Digital Electronics Notes
COMBINATIONAL CIRCUIT DESIGN
MAGNITUDE COMPARATOR
A magnitude comparator is a combinational circuit that compares two given numbers (A and B) and
determines whether one is equal to, less than or greater than the other. The output is in the form of three
binary variables representing the conditions A = B, A>B and A<B, if A and B are the two numbers being
compared.
Fig : - Block diagram of magnitude comparator
For comparison of two n-bit numbers, the classical method to achieve the Boolean expressions requires a
truth table of 22n entries and becomes too lengthy and cumbersome.
2-bit Magnitude Comparator:
A 2-bit comparator compares two binary numbers, each of two bits and produces their relation such as one
number is equal or greater than or less than the other.
The figure below shows the block diagram of a two-bit comparator which has four inputs and three outputs.
The truth table of 2-bit comparator is given in table below—Truth table:
Inputs Outputs
A1 A0 B1 B0 A>B A=B A<B
0 0 0 0 0 1 0
0 0 0 1 0 0 1
0 0 1 0 0 0 1
0 0 1 1 0 0 1
0 1 0 0 1 0 0
0 1 0 1 0 1 0
0 1 1 0 0 0 1
0 1 1 1 0 0 1
1 0 0 0 1 0 0
1 0 0 1 1 0 0
1 0 1 0 0 1 0
Digital Electronics Notes
1 0 1 1 0 0 1
1 1 0 0 1 0 0
1 1 0 1 1 0 0
1 1 1 0 1 0 0
1 1 1 1 0 1 0
K-map Simplification:
Digital Electronics Notes
Logic Diagram:
Fig : 2-bit Magnitude Comparator4-bit Magnitude Comparator
Let us consider the two binary numbers A and B with four digits each. Write the coefficient of the
numbers in descending order as,
A = A3A2A1A0
B = B3B2B1B0,
It compares each of these bits in one number with bits in that of other number and produces one of the
following outputs as A = B, A < B and A>B. The output logic statements of this converter are
If A3 = 1 and B3 = 0, then A is greater than B (A>B). Or
If A3 and B3 are equal, and if A2 = 1 and B2 = 0, then A > B. Or
If A3 and B3 are equal & A2 and B2 are equal, and if A1 = 1, and B1 = 0, then A>B. Or
If A3 and B3 are equal, A2 and B2 are equal and A1 and B1 are equal, and if A0 = 1 and B0 = 0, then A > B.
From the above statements, the output A > B logic expression can be written as
Digital Electronics Notes
In other words, we can write the Boolean expression for two equal 4-bit numbers.
(A = B) = [A3⊙ B3][ A2⊙ B2] [A1⊙ B1] [A0⊙ B0]
The binary variable (A=B) is equal to 1 only if all pairs of digits of the two numbers are equal.
To determine if A is greater than or less than B, we inspect the relative magnitudes of pairs of significant bits
starting from the most significant bit. If the two digits of the most significant position are equal, the next
significant pair of digits is compared. The comparison process is continued until a pair of unequal digits is
found. It may be concluded that A>B, if the corresponding digit of A is 1 and B is 0. If the corresponding
digit of A is 0 and B is 1, we conclude that A<B. Therefore, we can derive the logical expression of such
sequential comparison by the following two Boolean functions,
(A>B) = A3B3′ + [A3⊙ B3]A2B2′ + [A3⊙ B3][A2⊙ B2]A1B1′ + [A3⊙ B3][ A2⊙ B2] [A1⊙ B1]A0B0′
(A<B) = A3′B3 +[A3⊙ B3]A2′B2 +[A3⊙ B3][A2⊙ B2]A1′B1 +[A3⊙ B3][ A2⊙B2] [A1⊙ B1]A0′B0
The symbols (A>B) and (A<B) are binary output variables that are equal to 1 when A>B or A<B, respectively.
The gate implementation of the three output variables just derived is simpler than it seems because
it involves a certain amount of repetition. The unequal outputs can use the same gates that are needed to
generate the equal output. The logic diagram of the 4-bit magnitude comparator is shown below
Fig : 4-bit Magnitude Comparator
Digital Electronics Notes
The four x outputs are generated with exclusive-NOR circuits and applied to an AND gate to give the
binary output variable (A=B). The other two outputs use the x variables to generate the Boolean functions
listed above. This is a multilevel implementation and has a regular pattern.