How to Perform BCD to Gray Code Conversion?

Introduction to BCD Numbers

How to Perform BCD to Gray Code Conversion? BCD stands for binary coded decimals which means we have assigned binary codes to the decimal numbers. The range of BCD numbers is from 0 to 9. That’s why we need at least 4-bits for representing a single BCD number. While using the 4-bits, rest of the bit combinations are considered as dont care.

Table of BCD Numbers

Decimal Value

BCD Code

0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

BCD numbers have great significance in practical life. They are easily coded and decoded. They are widely used in digital displays like counters, digital watches, temperature display etc. Real-time clocks, or RTC chips, are still used to maintain track of wall-clock time, and embedded microprocessors are increasingly coming equipped with an RTC. The drawback of BCD numbers is that it does not use the bit combinations from 1010 to 1111 which actually wastes the memory.

What is the Gray Code?

Gray code has the property to cycle through all2n possible combinations of n-bits with the change of only one bit at a time. Hence for any two consecutive numbers only one bit position will be changed at a time. There are many types of gray code but I will discuss here only reflected binary gray code. Let’s generate the reflected binary code for n=2. 

for n=2

write the strings 0 and 1 for representing the integer 0 and 1

0

1

now reflect this string horizontally, you will get

0

1

1

0

Now place 1 before the reflected string and 0 before the previous string as shown

below

00

01

11

10

so this is the Gray code for n=2.

Similarly you can generate the gray code for n=3 or any higher number of bits.

Reflected Binary Code for n=3 bit

Write down the gray code for n=2 bits, then reflect it horizontally and finally place 1 before the reflected combination and 0 before the previous combinations. 

000
001
011
010
110
111
101
100

Application of Gray Code

  1. This is used in the transmission of digital signals as it reduces the occurrence of errors.
  2. Gray code is used for marking axis in Karnaugh map which is used for simplifying the Boolean functions.
  3. Gray code is also used for addressing program memory in computer systems which actually minimizes the power consumption.
  4. Gray code is preferred to be used for angle measuring devices than straight line binary codes because of its précised results.

Truth Table for Conversion from BCD to Gray Code

The following table shows how BCD numbers are converted into gray code. We will be using 4-bits which will result in binary combinations from 0000 to 1111. Since 1010 to 1111 does not make any sense in BCD that is why we will treat them as don’t care conditions.

Decimal Value BCD Code

ABCD

Gary Code

G3G2G1G0

0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101

you can convert any bit combination to the gray code using the following method.

  1. Write the first bit (MSB) as it is.
  2. Then compare this bit with its consecutive bit. If both are same put 0, otherwise put 1.
  3. Read the next consecutive bits and do the step 2 again until you are done with all bits.

Example:

  1. For example if you want to convert 1011 BCD to gray code. Then write first MSB as it is (which is 1 in this case) (gray code=1)
  2. Now the next bit is 0 (1011) so bit is actually changing from 1 to 0 (1011) that’s why put 1 (gray code=11).
  3. Now compare it with next bit since both are different bits (1011), put 1 again (gray code=111).
  4. Now in last step you will compare bits (1011)since both are same so put 0 (gray code=1110).

Karnaugh Map for BCD to Gray Code Conversion

K-Map for G3
K-Map for G3

G3=A

k-map for G2
k-map for G2

G2=A+B

k map for G1
k map for G1
minimized function expression
minimized function expression

G1=B’C+BC’

K map for G0
K map for G0

G0=C’D+CD’

The BCD to Gray Code Converter Circuit is implemented as followed. It must be noted that here each bit of gray code has been shown implemented individually.

BCD to Gray Code Converter Circuit
BCD to Gray Code Converter Circuit

How to Perform BCD to Gray Code Conversion?

Here is the video lecture for performing BCD to Gray code conversion

Also see

Leave a Reply

Your email address will not be published. Required fields are marked *