7.
5 Digital comparators
The basic function of a comparator is to compare the magnitudes of two binary quantities to determine the
relationship of those quantities. Figure 7.12 illustrates n-bit comparator block diagram.
A1
n-bit A A2
… A<B
_GE_C06.indd Page 330 12/11/14 8:13 PM user /204/PH01677_PIV/9781292075983_FLOYD/FLOYD_DIGITAL_FUNDAMENTALS11_PIE
An
n-bit
A=B
B1 comparator
B2 A>B
n-bit B
…
Bn
unctions of Combinational Logic
Figure 7.12: n-bit comparator block diagram
7.5.1 2-bit comparator design
EMENTATION: 4-BIT MAGNITUDE COMPARATOR
(Done in class)
Fixed-Function Device The 74HC85/74LS85 pin diagram and logic symbol are
7.5.2shown4-bit in comparator
Figure 6–23. using
Notice2-bit
that this device has all the inputs and outputs of the
comparators
generalized
(Done in class) comparator previously discussed and, in addition, has three cascading
inputs: A 6 B, A = B, A . B. These inputs allow several comparators to be cascaded
7.5.3for Fixed-function
comparison of any ICsnumber of bits
of digital greater than four. To expand the comparator,
comparators
the A 6 B, A = B, and A 7 B outputs of the lower-order comparator are connected
Digital comparators can be implemented using fixed-function integrated circuits (ICs) for various applications,
to 7485
such as: the corresponding cascading
(4-bit comparator), inputs
74688 (8-bit of the next
comparator), etc. higher-order comparator.
The 7485 pin diagram The
and logic low-are
symbol
shownest-order
in Figure comparator mustthis
7.13. Notice that have a HIGH
device has allon
thethe A =and
inputs B input
outputsand LOWs
of the A 6 B
on the comparator
generalized
and A
previously 7 B inputs.
discussed. The function table of the 7485 4-bit magnitude comparator is given in Figure 7.14.
B3 1 (10) COMP
16 VCC 0
(12)
A < Bin 2 15 A3
(13) A
A = Bin 3 14 B2 (15)
3
A > Bin 4 13 A2 (4) (5)
A>B A>B
Cascading (3) (6)
A > Bout 5 12 A1 A=B A=B Outputs
inputs (2) (7)
A = Bout 6 11 B1
A<B A<B
(9)
0
A < Bout 7 10 A0 (11)
(14) B
GND 8 9 B0
(1)
3 VCC (16), GND(8)
(a) Pin diagram (b) Logic symbol
FIGURE 6–23 The 74HC85/74LS85 4-bit magnitude comparator.
Figure 7.13: The 7485 4-bit magnitude comparator
Programmable Logic Device (PLD) A 4-bit magnitude comparator can be described
using VHDL and implemented in a PLD. The following VHDL program uses the data flow
approach to implement a simplified comparator
58 (A = B output only) in Figure 6–24. (The
blue comments are not part of the program.)
entity 4BitComparator is
Comparing Cascading Outputs
Inputs Inputs
A3, B3 A2, B2 A1, B1 A0, B0 A>B A<B A=B A>B A<B A=B
A3 > B3 X X X X X X H L L
A3 < B3 X X X X X X L H L
A3 = B3 A2 > B2 X X X X X H L L
A3 = B3 A2 < B2 X X X X X L H L
A3 = B3 A2 = B2 A1 > B1 X X X X H L L
A3 = B3 A2 = B2 A1 < B1 X X X X L H L
A3 = B3 A2 = B2 A1 = B1 A0 > B0 X X X H L L
A3 = B3 A2 = B2 A1 = B1 A0 < B0 X X X L H L
A3 = B3 A2 = B2 A1 = B1 A0 = B0 H L L H L L
A3 = B3 A2 = B2 A1 = B1 A0 = B0 L H L L H L
A3 = B3 A2 = B2 A1 = B1 A0 = B0 L L H L L H
A3 = B3 A2 = B2 A1 = B1 A0 = B0 X X H L L H
A3 = B3 A2 = B2 A1 = B1 A0 = B0 H H L L L L
A3 = B3 A2 = B2 A1 = B1 A0 = B0 L L L H H L
H = HIGH Level, L = LOW Level, X = Don’t Care
Figure 7.14: The 7485 4-bit comparator function table
In addition, the 7485 IC is provided with three cascading inputs: (𝐴 > 𝐵), (𝐴 = 𝐵), (𝐴 < 𝐵). These
inputs allow several comparators to be cascaded for comparison of any number of bits greater than four.
To expand the comparator, the (𝐴 > 𝐵), 𝐴 < 𝐵), and (𝐴 = 𝐵) outputs of the lower-order comparator are
connected to the corresponding cascading inputs of the next higher-order comparator. The lowest-order
comparator must have a HIGH on the (𝐴 = 𝐵) input and LOWs on the (𝐴 > 𝐵) and (𝐴 > 𝐵) inputs. Figure
7.15 shows how two 7485 ICs are cascaded to form an 8-bit magnitude comparator.
LSBs MSBs
COMP COMP
A0 0 A4 0
A1 A5
A A
A2 A6
A3 3 A7 3
A>B A>B A>B A>B
+5 V A=B A=B A=B A=B Outputs
A<B A<B A<B A<B
B0 0 B4 0
B1 B5
B B
B2 B6
B3 3 B7 3
7485 7485
Figure 7.15: An 8-bit magnitude comparator using two 7485 ICs
59