Experiments- 6 (Part -1)
Verify Binary to Gray and Gray to Binary conversion using NAND gates only.
Introduction
Binary Numbers is default way to store numbers, but in many applications binary numbers are difficult to use and a variation of binary numbers is needed. Gray code is an ordering of the binary numeral system such that two successive values differ in only one bit (binary digit). Gray codes are very useful in the normal sequence of binary numbers generated by the hardware that may cause an error or ambiguity during the transition from one number to the next. So, the Gray code can eliminate this problem easily since only one bit changes its value during any transition between two numbers.
Gray code has property that two successive numbers differ in only one bit because of this property gray code does the cycling through various states with minimal effort and used in K-maps, error correction, communication etc.
In computer science many times we need to convert binary code to gray code and vice versa. This conversion can be done by applying following rules :
1) Binary to Gray conversion :
- The Most Significant Bit (MSB) of the gray code is always equal to the MSB of the given binary code.
- Other bits of the output gray code can be obtained by Ex-ORing binary code bit at that index and previous index.
B3 = G3
B2 ⊕ B3 = G2
B1 ⊕ B2 = G1
B0 ⊕ B1 = G0

Figure-1: Binary to Gray Code Converter Circuit

Figure-2: Binary to Gray Code Converter Truth Table
Simulation:
- Step-1) Connect battery to supply 5V to the circuit.
- Step-2) Press Switches for different inputs.
- The switch in ON state is
and the switch in OFF state is 
- Step-3) The corresponding combination of input and output LEDs lit up for different combination of inputs.
- The input binary code LEDs are B3,B2,B1 and B0 and the output gray code LEDs G3,G2,G1 and G0 glow accordingly.
- The input LED in OFF state is
and in ON state is
. - The output LED in OFF state is
and in ON state is
. - Step-4) Click "Add" to add the values to the Truth Table.
- Step-5) Click "Print" to get the print out of the Truth Table.






Code Converter
2) Gray to binary conversion :
- The Most Significant Bit (MSB) of the binary code is always equal to the MSB of the given binary number.
- Other bits of the output binary code can be obtained by checking gray code bit at that index. If current gray code bit is 0, then copy previous binary code bit, else copy invert of previous binary code bit.
There are four inputs and four outputs. The input variable are defined as G3, G2, G1, G0 and the output variables are defined as B3, B2, B1, B0. From the truth table, combinational circuit is designed.The logical expressions are defined as :
G0 ⊕ G1 ⊕ G2 ⊕ G3 = B0
G1 ⊕ G2 ⊕ G3 = B1
G2 ⊕ G3 = B2
G3 = B3

Figure-3: Gray to Binary Code Converter Circuit

Figure-4: Gray to Binary Code Converter Truth Table
- Step-1) Connect battery to supply 5V to the circuit.
- Step-2) Press Switches for different inputs.
- The switch in ON state is
and the switch in OFF state is
- Step-3) The corresponding combination of input and output LEDs lit up for different combination of inputs.
- The input gray code LEDs are G3,G2,G1 and G0 and the output binary code LEDs B3,B2,B1 and B0 glow accordingly.
- The input LED in OFF state is
and in ON state is
.
- The output LED in OFF state is
and in ON state is
.
- Step-4) Click "Add" to add the values to the Truth Table.
- Step-5) Click "Print" to get the print out of the Truth Table.
Code Converter
Comments
Post a Comment