Re: whats wrong with my hdl - inc16
Posted by
cadet1620 on
Feb 16, 2014; 2:23am
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/whats-wrong-with-my-hdl-inc16-tp4027786p4027790.html
pwolf wrote
Add16(a[0] = in[0], b[0] = true, out[0]= out[0]);
Add16(a[1] = in[1], b[1] = false, out[1]= out[1]);
Add16(a[2] = in[2], b[2] = false, out[2]= out[2]);
...
Each Add16 in your circuit is an independent 16-bit adder. The first line adds 1 to in[0] and assigns it to out[0]. The carry from this addition is discarded because there is no connection to this adder's out[1].
The second line is another adder that adds 0 to in[1] and assigns it to out[1]. Since this adder's a[0] and b[0] are not connected, they default to 0 so there is never a carry generated by a[0]+b[0], so out[1] always equals in[1].
Your Inc16 needs to have exactly one Adder16 in it so that carry propagates correctly. The adder's "a" input needs to be "in" and the "b" input needs to be 1. The trick is to figure out how to set "b" = 1.
--Mark