2. 2
MAGNITUDE COMPARATOR: DIGITAL COMPARATOR
• It is a combinational logic circuit.
• Digital Comparator is used to compare the value of two binary
digits.
• There are two types of digital comparator (i) Identity Comparator
(ii) Magnitude Comparator.
• IDENTITY COMPARATOR: This comparator has only one output
terminal for when A=B, either A=B=1 (High) orA=B=0 (Low)
• MAGNITUDE COMPARATOR: This Comparator has three output
terminals namely A>B, A=B, A<B. Depending on the result of
comparison, one of these output will be high (1)
• Block Diagram of Magnitude Comparator is shown in Fig. 1
3. BLOCK DIAGRAM OF MAGNITUDE COMPARATOR
n- Bit Digital Comparator
A
n-Bit
3
B
n-Bit
A<B A=B A>B
Fig. 1
4. 4
1- Bit Magnitude Comparator:
• This magnitude comparator has two inputs A and B andthree
outputs A<B, A=B andA>B.
• This magnitude comparator compares the two numbers of single
bits.
• Truth Table of 1-Bit Comparator
INPUTS OUTPUTS
A B Y1 (A<B) Y2 (A=B) Y3 (A>B)
0 0 0 1 0
0 1 1 0 0
1 0 0 0 1
1 1 0 1 0
5. K-Maps For All Three Outputs:
0 1
0 0
B B
0 1
B
A
A 0
A 1
K-Map for Y1 :A<B
Y1 AB
5
6. K-Maps For All Three Outputs:
0 1
0 0A 1
B B
0 1
B
A
A 0
Y1 AB
K-Map forY1 :A<B
1 0
0 1A 1
B B
0 1
B
A
A 0
2Y ABAB
K-Map for Y2 :A=B
6
7. K-Maps For All Three Outputs:
0 1
0 0A 1
B B
0 1
B
A
A 0
1Y AB
K-Map forY1 :A<B
1 0
0 1A 1
B B
0 1
B
A
A 0
K-Map for Y2 :A=B
Y2 ABAB
A
B
A 0
B B
0 1
0 0
1 0A 1
Y3 AB
7
K-Map for Y2 :A>B
8. Realization of One Bit Comparator
Y1 A B
A
B AB
AB
Y2 A B AB
A B
AB
Y3 AB
A B
Y1 AB
Y2 AB AB
Y3 AB
8
9. Realization of by Using AND , EX-NORgates
AB
1Y A B
Y2 A B
A B
Y3 AB
A B
9
A
B
10. 2-Bit Comparator:
• A comparator which is used to compare two binary numbers each of two
bits is called a 2-bit magnitude comparator.
• Fig. 2 shows the block diagram of 2-Bit magnitude comparator.
• It has four inputs and three outputs.
• Inputs are A0 ,A1,B0 and B1 and Outputs are Y1, Y2 and Y3
A0
A1
B1
B0
Y1
2-Bit Comparator Y2
Y3
Output Fig. 2
A
10
B
Input
11. 11
GREATER THAN (A>B)
1. If A1= 1 and B1= 0 then A>B
2. If A1 and B1 are same, i.e A1=B1=1 or A1=B1=0 and A0=1, B0=0
thenA>B
LESS THAN (A<B)
Similarly,
1. If A1= B1=1 and A0= 0, B0=1, thenA<B
2. If A1= B1= 0 and A0= 0, B0=1 thenA<B
A1 A0 B1 B0
1 0 0 1
1 1 1 0
0 1 0 0
16. LOGIC DIAGRAM OF 2-BIT COMPARATOR:
A1 A0 B1 B0
A< B
A=B
A > B
A1 A0 B0
A1 B1
A1 B1
A1 A0 B0
A0 B1 B0
A1 B1
A0 B0
A0 B1 B0
16
17. Comparators
The function of a comparator is to compare the magnitudes of two
binary numbers to determine the relationship between them. In the
simplest form, a comparator can test for equality using XNOR gates.
How could you test two 4-bit numbers for equality?
AND the outputs of four XNOR gates.
A1
B1
A2
B2
A3
B3
A4
B4
Output
18. Comparators
IC comparators provide outputs to indicate which of the numbers is
larger or if they are equal. The bits are numbered starting at 0, rather
than 1 as in the case of adders. Cascading inputs are provided to
expand the comparator to larger numbers.
Outputs
A1
A0
A2
A3
B1
B0
B2
B3
Cascading
inputs
COMP
A = B
A < B
A > B
A = B
A < B
A > B
0
0
3
3
A
A
The IC shown is the
4-bit 74LS85.