Practical-4
Computer Architecture Lab
PRACTICAL 4
AIM :
To implement magnitude comparator Circuit.
Theory :
A magnitude comparator is a combinational circuit that compare two numbers and
determines their relative magnitudes.
For A and B, the outcome of the comparison is specified by three 'binary variables that
indicate weather A>B. A=B, or A<B.
Consider two numbers, A and B, with four digits each.
A= A3 A2 A1 Ao
B = B3 B2 B1 Bo
Where each subscripted letter represents one of the digits in the number. The two numbers
are equal if all pairs of significant digits are equal i.e. if A3 = B3 , A2 = B2, A, = B1, Ao =
Bo. when the numbers are binary, digits are either 1 or 0 and the equality relation of each
pair of bits can be expressed logically with an equivalence function:
Xi = Ai Bi + Ai' Bi' where I=0,1,2,3n,
Where Xi =1 only if the pair of bits in position i are equal. Le. both are 1's or both are 0's.
The equality of the two numbers, A and B is displayed in a combinational circuit by an out
put binary ,variable which we designate by the symbol ( A = B). this binary variable is equal
to 1 if the input numbers, A and B are equal and it is equal to 0 otherwise. For the equality
condition to exist, all Xi variables must be equal to 1. this dictates an AND operation of all
variables. (A=B) = X3 X2 X1 Xo
the binary variable are equal 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 magnitude of pairs of
significant digits starting from the most significant position. If the two digits are equal, we
compare the next lower significant pair of digits. This comparison continues until a pair of
unequal digits is reached. If the corresponding digits of A is 1 and that of B is 0, we conclude
that A>B. if the corresponding digit of A is 0 and that of B is 1. we have that A<B. the
sequential comparison can be expressed logically by the following two Boolean function.
(A>B) = A3 B3 + X3 A2 B2 + X3 X2 A1 B1 + X3 X2 X1 A0 B0
(A<B) = A3 B3 + X3 A2 B2 + X3 X2 A1 B1 + X3 X2 X1 A0 B0
the symbols (A>B) and (A<B) are binary output variables which are equal to 1 when A>B
and A<B respectively.
NIRAV PATEL (13012011036)
Page 10
Practical-4
Computer Architecture Lab
Circuit Diagram :
[ 4 Bit Magnitude Comparator ]
Procedure :
NIRAV PATEL (13012011036)
Page 11