Skip to main content

BCD code and 3-bit binary-to-Gray converter

Short answer

BCD encodes each decimal digit in 4-bit binary (8421), valid 0000–1001. A 3-bit binary to Gray converter: G2 = B2, G1 = B2⊕B1, G0 = B1⊕B0, implemented with two XOR gates. Example: binary 101 yields Gray 111.

What is a BCD code? Design a 3-bit binary to Gray code converter.

BCD code

BCD (Binary Coded Decimal) represents each decimal digit separately by its 4-bit binary value (8421 weights). Only 0000–1001 are valid; 1010–1111 are invalid. Example: (93)10(93)_{10} = 1001 0011 (BCD), while in binary 93=1011101293 = 1011101_2. BCD is used in calculators, clocks and 7-segment displays.

3-bit binary to Gray code converter

Inputs: binary B2B1B0B_2B_1B_0 (B2B_2 = MSB). Outputs: Gray G2G1G0G_2G_1G_0. In Gray code, successive values differ in only one bit.

Truth table (3-bit binary to Gray)

B2B_2B1B_1B0B_0G2G_2G1G_1G0G_0
000000
001001
010011
011010
100110
101111
110101
111100

Simplification (K-maps)

  • G2=∑m(4,5,6,7)=B2G_2 = \sum m(4,5,6,7) = B_2
  • G1=∑m(2,3,4,5)=Bˉ2B1+B2Bˉ1=B2⊕B1G_1 = \sum m(2,3,4,5) = \bar B_2 B_1 + B_2\bar B_1 = B_2 \oplus B_1
  • G0=∑m(1,2,5,6)=Bˉ1B0+B1Bˉ0=B1⊕B0G_0 = \sum m(1,2,5,6) = \bar B_1 B_0 + B_1\bar B_0 = B_1 \oplus B_0

K-map for G1G_1 (rows B2B_2, columns B1B0B_1B_0):

        B1B0
 B2    00  01  11  10
  0  |  0 | 0 | 1 | 1 |
  1  |  1 | 1 | 0 | 0 |

Logic circuit

 B2 ---+------------------------ G2
       |    +-------+
       +--->|       |
            |  XOR  |----------- G1
 B1 ---+--->|       |
       |    +-------+
       |    +-------+
       +--->|       |
            |  XOR  |----------- G0
 B0 ------->|       |
            +-------+

The converter needs only two XOR gates: the MSB passes straight through and each other Gray bit is the XOR of two neighbouring binary bits.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 1 questions →