Professional Documents
Culture Documents
Lab 4 Digital Electronic
Lab 4 Digital Electronic
1. Introduction
Digital comparators circuit is combinational logic circuits that could be used to verify whether
the values of 2 input (1-bit or multiple-bit) is greater than, less than, or equal to each other or not.
Equality comparator and Magnitude comparator are the two basic types of comparator which
commonly used.
• Comparators are used in central processing units (CPUs) and microcontrollers (MCUs).
• They are also used in control applications in which the binary number representing
physical variables such as temperature, position, etc. are compared with a reference
value.
• Comparators are also used as process controllers and for servo motor control.
• Used in password verification and biometric application.
2. Objective
The objective of this laboratory is to provide the student with a basic understanding of the
functionality of comparator circuit by the following task:
• To build several types of comparator circuits such as one-bit, two bits, or 4 bits circuits.
3. Simulation
The equality comparator is the simplest form of a comparator circuit for determining whether
two numbers are equal.
1
Practice
a. Verify with a 2-bit Equality comparator circuit by implementing and simulating on Quartus
Prime software for input as in Figure 2 below.
Figure 2:The 2-bits equality comparator circuit with waveform of 2-bits input
The magnitude comparator is a combinational circuit that compares two digital or binary
numbers to find out whether one binary number is equal, less than, or greater than the other binary
number. We logically design a circuit for which we will have two inputs, one for A and the other
for B, and have three output terminals, one for A>B condition, one for A=B condition, and one for
A<B condition.
Figure 3:The magnitude comparators which have two inputs and three output for each of three comparison results.
2
We got the following relationship between output and input through the following conditions:
Practice
a. Use the truth table to verify the operation of the 1-bit magnitude comparator.
b. Implement and simulate a 1-bit magnitude comparator in the Quartus Prime.
It is used to compare two binary numbers with each of the two bits. The input data are represented
by A1A0 and B1B0 and three outputs are represented as G (for A greater than B), L (for A less
than B), E (for A equal to B).
3
Practice
a. Use the truth table to verify the operation of the 2-bit magnitude comparator.
b. Implement and simulate a 2-bit magnitude comparator in the Quartus Prime.
The following figure shows the 4-bit magnitude comparator with cascading input. This circuit can
be cascaded together for building a comparator with more than 4-bit data.
Practice:
a. Write the logic for each condition (A>B, A<B, A=B) from the figure above.
b. Build the 4-bit magnitude comparator and simulate it by Quartus Prime with inputs as in
Figure below.