You are on page 1of 5

EXPERIMENT No.

4
AIM: To Analyse and Implement 1 Bit, 2 Bit and 4 Bit comparator using logic gates.

APPARATUS: Digital trainer kit, its associated components.


THEORY: A magnitude digital Comparator is a combinational circuit that compares two
digital or binary numbers in order to find out whether one binary number is equal, less
than, or greater than the other binary number. We logically design a circuit for which we will
have two inputs one for A and the other for B and have three output terminals, one for A > B
condition, one for A = B condition, and one for A < B condition.

Fig 4.1: Block diagram of comparator

1-Bit Magnitude Comparator: A comparator used to compare two bits is called a single-
bit comparator. It consists of two inputs each for two single-bit numbers and three outputs to
generate less than, equal to, and greater than between two binary numbers.

Table 4.1: Truth Table of 1-Bit Comparator

From the above truth table logical expressions for each output can be expressed as follows:
A > B: AB'
A < B: A'B
A = B: A'B' + AB

By using these Boolean expressions, we can implement a logic circuit for this comparator as
given below:
Fig 4.2: Logic Circuit of 1-Bit Comparator

2-Bit Magnitude Comparator: A comparator used to compare two binary numbers each of
two bits is called a 2-bit magnitude comparator. It consists of four inputs and three outputs to
generate less than, equal to and greater than between two binary numbers.

Table 4.2: Truth Table of 2-Bit Comparator

From the above truth table logical expressions for each output can be expressed as follows:
A > B : A1B1’ + A0B1’B0’ + A1A0B0’
A = B : A1’A0’B1’B0’ + A1’A0B1’B0 + A1A0B1B0 + A1A0’B1B0’
: A1’B1’ (A0’B0’ + A0B0) + A1B1 (A0B0 + A0’B0’)
: (A0B0 + A0’B0’) (A1B1 + A1’B1’)
: (A0 Ex-Nor B0) (A1 Ex-Nor B1)
A < B : A1’B1 + A0’B1B0 + A1’A0’B0
By using these Boolean expressions, we can implement a logic circuit for this comparator as
given below:

Fig 4.3: Logic Circuit of 2-Bit Comparator

4-Bit Magnitude Comparator: A comparator used to compare two binary numbers each of
four bits is called a 4-bit magnitude comparator. It consists of eight inputs each for two four-
bit numbers and three outputs to generate less than, equal to, and greater than between two
binary numbers.

Table 4.3: Truth Table of 4-Bit Comparator


If the corresponding digit of A is equal to 1 and that of B is equal to 0, we conclude that A>B.
The sequential comparison can be expressed logically by the Boolean function:

(A > B) = A3 B’3 + x3A2 B’2 + x3x2A1B’1 + x3x2x1A0B’0

If the corresponding digit of A is equal to 0 and that Of B is equal to 1, we have A<B. The
sequential comparison can be expressed logically by the Boolean function:

(A < B) = A’3 B3 + x3A’2 B2 + x3x2A’1B1 + x3x2x1A’0B0

When the numbers are binary, then the digits are either equal to 1 or 0, and the equality of each
pair of bits can be stated logically with an XNOR function as:

XOR-Invert = (AiB’i + A’iBi)’

(A’i + Bi) (Ai + B’i)

A’iAi + A’iB’i AiBi + BiB’i

xi = AiBi + A’iB’I for i = 0,1,2,3

Where xi = 1 only if the pair of bits in position i are same (i.e., if both are 1 or both are 0).

The equality of the two numbers A and B is showed in a combinational circuit by an output
binary variable that we term by the symbol (A = B). This binary variable is equal to 1 if the
given input numbers, A and B, are same, otherwise is equal to 0. For equality to be present, all
xi variables must be equal to 1, a condition that dictates an AND Operation of all variables

(A = B) = x3 x2 x1 x0

The binary variable (A = B) is equal to 1 only if all pairs of significant digits of the given two
numbers are same.

By using these Boolean expressions, we can implement a logic circuit for this comparator as
given below:
Fig 4.4: Logic Circuit of 4-Bit Comparator

PROCEDURE:

1. Take the IC’s numbered 7404, 7408, 7432, 7486, 7400, 7402.

2. Place them properly on their respective places.

3. Make the connections as per the circuit diagram.

4. The circuit can be verified using various values of inputs and then testing the values
of output as per truth table.

PRECAUTIONS:

1. Circuit should be properly connected.


2. Do not short circuit in the trainer kit during operation.
3. Wires should be held by their heads while being removed else they may get damage.

You might also like