Add16

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

Add16

dmoeller
Im not sure what the carry is supposed to be for a 16 bit adder. the textbook says overflow is neither detected nor handled, does that mean that carry is NULL everytime? or is carry one of the inputs in the next add?
Reply | Threaded
Open this post in threaded view
|

Re: Add16

ybakos
Carry and overflow are two separate things. Consider adding the two numbers 333 + 999 by hand. In the rightmost column (least significant digits) we add 9 and 3 to get 12, and "1" is the carry into the next column. To get the next column's sum, we add 9 and 3 plus the carry, to get 13, etc.

When the book states that we're going to ignore overflow, it means that we don't have to do anything with the carry result of the most significant digits.

Reply | Threaded
Open this post in threaded view
|

Re: Add16

cadet1620
Administrator
In reply to this post by dmoeller
Add16 implements 16-bit binary addition. This works similarly to ordinary decimal addition:
  1 1
  4567
+ 1825
------
  6392
In binary, the carry into the adder for bit 0 is always 0. In fact, you can save a little hardware by using a half adder for bit 0.
The carry into all other bits n is the carry output from the bit n-1 adder.
Since you are generating a 16-bit result, the carry output from the bit 15 adder is discarded.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Add16

dmoeller
So, use a half adder for bit 0, full adder for bits 1-15.  Should the carry of the last call to full adder be null?
FullAdder (.... sum=sum carry=NULL) ?
or just ..... sum=sum carry=W0 and have W0 go nowhere?
Reply | Threaded
Open this post in threaded view
|

Re: Add16

cadet1620
Administrator
dmoeller wrote
So, use a half adder for bit 0, full adder for bits 1-15.  Should the carry of the last call to full adder be null?
FullAdder (.... sum=sum carry=NULL) ?
or just ..... sum=sum carry=W0 and have W0 go nowhere?
If you don't mention "carry" at all in the final FullAdder, it will be connected to nothing.  Just like an IC pin with no wire soldered to it.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Add16

dmoeller
ok, thank you.