Addition via Logic Gates

 


Binary Addition

 
0 0 1 1
+ 0 + 1 + 0 + 1




00 01 01 10
inputoutput
ABcarrysum
0000
0101
1001
1110

What do these results look like?


One-bit Addition

inputoutput
ABcarrysum
0000
0101
1001
1110
 
sum = A XOR B
carry = A AND B
Half-Adder Circuit Diagram
We can also draw this using the other XOR circuit diagram or an XOR gate.

NOTE: This does not allow for a carry-in! What about if we want to add numbers that have more than one bit?

This does only half of the total task, and is known as a half-adder.


Binary Addition with carry-in

 
0 0 1 1 0 0 1 1
+ 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1








00 01 01 10 00 01 01 10
carry-in + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1








00 01 01 10 01 10 10 11

 

inputintermediate output
carryin AB carryh1sumh1 carryoutsumfull
0000000
0010101
0100101
0111010
1000001
1010110
1100110
1111011

If we show the first bit of the second addition (carryin + sumh1) explicitly, notice the relationship between sumh2 and sumfull.
inputintermediate output
carryin AB carryh1sumh1 carryh2sumh2 carryoutsumfull
000 0 0 0 0 00
001 0 1 0 1 01
010 0 1 0 1 01
011 1 0 0 0 10
100 0 0 0 1 01
101 0 1 10 10
110 0 1 10 10
111 1 0 0 1 11
sumfull = carryin XOR sumh1
(which makes sense because we did another one-bit half-add: carryin + sumh1)

What about the carry? Notice the relationship between carryh1, carryh2, and carryout.
inputintermediate output
carryin AB carryh1sumh1 carryh2sumh2 carryoutsumfull
000 0 0 0 0 00
001 0 1 0 1 01
010 0 1 0 1 01
011 1 0 0 0 10
100 0 0 0 1 01
101 0 1 10 10
110 0 1 10 10
111 1 0 0 1 11
carryout = carryh1 OR carryh2

Summary: One-bit Addition With Carry-in

Full-Adder Circuit Diagram

We have two half-adders. The first adds A + B. The sum bit of that is then added to the carryin in the second half-adder. The overall sum is the sum bit from the second add.

sumfull = carryin XOR sumh1

The addition yields a carry if either of the two half-adders yield a carry.

carryout = carryh1 OR carryh2


Next: How do we set up a multi-bit adder?

Alyce Brady, Kalamazoo College