Digital Electronic4
Digital Electronic4
Digital Electronic4
DIGITAL ELECTRONIC
• 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:
3. Simulation
3.1. Equality Comparator
The equality comparator is the simplest form of a comparator circuit for determining whether
two numbers are equal.
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 1: The 2-bits equality comparator circuit with waveform of 2-bits input
2
Figure 2: The 2-bit comparator connection circuit.
3
3.2. Magnitude Comparator
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 4: The magnitude comparators which have two inputs and three output for each of three
comparison results.
We got the following relationship between output and input through the following conditions:
For A > B: G = AB ′
For A < B: L = A′ B
For A = B: E = A′ B ′ + AB
Practice
b. Use the truth table to verify the operation of the 1-bit magnitude comparator.
4
INPUT OUTPUT
A B A<B A=B A>B
0 0 0 0 0
0 1 0 1 1
1 0 1 1 0
1 1 0 0 0
5
• Results and discussion
This is useful if we want to compare two variables and want to produce an output when any
of the above three conditions are achieved.
6
Figure 7: Implementing a 2-bit magnitude comparator.
7
Practice:
f. Write the logic for each condition (A>B, A<B, A=B) from the figure above.
For A>B:
For A=B:
For A<B:
L=𝐴3 ′ 𝐵3 + (𝐴3 ⊕ 𝐵3) (𝐴2 ′ 𝐵2) + (𝐴3 ⊕ 𝐵3) (𝐴2 ⊕ 𝐵2) (𝐴1 ′ 𝐵1)
g. Build the 4-bit magnitude comparator and simulate it by Quartus Prime with inputs as in Figure
below.
8
Figure 9: The 4-bit magnitude comparator circuit.
4. Conclusion
In conclusion, comparators are electronic circuits that compare two input voltages and provide
an output based on the comparison. These circuits can be implemented using logic gates such as AND,
OR, and NOT gates