Gray Code
Gray Code
Binary Number is the default way to store numbers, but in many applications, binary numbers
are difficult to use and a variety of binary numbers is needed. This is why Gray codes are
very useful. Gray code has a 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 is used in K-maps, error correction, communication, etc.
The binary numeral system is ordered in the reflected binary code, also known as the Gray
code, so that two subsequent values only differ in one bit (binary digit). In the typical
1
sequence of binary numbers produced by the hardware that could provide an error or
ambiguity during the change from one number to the next, gray codes are highly helpful.
Binary code:-
Binary code, code used in digital computers, based on a binary number system in which there
are only two possible states, off and on, usually symbolized by 0 and 1. Whereas in a decimal
system, which employs 10 digits, each digit position represents a power of 10 (100, 1,000,
etc.), in a binary system each digit position represents a power of 2 (4, 8, 16, etc.).
A binary code signal is a series of electrical pulses that represent numbers, characters, and
operations to be performed. A device called a clock sends out regular pulses, and components
such as transistors switch on (1) or off (0) to pass or block the pulses. In binary code, each
decimal number (0–9) is represented by a set of four binary digits, or bits. The four
fundamental arithmetic operations (addition, subtraction, multiplication, and division) can all
be reduced to combinations of fundamental Boolean algebraic operations on binary numbers.
(See the table below for how the decimal numbers from 0 to 10 are represented in binary.
Gray codes are used in rotary and optical encoders, Karnaugh maps, and error detection. The
hamming distance of two neighbors Gray codes is always 1 and also
first Gray code and last Gray code also has Hamming distance is always 1, so it is also called
Cyclic codes. You can convert a Gray code to Binary number using two methods.
2
You can construct Gray codes using other methods but they may not be performed in
parallel like given above method. For example, 3 bit Gray codes can be contracted using K-
map which is given as following below.:
A B A⊕B
Decimal Gray code Binary code
0 0 000 0 000 0
1 0 001 1 001 1
2 011 010
Using 3 1 010 0 011 1
(⊕) operation – 5
Exclusive-Or 4 110 100
1 111
1 101
0
6 101 110
This is very simple 7 100 111 method to get
Binary number from Gray code. These are following steps for n-bit binary numbers −
1. The Most Significant Bit (MSB) of the binary code is always equal to the MSB of
the given gray code.
2. Other bits codes are
3
Logical circuit diagram of gray code binary code conversion
4
Conclusion :-
In conclusion we learned conversion of gray code to binary code. In this the most significant
bit of the binary code is always equal to the MSB of the given gray code. Gray codes are used
in rotory and optical encoders, k-maps, and error detections.
5
REFERENCES:-
Websites like
www.geeksforgeeks.com
www.wikipedia.com