How to build a BCD to excess-3 code converter
A BCD to excess-3 converter adds 3 to a decimal digit written in BCD: 0 (0000) becomes 0011, 9 (1001) becomes 1100. With the six unused BCD codes treated as don't-cares, four short equations do it: E0 = NOT B0, E1 = B1 XNOR B0, E2 = B2 XOR (B1 OR B0) and E3 = B3 OR B2 (B1 OR B0).
Excess-3 (XS-3) writes each decimal digit as its value plus 3. Its best-known property is that it is self-complementing: inverting every bit of a digit gives the code of 9 minus that digit, which made decimal subtraction simpler in early calculators and computers. Because inputs 10 to 15 never occur in BCD, the K-maps can use them as don't-cares, which is why the converter needs only six gates rather than a full 4-bit adder. All ten valid digits are checked before the page is built; the reverse direction, B = E - 3, is the same idea with subtraction.
Open this circuit in the lab →
What you need
- 1× NOT: E0 = NOT B0
- 1× XNOR: E1 = B1 XNOR B0
- 1× OR: B1 OR B0, shared by E2 and E3
- 1× XOR: E2 = B2 XOR (B1 OR B0)
- 1× AND: B2 AND (B1 OR B0)
- 1× OR: E3 = B3 OR B2 (B1 OR B0)
Step by step
- Place the BCD inputs
B3toB0and probesE3toE0. - Bit 0 just flips:
E0 = NOT B0(adding 3, an odd number, always changes the last bit). - Bit 1:
E1 = B1 XNOR B0. - Build
B1 OR B0once. ThenE2 = B2 XOR (B1 OR B0)andE3 = B3 OR (B2 AND (B1 OR B0)). - Count the inputs from 0000 to 1001 and check each output is the input plus 3.
BCD to excess-3 table
| Decimal | BCD B3..B0 | Excess-3 E3..E0 |
|---|---|---|
| 0 | 0000 | 0011 |
| 1 | 0001 | 0100 |
| 2 | 0010 | 0101 |
| 3 | 0011 | 0110 |
| 4 | 0100 | 0111 |
| 5 | 0101 | 1000 |
| 6 | 0110 | 1001 |
| 7 | 0111 | 1010 |
| 8 | 1000 | 1011 |
| 9 | 1001 | 1100 |
Read any row and its mirror: 2 is 0101 and 7 is 1010, the bitwise inverse, because 2 + 7 = 9. That self-complementing pattern holds for every pair of digits that add up to 9. Inputs 1010 to 1111 are not BCD digits, so the circuit's outputs for them do not matter.
You can also read the full theory in the lesson on BCD. 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 to excess-3 code converter in the lab →Frequently asked
What is excess-3 code?
A decimal code that writes each digit as its 4-bit binary value plus 3, so 0 is 0011 and 9 is 1100. It is self-complementing: inverting all four bits gives the code for 9 minus the digit.
How do you convert BCD to excess-3?
Add 3 (0011) to the BCD digit. As logic, with codes 10 to 15 as don't-cares: E0 = NOT B0, E1 = B1 XNOR B0, E2 = B2 XOR (B1 OR B0), E3 = B3 OR B2 (B1 OR B0).
Why is excess-3 called self-complementing?
Because the 9's complement of a digit is just the bitwise NOT of its excess-3 code. For example 3 is 0110 and 6 is 1001. That made decimal subtraction easy to do with the same adder.
How do you convert excess-3 back to BCD?
Subtract 3 from each 4-bit group, or equivalently add 1101 and drop the carry. A gate-level converter uses the same K-map method with the six unused codes as don't-cares.