DIGITAL LOGIC AND Comparators
DESIGN
COMPARATORS
The basic function of a comparator is to compare the magnitudes of
two binary quantities to determine the relationship of those
quantities
There are two types of comparators
1. Equality
2. Inequality
EQUALITY
As we already know the exclusive-NOR gate can be used as a basic
comparator
because its output is a 0 if the two input bits are not equal and a 1
if the input bits are equal
MORE THAN 1 BIT EQUALITY
In order to compare binary numbers containing two bits each, an
additional exclusive-NOR gate is necessary
The two least significant bits (LSBs) of the two numbers are
compared by gate G1 , and the two most significant bits (MSBs) are
compared by gate G2
If the two numbers are equal, their corresponding bits are the
same, and the output of each exclusive-NOR gate is a 1
If the corresponding sets of bits are not equal, a 0 occurs on that
exclusive-NOR gate output a 0 occurs on that exclusive-NOR gate
output
DIAGRAM
EXAMPLE
INEQUALITY
In addition to the equality output, fixed-function comparators can
provide additional outputs that indicate which of the two binary
numbers being compared is the larger
That is, there is an output that indicates when number A is greater
than number B (A > B) and an output that indicates when number
A is less than number B (A < B)
LOGIC SYMBOL FOR A 4-BIT
COMPARATOR WITH
INEQUALITY INDICATION
INEQUALITY CONDITIONS
We can determine an inequality of binary numbers A and B by
examine the highest order bit in each number
The following conditions are possible:
1. If A3 = 1 and B3 = 0, number A is greater than number B.
2. If A3 = 0 and B3 = 1, number A is less than number B.
3. If A3 = B3 , then next lower bit position for an inequality must
be examined
HOW IT WORKS
The three operations are valid for each bit position in the numbers
The general procedure used in a comparator is to check for an
inequality in a bit position, starting with the highest-order bits
(MSBs)
When such an inequality is found, the relationship of the two
numbers is established, and any other inequalities in lower-order
bit positions must be ignored because it is possible for an opposite
indication to occur; the highest-order indication must take
precedence
EXAMPLE
Determine the A = B, A 7 B, and A 6 B outputs for the input
numbers shown on the comparator
COMPARATOR CIRCUIT
SOLUTION
The number on the A inputs is 0110 and the number on the B
inputs is 0011
The A > B output is HIGH and the other outputs are LOW
Q&A