How to build a 4-bit binary to BCD converter
A 4-bit binary to BCD converter turns a binary number from 0 to 15 into two decimal digits: a tens digit T0 = B3 AND (B2 OR B1), which is 1 for 10 and above, and a units digit that is the number itself up to 9 and the number minus 10 above that.
Displays and decimal readouts need one 4-bit BCD code per decimal digit, so 13 must become 0001 0011, not 1101. For four input bits the tens digit can only be 0 or 1, and the units digit comes straight from K-maps over the 16 rows. One bit is free: subtracting 10 never changes whether a number is odd, so U0 = B0. Feed the units digit into a BCD to 7-segment decoder to light a display. For wider numbers the usual method is the shift-and-add-3 (double dabble) algorithm, which builds the BCD digits one input bit at a time. All 16 inputs are checked before the page is built.
Open this circuit in the lab →
What you need
- 1× OR: B2 OR B1
- 1× AND: tens T0 = B3 AND (B2 OR B1)
- 1× AND: B3 B2, shared by U1 and U2
- 3× AND / OR: U1 = B3' B1 + B3 B2 B1' (two ANDs and an OR)
- 3× AND / OR: U2 = B3' B2 + B3 B2 B1 (two ANDs and an OR)
- 2× AND: U3 = B3 B2' B1' (high only for 8 and 9)
- 3× NOT: B3', B2' and B1'
Step by step
- Place inputs
B3(most significant) toB0, and probes for the tens bitT0and the units digitU3toU0. - Tens: the number is 10 or more exactly when B3 is 1 and B2 or B1 is 1 (10 is 1010, 12 is 1100), so
T0 = B3 AND (B2 OR B1). - Units bit 0: wire B0 straight to
U0. - Units bits 1 to 3 from the K-maps:
U1 = B3' B1 + B3 B2 B1',U2 = B3' B2 + B3 B2 B1,U3 = B3 B2' B1'. - Count the inputs from 0000 to 1111 and read the outputs as two decimal digits: up to 9 the tens bit stays 0, then 10 shows as 1 and 0000.
Binary to BCD truth table
| Decimal | B3 B2 B1 B0 | Tens T0 | Units U3 U2 U1 U0 |
|---|---|---|---|
| 0 | 0000 | 0 | 0000 |
| 1 | 0001 | 0 | 0001 |
| 2 | 0010 | 0 | 0010 |
| 3 | 0011 | 0 | 0011 |
| 4 | 0100 | 0 | 0100 |
| 5 | 0101 | 0 | 0101 |
| 6 | 0110 | 0 | 0110 |
| 7 | 0111 | 0 | 0111 |
| 8 | 1000 | 0 | 1000 |
| 9 | 1001 | 0 | 1001 |
| 10 | 1010 | 1 | 0000 |
| 11 | 1011 | 1 | 0001 |
| 12 | 1100 | 1 | 0010 |
| 13 | 1101 | 1 | 0011 |
| 14 | 1110 | 1 | 0100 |
| 15 | 1111 | 1 | 0101 |
Rows 0 to 9 pass straight through with a tens digit of 0. From 10 to 15 the tens digit is 1 and the units digit is the input minus 10 (1010 becomes 0000, 1111 becomes 0101), so the units digit never goes above 5 in that half.
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 binary to BCD converter in the lab →Frequently asked
How do you convert binary to BCD?
For a 4-bit input, set the tens digit to 1 when the number is 10 or more and subtract 10 from the units digit in that case; as logic that is T0 = B3 (B2 + B1) plus a few gates per units bit. For wider inputs, the double dabble method shifts the binary number left one bit at a time into BCD digits and adds 3 to any digit that is 5 or more before each shift.
What is 13 in BCD?
0001 0011: the tens digit 1 and the units digit 3, each as its own 4-bit code. In plain binary 13 is 1101.
Why is the lowest units bit just B0?
Subtracting 10, an even number, never changes whether a number is odd or even, so the last bit of the units digit always equals the last bit of the input.
What is the difference between binary and BCD?
Binary writes the whole number in base 2, so 4 bits reach 15. BCD encodes each decimal digit separately in 4 bits, which wastes the codes 1010 to 1111 but makes decimal display and rounding simple.