13 Comparators
13 Comparators
-Magnitude Comparator-
Comparing Bits
A B O
0 0 1
0 1 0
1 0 0
1 1 1
AB + A’B’ = XNOR gate
A3
A B O B3
0 0 1 A2
B2 Output
0 1 0
A1
1 0 0 B1
1 1 1 A0
B0
Instr: Dr. Awais M. Kamboh. 3
Comparing Bits
A comparator is used to compare magnitudes of two binary numbers
How could you test if two bits are equal ?
A B O
0 0 1
0 1 0
1 0 0
1 1 1 AB + A’B’ = XNOR gate
How could you test if bit A is greater than bit B ?
A B O
0 0 0 A
0 1 0 B
1 0 1
1 1 0
How could you test if bit B is greater than bit A ?
A
B
Instr: Dr. Awais M. Kamboh. 4
Comparators
A B A > B A < B A = = B
0 0 0 0 1
0 1 0 1 0
1 0 1 0 0
1 1 0 0 1
Bit 3
Bit 2
Bit 1
Bit 0
Instr: Dr. Awais M. Kamboh. 6
Comparators Determine if binary number A is smaller than B
Check if MSB bit-3 of A is smaller , if yes then A <B
OR Check if bit-3 of A == B and if bit-2 of A < B, if yes A < B
OR Check if bits 3 and 2 of A == B and if bit-1 of A < B, if yes A < B
OR Check if bits 3, 2, and 1 of A == B and if bit-0 of A < B, if yes A < B
Bit 3
Bit 2
Bit 1
Bit 0
Instr: Dr. Awais M. Kamboh. 7
Comparator
COMP
A0 0
A1 A
A2
A3 3
Cascading A>B A>B
A=B A=B Outputs
inputs
A<B A<B
B0 0
B1 A
B2
B3 3
The IC shown is the
4-bit 74LS85.