Digital Logic: Binary to Gray Code Converter

Before starting with this read Digital Logic: Designing Decimal to 4 bit Gray Code Converter if you are unfamiliar.


Binary, Decimal and Gray Code Table:

Here I am representing gray code bits with A, Decimal values with D and Binary bits with B.

Binary Decimal Gray Code
B3 B2 B1 B0 D A3 A2 A1 A0
0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 1
0 0 1 0 2 0 0 1 1
0 0 1 1 3 0 0 1 0
0 1 0 0 4 0 1 1 0
0 1 0 1 5 0 1 1 1
0 1 1 0  6 0 1 0 1
0 1 1 1 7 0 1 0 0
1 0 0 0 8 1 1 0 0
1 0 0 1 9 1 1 0 1
1 0 1 0 10 1 1 1 1
1 0 1 1 11 1 1 1 0
1 1 0 0 12 1 0 1 0
1 1 0 1 13 1 0 1 1
1 1 1 0 14 1 0 0 1
1 1 1 1 15 1 0 0 0
Binary to Gray Code Converter:

This same technique can be applied to make gray to binary converter. There will be 4 input bits, which represent binary and 4 output bits which represent equivalent gray code.

Since we are creating binary to gray code converter so, we need to find expressions for each gray code output in terms of input binary bits.

So, there will be four output bits A_3, A_2, A_1, A_0 . For these output bits the input will be different combinations of B_3, B_2, B_1, B_0 based on minimized expression.


Karnaugh Maps:

A3:

4 bit binary to gray code A3 expression
4 bit binary to gray code A3 expression

Minimized expression from the above k map,
A_3 = B_3


A2:

4 bit binary to gray code A2 k map
4 bit binary to gray code A2 k map

Minimized expression from the above k map,
A_2 = B_3 \overline{B_2} + B_2 \overline{B_3}

But, the expression of XOR Gate is (Let, A and B be the inputs),
A.\overline{B} + B.\overline{A} = A \oplus B
[Note: This is not related to this problem but, only showing how XOR can be made from And, Or, Not gates]

Similarly,it can be shown that,
B_3 \overline{B_2} + B_2 \overline{B_3} = B_2 \oplus B_3

If XOR gate is not available then the former expression can be used with and, or and not gates to design the gray code converter.


A1:

4 bit binary to gray code A1 k map
4 bit binary to gray code A1 k map

Minimized expression from the above k map,
A_1 = B_1 \overline{B_2} + B_2 \overline{B_1}

Similarly,it can be shown that,
B_1 \overline{B_2} + B_2 \overline{B_1} = B_1 \oplus B_2


A0:

4 bit binary to gray code A0 k map
4 bit binary to gray code A0 k map

Minimized expression from the above k map,
A_0 = B_0 \overline{B_1} + B_1 \overline{B_0}

Similarly,it can be shown that,
B_0 \overline{B_1} + B_1 \overline{B_0} = B_0 \oplus B_1


Circuit Diagram using XOR gates:

Download the logisim circ file from github.

4 bit binary to Gray Code Converter using XOR gates
4 bit binary to Gray Code Converter using XOR gates

Circuit Diagram without using XOR gates:

Download the logisim circ file from github.

4 bit binary to Gray Code Converter without using XOR gates
4 bit binary to Gray Code Converter without using XOR gates

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s