How to build a BCD adder from logic gates
A BCD adder adds two decimal digits stored in BCD (0000 to 1001) plus a carry-in and outputs one BCD digit and a decimal carry. It adds in binary first, and if the binary sum is more than 9 it adds 6 (0110) to skip the six unused codes and sets the carry.
A 4-bit binary adder counts to 15, but a BCD digit stops at 9, so binary sums from 10 to 19 come out wrong as decimal digits. Adding 6 fixes them: it jumps over the six codes 1010 to 1111 and produces the right digit with a carry. The correction is needed exactly when the first adder carries out or its result is 1010 to 1111, which simplifies to Cout = K + Z3 Z2 + Z3 Z1. That Cout is both the decimal carry and the "add 6" signal for a second adder. Every combination of two BCD digits and a carry-in (200 cases) is checked against real decimal addition before the page is built.
Open this circuit in the lab →
What you need
- 4× full adder: the binary sum Z = A + B + Cin, with carry K (each 2 XOR, 2 AND, 1 OR)
- 2× AND: Z3 Z2 and Z3 Z1, which detect sums 10 to 15
- 2× OR: Cout = K + Z3 Z2 + Z3 Z1
- 1× half adder: adding Cout into bit 1 of the correction (+ 0110)
- 1× full adder: adding Cout into bit 2 with the carry from bit 1
- 1× XOR: bit 3 of the correction (its carry out is not needed)
Step by step
- Place the BCD digits
A3toA0,B3toB0, and a carry-inCin. Add them with a 4-bit ripple-carry adder into Z3..Z0 with carry K. - Detect a result over 9:
Cout = K OR (Z3 AND Z2) OR (Z3 AND Z1). K covers sums 16 to 19; the two AND terms cover 10 to 15. - Add 0110 when Cout is 1: add Cout into bits 1 and 2 of Z with a second, short adder (bit 0 passes straight through).
- Probe the corrected digit as
S3toS0and the decimal carry asCout. - Try 0111 + 0101 (7 + 5): the binary sum is 1100 (12), Cout lights, and +6 gives S = 0010 with carry 1, which reads 12 in decimal.
Examples
| A | B | Cin | Binary sum | Corrected | Cout | Decimal |
|---|---|---|---|---|---|---|
| 0011 | 0101 | 0 | 1000 (8) | 1000 | 0 | 8 |
| 0111 | 0101 | 0 | 1100 (12) | 0010 | 1 | 12 |
| 1001 | 1001 | 0 | 1 0010 (18) | 1000 | 1 | 18 |
| 1001 | 1001 | 1 | 1 0011 (19) | 1001 | 1 | 19 |
| 0101 | 0100 | 1 | 1010 (10) | 0000 | 1 | 10 |
Inputs above 1001 are not valid BCD digits and are not part of the specification. Chain BCD adders through Cout and Cin to add multi-digit decimal numbers, one digit per stage, which is how calculators and early business computers did decimal arithmetic.
You can also read the full theory in the lesson on binary-coded decimal. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
Build more parts from gates
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the BCD adder in the lab →Frequently asked
Why do we add 6 in a BCD adder?
Four bits have 16 codes but BCD uses only 10 of them. When the binary sum is 10 or more, adding 6 skips the six unused codes (1010 to 1111), which leaves the correct decimal digit in the low four bits and produces the decimal carry.
When is the BCD correction needed?
When the binary sum is greater than 9: either the 4-bit adder produced a carry (sums 16 to 19) or the result is 1010 to 1111. The condition is Cout = K + Z3 Z2 + Z3 Z1, where K is the binary carry and Z the binary sum.
How many adders does a BCD adder need?
Two: a 4-bit binary adder for the sum and a second adder that adds 0110 when correction is needed. Because the correction only touches bits 1 to 3, the second adder can be smaller than a full 4-bit adder, as here.
What is the largest sum a one-digit BCD adder handles?
9 + 9 + 1 = 19, which is binary 10011. The correction turns it into digit 1001 (9) with a decimal carry of 1.