The not-so-deadly Adder

Steve > Projects > Computer > Adder

Remeber the XOR gate. It has an output that is on only if one input or the other is on, but not both. This little gate can be used to make a simple adder. If we want to add two inputs, called A and B, the sum of those would be S = AB.

We can see this is true simply by looking at all the possibilities. 0+0=0, 0+1=1, 1+0=1, and 1+1=2, and two in binary numbers is written "10". But we see that we really need a two wire (or two bit) output. If they were both on, this extra ouput wire, we'll call Cout, would be on. So we can write Cout = AB (ie A AND B). Below is the design.

Full Adder

The above adder is called a half adder. A "full adder" can take three inputs. Below is a truth table for adding three inputs. You'll notice only the top half of the table could be calculated by the half adder.

 A  B  C Cout S
0000  0
1000  1
0100  1
1101  0
0010  1
1011  0
0111  0
1111  1

That's not so bad. Below is the somewhat more complicated design for a full adder, but take a little time to see what it's doing, and you'll get it. Notice that S is on only when two of the three inputs are on. So S = (AB) C. Now see that Cout is on in either of two cases. 1) When one of A or B is on and C is on also. 2) When both A and B are on. This means Cout = ((AB)C) + (AB).

But that's too much to draw every time we want to put an adder in our design, so we can draw it thusly:

Add it all up

But what good is a computer that can only add up to three? Back to grade school: How do you go about adding numbers such as 109 and 092? First you add the numbers on the right. So 9+2 gives 1 and we carry 1 into the tens column. So then we have the carried 1 plus 9 + 0 which gives 0, and carry 1 to the hundreds. Then 1 + 1 = 2. So our number is 201!

That was hard work I know, but we'll use that technique for our computer as well. You notice we had an output marked Cout and an input marked Cin. Those will be our carry numbers. Below is a design that will add, not 190 + 092, but A2A1A0 + B2B1B0.

Or the shorthand:

That's it. Now we know how to make an adder. These simple creatures may be small, but they pack a mighty bite--No computer could exist without them.