Re: How do I combine 2 sperate bits in a 2bit input
Posted by
cadet1620 on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/How-do-I-combine-2-sperate-bits-in-a-2bit-input-tp3593549p3595105.html
rogerdodger91 wrote
//Now lets explore something that isnt logically sound.
And(a=a[0], b=a[6], out=Buggy_1BIT_AndAB);
//See the problem here that isnt obvious, that tends to confuse alot of people is the fact that logically //speaking, your trying to pass an individual bit from a 16 bit byte magically.
...
And16(a=a, b=a, out[0]=person1, out[6]=person2); //ect
And(a=person1, b=person2, out=Saved_People);
These two statements are in fact logically equivalent, the version using And16 and And is, however, a lot less hardware efficient, both in space and time.
You will do much better to NOT think of buses as arrays. Buses are just collections of wires that contain related information. It is often useful to process all the data on the bus at the same time but is not required; the electrons will not jump out of unused wires (at least at the voltages used in computers).
When you get to chapter 5 and are designing your ALU, one of the requirements is to decode the instructions that come in on the instruction bus. You will have many lines that look like
And(a=instr[15], b=instr[0], out=jmpEQ)
that decode the individual control signals used by the ALU.
--Mark