Question with the 16 bit adder

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question with the 16 bit adder

Will
I made a 16 bit adder using 14 full adders a half adder (since you don't need a third input for the least significant big), and a couple of xor gates to accomplish addition for the most significant bit without using any and gates that would be used for carrying; the example said it would be easy to use 16 full adders. In this case, would you just connect the carry output and carry input to ground?
Reply | Threaded
Open this post in threaded view
|

Re: Question with the 16 bit adder

culchie
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
Reply | Threaded
Open this post in threaded view
|

Re: Question with the 16 bit adder

cadet1620
Administrator
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