ABSCHALF ADDER01XOR0101AND01A B → C S0 0 → 0 00 1 → 0 11 0 → 0 11 1 → 1 0A B Cin → Cout S0 0 0 → 0 00 0 1 → 0 10 1 0 → 0 10 1 1 → 1 01 0 0 → 0 11 0 1 → 1 01 1 0 → 1 01 1 1 → 1 1ABCinPSCoutFULL ADDER01XOR01XOR01ANDAND01OR01
Lit wire with moving dashes: it carries a 1Lamps: a glowing lamp shows 1, a dark one 0Gate block: its symbol is on top, its name on the frontDashed tray: one half adder (an XOR and an AND)A half adder adds two bits with one XOR gate (the sum S) and one AND gate (the carry C). A full adder also adds a carry in: two half adders and an OR gate. The truth table card highlights the row being shown, and a lit wire carries a 1. A half adder is one XOR gate (sum) and one AND gate (carry). A full adder is two half adders and one OR gate: S = A XOR B XOR Cin and Cout = (A AND B) OR (Cin AND (A XOR B)), which is the same as AB + ACin + BCin (Harris and Harris, Digital Design and Computer Architecture, section 5.2.1). The two carries can never both be 1: the first is 1 only when A = B = 1, and then P = A XOR B = 0, so the second is 0. That is why a plain OR is enough to join them.

Adding two bits

  1. Adding bits works like adding on paper, but a column holds only 0 or 1. 0 + 1 = 1 fits. But 1 + 1 = 2, written 10 in binary: a 0 stays here and a carry of 1 moves left.

Adding three bits

The whole table

The sums, row by row

;; step 1/9 · add-bits
;; about: Inputs A, B, Sum S, Carry C, Truth table
Column addition with bits:

  0 + 0 =  0
  0 + 1 =  1
  1 + 0 =  1
  1 + 1 = 10   (two)

S (sum) is the bit that stays in the column.
C (carry) is the bit that moves one column left.

A B → C S
0 0 → 0 0
0 1 → 0 1
1 0 → 0 1
1 1 → 1 0

In binary each column is worth twice the one to its right, so 10 means one two and no ones: 2. A sum that does not fit in one column sends a carry left, just like 9 + 1 = 10 in decimal. In Python, ^, & and | on the numbers 0 and 1 work as XOR, AND and OR, so s = a ^ b ^ cin and cout = (a & b) | (cin & (a ^ b)) give the same 8 rows as the circuit.