Subtractors
A subtractor computes A − B in binary, producing a difference and a borrow.
1. Half Subtractor
Subtracts two bits: A − B. Note that the order matters — subtraction is not commutative.
Truth table
| A | B | Difference (D) | Borrow (Bout) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
Row 2 explains everything: 0 − 1 requires borrowing 1 from the next higher position, which makes the local computation 10 − 1 = 1. Hence D = 1, Borrow = 1.
Boolean equations
D = A'B + AB' = A ⊕ B (same as the half-adder sum!)
Bout = A' . B (borrow only when A=0 and B=1)
Compare with the half adder: the sum/difference expressions are identical; only carry (A·B) vs borrow (A'·B) differ. A half subtractor is a half adder with one inverter added on A before the AND gate.
2. Full Subtractor
Subtracts three bits: A − B − Bin, where Bin is the borrow from the previous (less significant) stage.
Truth table
| A | B | Bin | Difference (D) | Borrow out (Bout) |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 | 1 |
D = Σm(1, 2, 4, 7) <- identical to the full-adder SUM
Bout = Σm(1, 2, 3, 7)
K-map for Difference
B Bin
00 01 11 10
+------+------+------+------+
A=0 | 0 | 1 | 0 | 1 |
+------+------+------+------+
A=1 | 1 | 0 | 1 | 0 |
+------+------+------+------+
Checkerboard -> D = A ⊕ B ⊕ Bin
K-map for Borrow-out
B Bin
00 01 11 10
+------+------+------+------+
A=0 | 0 | 1 | 1 | 1 |
| (0) | (1) | (3) | (2) |
+------+------+------+------+
A=1 | 0 | 0 | 1 | 0 |
| (4) | (5) | (7) | (6) |
+------+------+------+------+
Group m1, m3 -> A'.Bin
Group m2, m3 -> A'.B
Group m3, m7 -> B.Bin
Bout = A'B + A'.Bin + B.Bin
= A'B + Bin(A ⊕ B)' <- alternative form
= A'B + Bin(A' + B) ... standard exam answer is the first form
Full subtractor from two half subtractors
HS1: D1 = A ⊕ B B1 = A' . B
HS2: D = D1 ⊕ Bin B2 = D1' . Bin
Then: Bout = B1 + B2 = A'B + (A ⊕ B)'.Bin
3. Adder vs Subtractor — Side by Side
| Quantity | Full Adder | Full Subtractor |
|---|---|---|
| Third input | Carry-in | Borrow-in |
| Sum / Difference | A ⊕ B ⊕ Cin | A ⊕ B ⊕ Bin |
| Carry / Borrow | AB + Cin(A ⊕ B) | A'B + Bin(A ⊕ B)' |
| Difference in hardware | — | One inverter on A, and the XOR feeding the second AND is complemented |
4. Worked Numerical
Compute 1011 - 0110 using four full subtractors (Bin of the LSB = 0).
Position: 3 2 1 0
A: 1 0 1 1
B: 0 1 1 0
Stage 0: A=1 B=0 Bin=0 -> D=1, Bout=0
Stage 1: A=1 B=1 Bin=0 -> D=0, Bout=0
Stage 2: A=0 B=1 Bin=0 -> D=1, Bout=1
Stage 3: A=1 B=0 Bin=1 -> D=0, Bout=0
Difference = 0101 = 5 Check: 11 - 6 = 5 ✓ Final borrow 0 -> positive result
5. Why Real Machines Do Not Build Subtractors
Building a separate subtractor doubles the arithmetic hardware. Real ALUs use 2's complement:
A - B = A + (2's complement of B)
= A + B' + 1
A single adder plus a row of XOR gates does both operations — that is the parallel adder/subtractor of the next lesson, and it is the standard answer to "how does a computer subtract?"
6. Practice
1. Design a half subtractor using NAND gates only.
D = A ⊕ B -> 4 NAND
Bout = A'B -> NOT A (1 NAND) then AND (2 NAND) = 3 NAND
Total = 7 NAND (sharing the inverter reduces this)
2. Verify the full subtractor for A=0, B=1, Bin=1 (0 - 1 - 1 = -2)
D = 0 ⊕ 1 ⊕ 1 = 0
Bout = A'B + Bin(A⊕B)' = 1.1 + 1.(1)' = 1 + 0 = 1
Reading "Bout D" as -(2) + 0 -> borrow 1, difference 0
i.e. 0 - 1 - 1 = 10(2) borrowed, difference 0 ✓
Next: cascade these single-bit cells into a full n-bit parallel adder/subtractor, and see why the carry chain is the speed limit of the whole CPU.