Ex No:4 Code Convertors: CS2207-Digital Lab
Ex No:4 Code Convertors: CS2207-Digital Lab
Ex No:4 Code Convertors: CS2207-Digital Lab
Aim:
To Design and Simulate Binary to Gray ,Gray to Binary , BCD to Excess 3, Excess 3 to
BCD code converters.
Procedure:
Theory
Binary Codes
A symbolic representation of data/ information is called code. The base or radix of the
binary number is 2. Hence, it has two independent symbols. The symbols used are 0 and 1. A
binary digit is called as a bit. A binary number consists of sequence of bits, each of which is
either a 0 or 1. Each bit carries a weight based on its position relative to the binary point. The
weight of each bit position is one power of 2 greater than the weight of the position to its
immediate right. e. g. of binary number is 100011 which is equivalent to decimal number 35.
BCD Codes
Numeric codes represent numeric information i.e. only numbers as a series of 0’s and 1’s.
Numeric codes used to represent decimal digits are called Binary Coded Decimal (BCD) codes.
A BCD code is one, in which the digits of a decimal number are encoded-one at a time into
group of four binary digits. There are a large number of BCD codes in order to represent decimal
digits0, 1, 2 …9, it is necessary to use a sequence of at least four binary digits. Such a sequence
of binary digits which represents a decimal digit is called code word.
Gray Codes
19
CS2207-Digital Lab
Excess-3 code
Code Converters
The availability of a large variety of codes for the same discrete elements of information
results in the use of different codes by different digital systems. It is some time necessary to use
the output of one system as the input to the other. The conversion circuit must be inserted
between the two systems if each uses different codes for the same information. Thus a code
converter is a circuit that makes the two systems compatible even though each uses the different
code.
Truth Table:
Binary Gray
No
D C B A G3 G2 G1 G0
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 1 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
20
CS2207-Digital Lab
Equations:
Diagram:
Truth Table:
Gray Binary
No
G3 G2 G1 G0 D C B A
0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 1
2 0 0 1 1 0 0 1 0
3 0 0 1 0 0 0 1 1
4 0 1 1 0 0 1 0 0
5 0 1 1 1 0 1 0 1
6 0 1 0 1 0 1 1 0
7 0 1 1 0 0 1 1 1
8 1 1 0 0 1 0 0 0
21
CS2207-Digital Lab
9 1 1 0 1 1 0 0 1
10 1 1 1 1 1 0 1 0
11 1 1 1 0 1 0 1 1
12 1 0 1 0 1 1 0 0
13 1 0 1 1 1 1 0 1
14 1 0 0 1 1 1 1 0
15 1 0 0 0 1 1 1 1
Equations:
Diagram:
BCD to Excess-3 :
To convert from binary code A to binary code B, the input lines must supply the bit
combination of elements as specified by code A and the output lines must generate the
22
CS2207-Digital Lab
Truth table:
Decimal BCD Excess-3
Digit B3 B2 B1 B0 E3 E2 E1 E0
0 0 0 0 0 0 0 1 1
1 0 0 0 1 0 1 0 0
2 0 0 1 0 0 1 0 1
3 0 0 1 1 0 1 1 0
4 0 1 0 0 0 1 1 0
5 0 1 0 1 1 0 0 1
6 0 1 1 0 1 0 0 1
7 0 1 1 1 1 0 1 0
8 1 0 0 0 1 0 1 0
9 1 0 0 1 1 1 0 1
Equations:
z=D
y = CD+C’D’=CD(C+D)’
x = B’(C+D) +B(C+D)’
w= A+BC+BD=A+B(C+D)
Diagram:
23
CS2207-Digital Lab
Excess-3 to BCD :
The truth table relating the input and output variables is as shown.
24
CS2207-Digital Lab
Equations
Diagram:
Result:
Thus the implementation of various code convertors were designed and outputs were
noted.
25