|
You may be surprised to see how easy it is to create a logic circuit that adds binary
numbers. The binary half-adder is perfect for adding 1-bit binary numbers. It is
made out of one AND gate and one XOR gate. Here is how it is arranged in a diagram:
A and B are the two inputs. In this case they are the two bits that are to be added.
The XOR gate is used to figure out the sum, while the AND gate is used to figure out the
carry. Let us start with the XOR gate. A and B are inputted, and if the two bits differ,
the output of the XOR gate is 1, which means that the sum is 1. Otherwise, the output of
the XOR gate is 0. If you recall addition of bits, 0 + 0 = 0, 0 + 1 = 1, while 1 + 1 = 0
with a carry of 1. This is where the AND gate comes in. If both A and B are 1, then
the output for the AND gate, which represents the carry, is 1. Otherwise the carry
is 0. This can be summarized in a truth table for the half-adder:
| Input |
Output |
| A |
B |
Sum |
Carry |
| 0 |
0 |
0 |
0 |
| 0 |
1 |
1 |
0 |
| 1 |
0 |
1 |
0 |
| 1 |
1 |
0 |
1 |
|
The Half-Adder has its own special symbol in diagrams in order to make them simpler.
This is what it looks like:
Now that we know how the computer adds two digits at a time, it is time to learn how it
adds two bits and a carry at the same time.
|