The conversion between gray to binary and binary to gray is very common in digital systems. In one of our previous post we explained what are gray codes and how to convert from binary to gray and gray to binary. This post focus on implementing **code converter** using logic gates.

### Binary to Gray Code Converter

Gray code equivalent of the given binary number is computed as follows:

g_{3} = b_{3}

g_{2} = b_{3} ⊕ b_{2}

g_{1} = b_{2} ⊕ b_{1}

g_{0} = b_{1} ⊕ b_{0}

A **binary to gray code converter** can be implemented using XOR gates. For n input, n-1 gates are required. As shown in the image below for 4 inputs, 3 XOR gates are used:

### Gray to Binary Code Converter

Binary code equivalent of the given gray number is computed as follows:

b_{3} = g_{3}

b_{2} = b_{3} ⊕ g_{2}

b_{1} = b_{2} ⊕ g_{1}

b_{0} = b_{1} ⊕ g_{0}

A **gray to binary code converter** can be implemented using XOR gates. For n input, n-1 gates are required. As shown in the image below for 4 inputs, 3 XOR gates are used:

Hope you find the information presented here useful. Feel free to leave your footprints in the comments section below for any further queries, feedback or suggestions.

thanks

Really easy to understand.thanks..

Helped me thanks