Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

EC2004: Digital Circuits Practice Jul-Nov 2022

Experiment 5 – Code Converters & Magnitude


Comparator

AIM: To design and implement the following combinational circuits


(i) 4-bit binary to Gray code converter & Gray code to binary converter
(ii) 4-bit BCD to Excess-3 code converter & Excess-3 to BCD converter
(iii) Magnitude comparator using logic gates

THEORY:

Gray code:
Gray Code system is a binary number system in which every successive pair of numbers differs
in only one bit. The Boolean expressions for conversion of binary to Gray code for n-bits is as
follows:
Gn = B n
Gn-1 = Bn  B n-1
….
G 1 = B 2  B1

Boolean expression for conversion of Gray to binary code for n-bit is as follows:
Bn = Gn
Bn-1 = Bn  G n-1
….
B 1 = B2  G1

Excess-3 Code:
Excess-3 binary code is a self-complementary BCD code. Self-Complementary property means
that the 1’s complement of an excess-3 number is the excess-3 code of the 9’s complement of
the corresponding decimal number. This property is useful since a decimal number can be 9’s
complemented (for subtraction) as easily as a binary number can be 1’s complemented - just
by inverting all bits. The Excess-3 code can be calculated by adding 3, i.e., 0011 to each four-
digit BCD code. The process of converting Excess-3 to BCD is opposite to the process of
converting BCD to Excess-3. The BCD code can be calculated by subtracting 3, i.e., 0011 from
each four-digit Excess-3 code.

Magnitude comparator
A magnitude digital Comparator is a combinational circuit that compares two binary
numbers in order to find out whether one binary number is equal, less than, or greater than the
other binary number. The circuit shall have two inputs one for A and the other for B and have
three output terminals, one each for A > B condition, A = B condition and A < B condition.

Dept. of ECE, IIITDM Kancheepuram Page 12


EC2004: Digital Circuits Practice Jul-Nov 2022

Pre-lab activity:
1. The following circuits shall be performed in hardware
a. 4-bit Binary to Gray code converter
b. 4-bit BCD to Excess-3 code converter
c. 2-bit magnitude comparator
2. The following circuits shall be simulated through Verilog codes only
a. 4-bit Gray to Binary converter (use behavioral modelling)
b. 4-bit Excess-3 to BCD converter (use structural modelling)
c. 1-bit magnitude comparator (use dataflow modelling)
For each of the above circuits, write the truth table, simplify the relevant Boolean expressions
using K-map and draw the logic diagram.
(Only the circuits mentioned in part 1 may be written in the record note book. The circuits
mentioned in part 2 may be submitted along with the Verilog code as a separate report)

PROCEDURE:
(i) Connect the circuit as per the logic diagram.
(ii) Apply the necessary logical inputs.
(iii) Verify the outputs.

RESULT:

Dept. of ECE, IIITDM Kancheepuram Page 13

You might also like