The half-adder is the smallest adding circuit: it adds two bits A and B and produces a sum bit S and a carry bit C. It has no carry input, so it serves the least significant bit of an adder, incrementers and counters, and it is the building block of the full adder.
10 min read | Beginner Level
What You'll Learn
- How two bits add, and why the result needs a sum and a carry output
- The half-adder equations: sum is XOR, carry is AND
- How to build it from XOR and AND gates, or from NAND gates only
- How half-adders chain into an incrementer
Quick Answer: Half-Adder
| A | B | S | C | Meaning |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 + 0 = 00 (binary) |
| 0 | 1 | 1 | 0 | 0 + 1 = 01 (binary) |
| 1 | 0 | 1 | 0 | 1 + 0 = 01 (binary) |
| 1 | 1 | 0 | 1 | 1 + 1 = 10 (binary) |
S = A xor B (1 when exactly one input is 1) C = A . B (1 only when both inputs are 1)
The sum is an XOR because a column discards the carry: 1 + 1 gives sum 0 and carry 1, that is 10 in binary. The carry is an AND because it is generated only when both bits are 1.
The Half-Adder Circuit
One XOR gate and one AND gate share the same two inputs:
Where Are Half-Adders Used?
Every counter and incrementer contains them: a program counter that steps by one, a timer, a FIFO pointer. They also sit in the least significant column of adders that have no carry in.
A Half-Adder From NAND Gates Only
NAND is a universal gate (see Universal Gates). The classic four-NAND XOR already contains NAND(A, B), the inverse of the carry, so one more NAND used as an inverter finishes the job: five NAND gates in total.
Each 2-input NAND is 4 transistors in CMOS, so this version uses 20 transistors. Library half-adder cells are smaller still.
Chaining Half-Adders: An Incrementer
A half-adder cannot sit in the middle of an addition, but it works in a chain that adds 1. An incrementer computes X + 1: the first half-adder adds 1 to bit 0, and each carry ripples into the next stage.
| Stage | X bit | Carry in | Sum bit | Carry out |
|---|---|---|---|---|
| bit 0 | 1 | 1 | 0 | 1 |
| bit 1 | 1 | 1 | 0 | 1 |
| bit 2 | 1 | 1 | 0 | 1 |
| bit 3 | 0 | 1 | 1 | 0 |
The input 0111 (7) becomes 1000 (8): the carry ripples through bits 0, 1 and 2 and stops at the first 0.
Quick Check
Q: What does the incrementer output for X = 1111, and what is the final carry out?
Show Answer
The carry ripples through all four stages: every sum bit is 0 and the last carry out is 1, so the result is 0000 with carry 1 (15 + 1 wraps to 0).
An incrementer does not have to ripple: the carry into bit i is the AND of all lower bits of X, so the chain can be replaced by an AND tree when speed matters.
Where Do the XOR and AND of a Half-Adder Reappear?
The XOR half is the core of parity generators and CRC circuits, and the AND half is the carry-generate term used by fast adders.
Common Mistakes
Mistake #1: Using OR for the sum
Wrong: S = A + B (OR) in the equations
Right: S = A xor B
Why? For A = B = 1 the sum bit is 0 and the carry is 1. OR gives 1, which is wrong.
Mistake #2: Dropping the carry
Wrong: Reading only the sum output of 1 + 1
Right: Use both outputs: the result of 1 + 1 is the two-bit number 10.
Why? The sum of two bits can need two bits, so a one-bit result throws the carry away.
Mistake #3: Using a half-adder where a carry-in exists
Wrong: A half-adder in column 3 of a 4-bit adder
Right: Use a half-adder only in the lowest column; every other column needs a full adder.
Why? Columns above the lowest add three bits (A, B and the carry from below), which a half-adder cannot do.
Practice Exercise
Challenge: Design a Half-Subtractor
A half-subtractor computes A - B for two bits. It has a difference output D and a borrow output Bo, which is 1 when A < B.
- Write the truth table.
- Derive the equations for D and Bo and compare them with the half-adder.
Hint
Subtracting 1 from 0 gives a difference of 1 with a borrow.
Solution
1. A B | D Bo 0 0 | 0 0 0 1 | 1 1 1 0 | 1 0 1 1 | 0 0 2. D = A xor B (same as the half-adder sum) Bo = A' . B (the carry with A inverted)
Summary
In this tutorial, you learned:
- A half-adder adds two bits: S = A xor B and C = A . B
- 1 + 1 gives sum 0 and carry 1, which is 10 in binary
- It is one XOR and one AND gate, or five NAND gates, and has no carry input
- Chains of half-adders make incrementers: the carry ripples through the 1s and stops at the first 0