where we are: from memory to compute
Until this page, we built circuits that store. Starting here, we build circuits that do something. The first thing they'll do is add.
The half adder is the simplest possible arithmetic: two binary inputs (A, B), two binary outputs (sum, carry). Why two outputs? Because 1+1=2, which is binary "10" — two bits. The carry is the overflow into the next column.
An XOR gate (sum = "exactly one input is 1") and an AND gate (carry = "both inputs are 1"). From here on, we treat gates as black boxes — hover any to see its truth table.
A = 0, B = 0
Hit ↺ reset. Both inputs are 0. 0 + 0 = 0, so both outputs are 0. Look at the gates: XOR is dark (0 XOR 0 = 0), AND is dark (0 AND 0 = 0). The display reads 0 0.
click A → 1 (or B → 1)
One input is now 1, the other still 0. 1 + 0 = 1. The XOR lights up (its rule: "exactly one input is 1"). The AND stays dark (its rule: "both inputs are 1"). sum = 1, carry = 0.
So when the inputs differ, XOR fires and AND doesn't — that's exactly the "no overflow yet" case of addition.
click both → 1
Now A = B = 1. 1 + 1 = 2 = binary 10. The XOR turns OFF (XOR is 0 when inputs match), and the AND turns ON. sum = 0, carry = 1.
This is the "overflow" case. A single bit can't hold the value 2, so the result spills into the carry. The carry IS the second bit of the answer.
the key insight
Look at the structure: each output is a logic gate applied to A and B.
• sum = A XOR B — "the bits differ" — the low bit of A+B.
• carry = A AND B — "both bits high" — the high bit of A+B.
Those two gates, working together, IS the addition of two bits. The whole truth table of one-bit addition is just two truth tables stacked. Arithmetic, decomposed into pure logic.
why this matters
This is the first taste of compute. Up until now we've built circuits that remember (latch → DFF → register). The half adder is a circuit that does something — it transforms inputs into a new output by pure combinational logic. No memory, no clock, just gates.
From here, multi-bit addition is just stacking half adders together — chain the carry of bit N into bit N+1, and you can add arbitrarily wide numbers. That's the full adder (next page), and a chain of full adders is a ripple-carry adder. Plug that into an ALU and you have computation.