culchie wrote
Will wrote
In this case, would you just connect the carry output and carry input to ground?
AFAIK in HDL you don't need to connect them to anything, at least I didn't.
I'm not sure about the real world, whether it's done using full adders only or a mixture as you did
In the real world we do it using full adders for all bits.
One of the simplifications in the Hack CPU is that there is no carry bit (or any other latched status bits). This simplifies things quite a bit since there are therefore no instructions to test or set status bits. The carry bit is usually used to implement multiprecision arithmetic. For example:
LOAD a[0]
ADD b[0] // Sets ALU carry in to 0; stores ALU carry out in carry latch
STORE c[0]
LOAD a[1]
ADDC b[1] // Sets ALU carry in to carry latch
STORE c[1]
Also, if you are building with discrete parts, they come wider than 1 bit so it makes sense to use 4 4-bit full adders to make a 16-bit adder, or 4 4-bit ALUs to make a 16-bit ALU.
As for unused inputs, HDL appears to assume unused inputs are FALSE. In the real world, they should always be tied high or low. Unconnected inputs can pick up electrical noise resulting in erratic behavior.
Don't connect unused outputs to anything.
--Mark