Exp 2
Exp 2
2
Design and implement Code Converters-Binary to Gray and
BCD to Excess-3
Title: Code Convertor
Problem Statement:
Design and implementation of 4-bit Code convertors.
i) Binary to Gray Code
ii) Gray to Binary Code
iii) BCD to Excess – 3 Code
iv) Excess-3 to BCD Code
IC’s Used:
IC 7404(Hex INV), 7432 (OR-gate), 7408 (AND-gate), 7486 (Ex-or gate)
Theory: There is a wide variety of binary codes used in digital systems. Some of these
codes are binary- coded -decimal (BCD), Excess-3, Gray, octal, hexadecimal, etc. Often it is
required to convert from one code to another. For example the input to a digital system
may be in natural BCD and output may be 7-segment LEDs. The digital system used may be
capable of processing the data in straight binary format. Therefore, the data has to be
converted from one type of code to another type for different purpose. The various code
converters can be designed using gates.
1) Binary Code:
It is straight binary code. The binary number system (with base 2) represents values using
two symbols, typically 0 and 1.Computers call these bits as either off (0) or on (1). The
binary code are made up of only zeros and ones, and used in computers to stand for
letters and digits. It is used to represent numbers using natural or straight binary form.
It is a weighted code since a weight is assigned to every position. Various arithmetic
operations can be performed in this form. Binary code is weighted and sequential code.
2) Gray Code:
It is a modified binary code in which a decimal number is represented in binary form in
such a way that each Gray- Code number differs from the preceding and the succeeding
number by a single bit. (E.g. for decimal number 5 the equivalent Gray code is 0111 and for
6 it is 0101. These two codes differ by only one bit position i. e. third from the left.)
Whereas by using binary code there is a possibility of change of all bits if we move from one
number to other in sequence (e.g. binary code for 7 is 0111 and for 8 it is 1000). Therefore
it is more useful to use Gray code in some applications than binary code. The Gray code is a
non-weighted code i.e. there are no specific weights assigned to the bit positions. Like
binary numbers, the Gray code can have any no. of bits. It is also known as reflected code.
Applications:
1. Important feature of Gray code is it exhibits only a single bit change from one code word
to the next in sequence. This property is important in many applications such as Shaft
encoders where error susceptibility increases with number of bit changes between
adjacent numbers in sequence.
2. It is sometimes convenient to use the Gray code to represent the digital data converted
from the analog data (Outputs of ADC).
3. Gray codes are used in angle-measuring devices in preference to straight forward binary
encoding.
4. Gray codes are widely used in K-map
The disadvantage of Gray code is that it is not good for arithmetic operation
Binary To Gray Conversion
1. Record the most significant bit as it is.
2. EX-OR this bit to the next position bit, record the resultant bit.
3. Record successive EX-ORed bits until completed.
4. Convert 0011 binary to Gray.
0 0 1 1 Binary code
+ + +
0 0 1 0 Gray code
(MSB) (LSB)
+ + +
1 1 0 1 Binary code
(MSB) (LSB)
XOR 3 7486 1
XOR 3 7486 1
Conclusion:
Hence we have studied all the operations and implementation of code convertor.