Adder Anatomy
How do you make wires add two numbers? The logic gates we already know come to the rescue.
To add two bits, we need two results: the sum itself and the carry bit — the "one to carry over" when we add 1+1. The XOR gate is perfect for the sum: it outputs 1 only when the inputs differ, and 0 when both are 1. To catch the carry, we put an AND gate in parallel — it fires only when we add two ones at once.
This pairing of XOR and AND is called a half-adder. However, it can only add two bits and has no carry input. For a refresher on how numbers are represented in binary, see the article "Binary Math for Beginners".
Half adder: XOR and AND
A half adder adds two bits A and B and outputs two bits: Sum and Carry. Its formulas are the simplest possible:
Sum = A XOR B
Carry = A AND B
Let's check it with the truth table:
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Look at the last row: 1 + 1 gives a sum of 0 and a carry of 1 — binary "10", decimal two. Just like column addition.
But the half adder has a limitation: it doesn't know that a "one to carry over" may have arrived from the lower place. That's what the full adder is for.
Full adder: the third input
A full adder solves this: it has three inputs — A, B and CarryIn (the carry from the lower place) — and two outputs: Sum and CarryOut. The full truth table has 8 rows, covering all combinations of the three inputs:
| A | B | CarryIn | Sum | CarryOut |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
The pattern is clear: Sum is the sum of the three bits modulo two, and CarryOut is 1 whenever at least two of the inputs are 1.
The formulas of the adder
The sum is computed with a double XOR, and the carry is a "majority vote":
Sum = (A XOR B) XOR CarryIn
CarryOut = (A AND B) OR (A AND CarryIn) OR (B AND CarryIn)
The first XOR adds A and B; the second adds the carry CarryIn.
The carry is a "majority vote": CarryOut = 1 whenever at least two of the three inputs are 1. Three pairwise AND gates check each pair, and the OR gate collects the win — the majority side wins.
The carry chain: 113 + 29
One adder adds one place. To add 8-bit numbers, we chain eight full adders: the CarryOut of each feeds the CarryIn of the next. This construction is called a cascade, or ripple carry — the carry ripples through the places like a wave.
Let's test it with the numbers from the binary math article: 113 (01110001) + 29 (00011101).
FA0: 1 + 1 + 0 = 0, carry 1
FA1: 0 + 0 + 1 = 1, carry 0
FA2: 0 + 1 + 0 = 1, carry 0
FA3: 1 + 0 + 0 = 1, carry 0
FA4: 1 + 1 + 0 = 0, carry 1
FA5: 1 + 0 + 1 = 0, carry 1
FA6: 1 + 0 + 1 = 0, carry 1
FA7: 0 + 0 + 1 = 1, carry 0
Result: 10001110 = 142
Watch the carry ripple through the chain: from place 0 into place 1, then onward from place 4 to place 7. Importantly, all the adders work simultaneously: the circuit doesn't "execute code step by step" — signals simply propagate through the wires, and once the carry wave finishes its pass, the whole chain outputs the answer: 142.
In the game: from half adder to ADDER8
The game repeats this journey three times. In level 1.6 you build a half adder from XOR and AND and get the HalfAdder chip as a reward. In level 1.7 you build a full adder from XOR, AND and OR — and get the FullAdder chip.
Then, in level 1.8, you build the 8-bit adder ADDER8: eight full adders in a chain plus two splitters and a maker, to split the 8-bit inputs and gather the result back into a bus. Passing the level rewards you with the ADDER8 chip. To learn about buses, see the article "Information Buses".
Common mistakes
1. Sending the carry the wrong way. The CarryOut of a lower adder must go into the CarryIn of the next higher one, not the other way around.
2. Forgetting the third input. A full adder without a connected CarryIn degrades into two independent half adders.
3. Thinking the adders work one after another. The whole chain computes in parallel; the carry simply "ripens" as signals propagate.
Summary
1. A half adder adds two bits: Sum = A XOR B, Carry = A AND B.
2. A full adder also accepts a carry: inputs A, B, CarryIn, outputs Sum and CarryOut.
3. Sum = (A XOR B) XOR CarryIn, and CarryOut is a "majority vote" of three ANDs and one OR.
4. A cascade of adders adds numbers of any length: the carry of each place feeds the next one.
5. A chain of eight adders computes 113 + 29 = 142 = 10001110 in a single pass of the carry wave.
6. In the game: level 1.6 is the half adder, 1.7 is the full adder, 1.8 is ADDER8 built from eight FullAdders.
In level 1.7 you will build a full adder from XOR, AND and OR gates — exactly following the formulas in this article. Then, in level 1.8, you will chain such adders together to build the full 8-bit ADDER8 and see the carry cascade in action.