Binary Codes
25
2.3.2 Gray Code–Binary Conversion
A given Gray code number can be converted into its binary equivalent by going through the following
steps:
1. Begin with the most significant bit (MSB). The MSB of the binary number is the same as the MSB
of the Gray code number.
2. The bit next to the MSB (the second MSB) in the binary number is obtained by adding the MSB in the
binary number to the second MSB in the Gray code number and disregarding the carry, if any.
3. The third MSB in the binary number is obtained by adding the second MSB in the binary number
to the third MSB in the Gray code number. Again, carry, if any, is to be ignored.
4. The process continues until we obtain the LSB of the binary number.
The conversion process is further illustrated with the help of an example showing step-by-step
conversion of the Gray code number 1110 into its binary equivalent:
Gray code 1110
Binary
1- - -
Gray code 1110
Binary
10 - -
Gray code 1110
Binary
101
Gray code 1110
Binary
1011
2.3.3 n-ary Gray Code
The binary-reflected Gray code described above is invariably referred to as the ‘Gray code’. However,
over the years, mathematicians have discovered other types of Gray code. One such code is the n-ary
Gray code, also called the non-Boolean Gray code owing to the use of non-Boolean symbols for
encoding. The generalized representation of the code is the (n, kk-Gray code, where n is the number
of independent digits used and k is the word length. A ternary Gray code (n = 3) uses the values 0,
1 and 2, and the sequence of numbers in the two-digit word length would be (00, 01, 02, 12, 11, 10,
20, 21, 22). In the quaternary (n = 4) code, using 0, 1, 2 and 3 as independent digits and a two-digit
word length, the sequence of numbers would be (00, 01, 02, 03, 13, 12, 11, 10, 20, 21, 22, 23, 33, 32,
31, 30). It is important to note here that an (n, kk-Gray code with an odd n does not exhibit the cyclic
property of the binary Gray code, while in case of an even n it does have the cyclic property.
The (n, kk-Gray code may be constructed recursively, like the binary-reflected Gray code, or may be
constructed iteratively. The process of generating larger word-length ternary Gray codes is illustrated in
Table 2.5. The columns between those representing the ternary Gray codes give the intermediate steps.
2.3.4 Applications
1. The Gray code is used in the transmission of digital signals as it minimizes the occurrence of
errors.
2. The Gray code is preferred over the straight binary code in angle-measuring devices. Use of
the Gray code almost eliminates the possibility of an angle misread, which is likely if the
Précédent

- 47/741

Suivant