Page 77 - Handout Digital Electronics
P. 77
9.4 Comparators
A comparator is a logic circuit used to compare two binary numbers. There are two types of
comparators:
• Comparator for equality
• Full comparator
A comparator for equality has n inputs and one output and a Full comparator has n inputs and three (3)
outputs. But both comparators can compare a maximum of two binary numbers at a time. For example,
given two n – bit magnitude binary numbers A and B a comparator for equality will indicate that either
the two binary numbers are equal in which case output F=1 or the two binary numbers are not equal in
which case F= 0. Using the same binary numbers a full comparator will indicate whether:
• A>B or
• A<B or
• A = B
9.5 Comparator for equality
A comparator for equality is the simplest since it is based on the Exclusive NOR (XNOR) logic gate.
Consider the truth table of the XNOR logic gate below:
Truth Table
A B F
0 0 1
0 1 0
1 0 0
1 1 1
Analysis of the above truth table shows that when the input variables A and B have the same input
values (equal) output F = 1 and when A and B have different values out F = 0.
Example
Compare for equality the two binary numbers below:
A = A2A1A0 = 101
B = B2B1B0 = 101
The block diagram would look as shown below:
77

