Login  Register

Re: different bus widths

Posted by cadet1620 on Sep 27, 2011; 4:04pm
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/different-bus-widths-tp3372452p3373083.html

afsd wrote
Not(in=zx, out=notzx);
And16(a=x, b[0..15]=notzx, out=x1);

why doesn't this work?
The problem is that b[0..15] is a 16-bit bus (same as b by itself) and notzx is a single wire.

I originally built my ALU this way by making a chip called Widen16 with 1-bit in and 16-bit out that I could use to make code basically identical to yours work:
    Not(in=zx, out=notzx);
    Widen16(in=notzx, out=notzx16)
    And16(a=x, b=notzx16, out=x1);

With a bit more thought, I realized that I could make the ALU using only the TECS chips by choosing what values get presented to the And/Add rather than computing them.

Note that the built-in constants true and false will match any bus width.

--Mark