Code Converters Experiment
Code Converters Experiment
AIM :
To design and implement a digital combinational circuit that converts the given code
in
Components Required :
1.
2.
3.
4.
5.
6.
1
-
1
1
1
1
Required quantity
Theory :
While the binary system of representation is the most extensively used one in digital
systems, including computers, octal and hexadecimal number systems are commonly used for
representing groups of binary digits. The binary coding system, called the straight binary
code becomes very cumbersome to handle when used to represent larger decimal numbers. To
overcome this shortcoming, and also to perform many other special functions, several binary
codes have evolved over the years. Some of the better-known binary codes, including those
used efficiently to represent numeric and alphanumeric data, and the codes used to perform
special functions, such as detection and correction of errors. Coding was defined as the use of
groups of bits to represent items of information that are multivalued. Assigning each item of
information a unique combination of bits makes a transformation of the original information.
This we recognize as information being processed into another form. Moreover, we have seen
that there are many coding schemes exist. Different digital systems may use different coding
schemes. It is sometimes necessary to use the output of one system as the input to other.
Therefor a sort of code conversion is necessary between the two systems to make them
compatible for the same information. A code converter is a combinational logic circuit that
changes data presented in one type of binary code to another type of binary code. A general
block diagram of a code converter is shown in Fig.
Gray Code
The Gray code was designed by Frank Gray at Bell Labs and patented in 1953. It is an
unweighted binary code in which two successive values differ only by 1 bit. Owing to this
feature, the maximum error that can creep into a system using the binary Gray code to encode
data is much less than the worst-case error encountered in the case of straight binary
encoding. An examination of the four-bit Gray code numbers shows that the last entry rolls
over to the first entry. That is, the last and the first entry also differ by only 1 bit. This is
known as the cyclic property of the Gray code.
determined by adding 3 to each decimal digit in the given number and then replacing each
digit of the newly found decimal number by its four-bit binary equivalent. It may be
mentioned here that, if the addition of 3 to a digit produces a carry, as is the case with the
digits 7, 8 and 9, that carry should not be taken forward. The result of addition should be
taken as a single entity and subsequently replaced with its excess-3 code equivalent. Another
significant feature that makes this code attractive for performing arithmetic operations is that
the complement of the excess-3 code of a given decimal number yields the excess-3 code for
9s complement of the decimal number. As adding 9s complement of a decimal number B to
a decimal number A achieves A B, the excess-3 code can be used effectively for both
addition and subtraction of decimal numbers.
4-bit Binary to Gray code conversion
1. The block diagram of a 4-bit binary to gray code converter is shown in Fig.
If has four inputs (B3B2B1B0) representing 4-bit binary numbers and four outputs (G3G2G1G0)
representing 4-bit gray code.
Truth table for binary to gray code converters
solving all the gray outputs distantly with respect to binary inputs From the truth table; the
logic expressions for the gray code outputs can be written as
G3 = (8, 9, 10, 11, 12, 13, 14, 15)
B3
B3 B2
B2 B1
B1 B0.
Now the above expressions can be implemented using X-OR gates to yield the desired code
converter circuit shown in Fig.
If has four inputs (G3G2G1G0) representing 4-bit Gray code and four outputs (B3B2 B1B0)
representing 4-bit Binary number.
TRUTH TABLE:
GRAY INPUT
G3
G2
G1
0
0
0
0
0
0
0
0
1
0
0
1
0
1
0
0
1
0
0
1
1
0
1
1
1
0
0
1
0
0
1
0
1
1
0
1
1
1
0
1
1
0
1
1
1
1
1
1
G0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
B3
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
BINARY OUTPUT
B2
B1
0
0
0
0
0
1
0
1
1
1
1
1
1
0
1
0
1
1
1
1
1
0
1
0
0
0
0
0
0
1
0
1
B0
0
1
1
0
1
0
0
1
1
0
0
1
0
1
1
0
Now we solve all the Binary outputs. From the truth table, the logic expressions for the
Binary coded outputs can be written as :
B3 =
B2 =
B1 =
B0 =
Map for B3
B3 = G3
Map for B2
Map for B1
Map for B0
B3 =
B2 =
B1 =
B0 =
G3
G3 G2
G3 G2G1
G3 G2 G1 G0.
Now the above expressions can be implemented using X-OR gates to yield the desired code
converter circuit shown in Fig.
XS-3 codes are obtained from BCD code by adding 3 to each coded number. Moreover 4
binary variables may have 16 combinations, but only 10 are listed. The six not listed are dont
care-combinations. Since they will never occur, we are at liberty to assign to the output
variable either a 1 or a 0, whichever gives a simpler circuit. In this particular example, the
unused i/o combinations are listed below the truth table.
Truth Table for XS-3 to BCD code converter
Now we solve all the BCD outputs. From the truth table, the logic expressions for the BCD
coded outputs can be written as :
B3 =
B2 =
B1 =
B0 =
B3 = E3 E2 + E3E1E0
Map for B2
Map for B1
B1 = E1' E0 + E1 E0'
= E1 E0
Map for B0
B0 = E0'
B3 =
B2 =
B1 =
B0 =
E3 E2 + E3 E1 E0
E2' E0' + E2 E1 E0 + E2'E1'
E1 E0
E0'
The expressions for BCD outputs (B3 B2 B1 B0) can be implemented for terms of inputs
(E3 E2 E1 E0) to form a XS-3 to BCD code converter circuit as below
E3
E2
E1
E0
6
5
E1 E0
4
2
3
2
B2 = E2' E0' + E2 E1 E0 +
E2'E1'
3
B1
B0 = E50'
B3 = E3 E2 + E3
2
2
E0
6
E1
The truth table, lists the values of the output (that is the excess-3 code) for all possible
combinations of the binary code. Note that, these codes are codes for decimal digits 0-9. In
other words, even though the 4 bits of the input can represent up to 16 different combinations,
ONLY 10 combinations are used to represent the 10 decimal digits. Thus, a total of 6 input
combinations are not likely to occur. Since these inputs will never occur, we use dont cares
for the corresponding output codes.
Excess 3 Output
Decimal
B3
B2
B
1
B0
E3
E2
E1
E0
10-15
As the procedure for simplification of a Boolean function suggests, we will minimize the four
output functions using K-maps. Thus we will be having four K-maps, one for each output
function. Each of these K-maps are given below
K-Map for E3
K-Map for E2
K-Map for E1
K-Map for E0
E3=B3+B2(B0+B1)
E2=B2B1+B2B0+B2B1B0
= B2(B1+B0)+B2B1B0
E2=B2(B1+B0)
The expressions for Excess-3 outputs (E3E2E1E0) can be implemented for terms of inputs
(B3B2B1B0) to form a BCD to XS-3 code converter circuit as below