ARTICLE CONTENT · UPDATED 14 JAN, 2026

CODE CONVERSION

Code Converters - Binary to/from Gray Code

Code Converters are digital combinational circuits that translate data representation from one format to another. This article covers the concepts, truth tables, K-maps, Boolean expressions, and logic circuits for converting binary code to Gray code and vice versa.

1. What are Code Converters?

Code Converters are digital circuits or algorithms designed to translate data representation from one format to another format. The binary-to-Gray code converter takes binary input and translates it into its corresponding Gray code representation.

What is Binary Code?

Binary code is the numerical system used in digital electronics consisting of symbols 0 and 1. Each bit position represents a power of 2 starting from the rightmost bit (20, 21, 22 ...). It serves as the basis for encoding text and numbers in digital systems.

What is Gray Code?

Gray Code is an unweighted binary system where every successive pair of numbers differs by only one bit. It eliminates multi-bit switching errors when hardware transitions between states.

Alternative Names for Gray Code:

Unit Hamming Distance Code Cyclic Code Reflecting Code

2. Converting Binary to Gray Code

Let b0, b1, b2, b3 be the binary bits (b0 = LSB, b3 = MSB) and g0, g1, g2, g3 be the Gray code bits (g0 = LSB, g3 = MSB).

Truth Table

Binary (b3b2b1b0) Gray Code (g3g2g1g0)
00000000
00010001
00100011
00110010
01000110
01010111
01100101
01110100
10001100
10011101
10101111
10111110
11001010
11011011
11101001
11111000

K-Map Simplifications

K-Map for g3

b1,b0b3,b2 00011110
000000
010000
111111
101111

K-Map for g2

b1,b0b3,b2 00011110
000000
011111
110000
101111

K-Map for g1

b1,b0b3,b2 00011110
000011
010011
110011
100011

K-Map for g0

b1,b0b3,b2 00011110
000101
010101
110101
100101

Minimized Boolean Expressions

Logic Circuit (Binary to Gray)

b3 g3 b2 b1 b0 g2 g1 g0

3. Converting Gray Code to Binary

Converting Gray code back to binary uses feedback logic from the calculated binary outputs:

Truth Table

Gray Code (g3g2g1g0) Binary (b3b2b1b0)
00000000
00010001
00110010
00100011
01100100
01110101
01010110
01000111
11001000
11011001
11111010
11101011
10101100
10111101
10011110
10001111

K-Map Simplifications

K-Map for b3

g1,g0g3,g2 00011110
000000
010000
111111
101111

K-Map for b2

g1,g0g3,g2 00011110
000000
011111
110000
101111

K-Map for b1

g1,g0g3,g2 00011110
000011
011100
110011
101100

K-Map for b0

g1,g0g3,g2 00011110
000101
011010
110101
101010

Minimized Boolean Expressions

Logic Circuit (Gray to Binary)

g3 b3 g2 g1 g0 b2 b1 b0

4. Applications of Code Converters