Prof. Neeraj Bhargava
Pooja Dixit
Department of Computer Science, School of Engineering & System
Sciences
MDS UniversityAjmer, Rajasthan
 Gray Code system is a binary number system in which two successive pair of
numbers differs in only one bit.
 It is also known as Reflected binary code. (RBC) or Cyclic code.
 Binary no is converted to gray code to reduce switching operation.
 Today gray code are widely used to facilitate the error correction in digital
communications such as cable TV system.
 It is unweighted code that means it does not depends on positional value of digit.
 It is also called unit distance code or minimum error code.
 It is used in applications in which the normal sequence of binary numbers
generated by the hardware may produce 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.
 Verify how two successive pair of numbers differs in only one bit.
 Now if we take an 3,4 decimal no as example and check how this number convert
into binary and gray code.
 Now lets see how many bits are changing in case of binary number.
 So, here in binary conversion total 3 bits(b0,b1,b2) are changing while in gray
code only 1 bit is changed.
Decimal Binary Gray
b3 b2 b1 b0 g3 g2 g1 g0
3 0 0 1 1 0 0 1 0
4 0 1 0 0 0 1 1 0
Decimal Binary Gray
0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 1
2 0 0 1 0 0 0 1 1
3 0 0 1 1 0 0 1 0
4 0 1 0 0 0 1 1 0
5 0 1 0 1 0 1 1 1
6 0 1 1 0 0 1 0 1
7 0 1 1 1 0 1 0 0
8 1 0 0 0 1 1 0 0
9 1 0 0 1 1 1 0 1
10 1 0 1 0 1 1 1 1
11 1 0 1 1 1 1 1 0
12 1 1 0 0 1 0 1 0
13 1 1 0 1 1 0 1 1
14 1 1 1 0 1 0 0 1
15 1 1 1 1 1 0 0 0
16 1 0 0 0 0 1 1 0 0 0
 Now if we take an 7,8 decimal no as example and check how this no convert into
binary and gray code.
 Now lets see how many bits are changing in case of binary number.
 So, here in binary conversion total 4 bits(b0,b1,b2,b3) are changing while in gray
code only 1 bit is changed.
 that’s why gray code is also called unit distance code or switching operation is
reduced in gray code.
Decimal Binary Gray
b3 b2 b1 b0 g3 g2 g1 g0
7 0 1 1 1 0 1 0 0
8 1 0 0 0 1 1 0 0
Step 1: Record the MSB as it is.
Step 2: Add the MSB to the next bit, record the sum and neglect the carry.
Step 3: Repeat the process
Ex1: Convert 1 0 1 1 to Grey code.
Solution: 1 0 1 1
1 1 1 0
MSB LSB
+ + + +
 XOR Operation
 Note: in Gray code conversion MSB remain same.
A B XOR
0 0 0
0 1 1
1 0 1
1 1 0
: Convert 1 1 1 0 to Grey code.
Solution: 1 1 1 0
1 0 0 1
Q1. 1001
Q2. 1010
Q3. 1111
+ + + +
MSB LSB
Step 1: Record the MSB as it is.
Step 2: Add the MSB to the next bit of gray code, record the sum and neglect the
carry.
Step 3: Repeat the process
Ex1: Convert 1 1 1 0 to Grey code.
Solution: 1 1 1 0
1 0 1 1
MSB LSB
+ + + +
 AssignmentQuestion
1. 1100
2. 1011
3. 1000
Ex1: Convert 1 0 0 1 to Grey code.
Solution: 1 0 0 1
1 1 1 0
+ + + +

Gray Code.pptx

  • 1.
    Prof. Neeraj Bhargava PoojaDixit Department of Computer Science, School of Engineering & System Sciences MDS UniversityAjmer, Rajasthan
  • 2.
     Gray Codesystem is a binary number system in which two successive pair of numbers differs in only one bit.  It is also known as Reflected binary code. (RBC) or Cyclic code.  Binary no is converted to gray code to reduce switching operation.  Today gray code are widely used to facilitate the error correction in digital communications such as cable TV system.  It is unweighted code that means it does not depends on positional value of digit.  It is also called unit distance code or minimum error code.  It is used in applications in which the normal sequence of binary numbers generated by the hardware may produce 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.
  • 3.
     Verify howtwo successive pair of numbers differs in only one bit.  Now if we take an 3,4 decimal no as example and check how this number convert into binary and gray code.  Now lets see how many bits are changing in case of binary number.  So, here in binary conversion total 3 bits(b0,b1,b2) are changing while in gray code only 1 bit is changed. Decimal Binary Gray b3 b2 b1 b0 g3 g2 g1 g0 3 0 0 1 1 0 0 1 0 4 0 1 0 0 0 1 1 0
  • 4.
    Decimal Binary Gray 00 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 2 0 0 1 0 0 0 1 1 3 0 0 1 1 0 0 1 0 4 0 1 0 0 0 1 1 0 5 0 1 0 1 0 1 1 1 6 0 1 1 0 0 1 0 1 7 0 1 1 1 0 1 0 0 8 1 0 0 0 1 1 0 0 9 1 0 0 1 1 1 0 1 10 1 0 1 0 1 1 1 1 11 1 0 1 1 1 1 1 0 12 1 1 0 0 1 0 1 0 13 1 1 0 1 1 0 1 1 14 1 1 1 0 1 0 0 1 15 1 1 1 1 1 0 0 0 16 1 0 0 0 0 1 1 0 0 0
  • 5.
     Now ifwe take an 7,8 decimal no as example and check how this no convert into binary and gray code.  Now lets see how many bits are changing in case of binary number.  So, here in binary conversion total 4 bits(b0,b1,b2,b3) are changing while in gray code only 1 bit is changed.  that’s why gray code is also called unit distance code or switching operation is reduced in gray code. Decimal Binary Gray b3 b2 b1 b0 g3 g2 g1 g0 7 0 1 1 1 0 1 0 0 8 1 0 0 0 1 1 0 0
  • 6.
    Step 1: Recordthe MSB as it is. Step 2: Add the MSB to the next bit, record the sum and neglect the carry. Step 3: Repeat the process Ex1: Convert 1 0 1 1 to Grey code. Solution: 1 0 1 1 1 1 1 0 MSB LSB + + + +
  • 7.
     XOR Operation Note: in Gray code conversion MSB remain same. A B XOR 0 0 0 0 1 1 1 0 1 1 1 0
  • 8.
    : Convert 11 1 0 to Grey code. Solution: 1 1 1 0 1 0 0 1 Q1. 1001 Q2. 1010 Q3. 1111 + + + + MSB LSB
  • 9.
    Step 1: Recordthe MSB as it is. Step 2: Add the MSB to the next bit of gray code, record the sum and neglect the carry. Step 3: Repeat the process Ex1: Convert 1 1 1 0 to Grey code. Solution: 1 1 1 0 1 0 1 1 MSB LSB + + + +
  • 10.
     AssignmentQuestion 1. 1100 2.1011 3. 1000 Ex1: Convert 1 0 0 1 to Grey code. Solution: 1 0 0 1 1 1 1 0 + + + +