Skip to main content

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

Short answer

Gray code: successive numbers differ by one bit. A 3-bit binary to Gray converter: truth table gives G2=B2, G1=B2⊕B1, G0=B1⊕B0. Circuit uses two XOR gates. Example: binary 010 yields Gray 011.

Define Gray Code. Design 3-bit binary to gray code converter circuit with necessary truth table and circuit diagram.

Gray code

Gray code is an unweighted, reflected binary code in which successive numbers differ in only one bit position. Examples: 0 = 000, 1 = 001, 2 = 011, 3 = 010. It is used in shaft encoders and K-maps because only one bit changes at each step, avoiding false intermediate values.

3-bit binary to Gray code converter

Inputs: B2B1B0B_2B_1B_0 (binary, B2B_2 = MSB). Outputs: G2G1G0G_2G_1G_0.

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 →