In a previous tutorial – Arithmetic Circuits , digital circuits were designed to perform arithmetic operations. Just like arithmetic operations, comparing numbers is also an important mathematical operation. From a computing point of view, number comparison plays a vital role in decision making and logical operations. In digital systems, numbers are in the form of binary numbers. Comparing two numbers determines whether one number is greater, equal to, or less than the other number. A digital comparator is widely used in combinational systems and is specially designed to compare the relative magnitudes of binary numbers.

To compare two binary numbers, first their MSB (Most Significant Bits) are compared. If the MSB of one of these numbers is 1 while that of another is 0, then it is greater than the other and the comparison process stops. If their MSBs are the same, as if they were both 1 or 0, the next significant bit will be compared in both numbers. If the next significant bit of one of these numbers is 1, while the other is 0, then it is greater than the other and the comparison process ends there. Otherwise, it continues to least significant bits until it is determined which number is greater or both numbers are found to be equal after comparing the LSB (least significant bit) of the numbers. Therefore, if two numbers A and B are compared, the result of the comparison will be A > B, A < B or A = B.

In microcontrollers and microprocessors, digital comparators for comparing binary numbers are integrated. A digital comparator can be a 4-bit, 8-bit, 16-bit, 32-bit, or 64-bit system, depending on how it compares 4-bit, 8-bit, 16-bit, 32-bit, or 64-bit numbers, respectively. More than one comparator can also be cascaded to perform comparison of long numbers. How two 4-bit comparators can be cascaded to compare 8-bit numbers. A comparator produces three results like L, E and G which correspond to results less than, equal to and greater than.

There are also discrete ICs available for comparing binary numbers. In this project, IC SN7485 is used, which is a 4-bit magnitude comparator. The two 4-bit numbers are input into the IC through a DC source via an 8-position DIP switch. The comparison result is checked by connecting LEDs to the output pins of the IC.

**Required components** –

*Fig. 1: List of components required to make 4-bit magnitude comparator based on IC 7485*

**Circuit Diagram**–

*Fig. 2: Circuit diagram of 4-bit magnitude comparator based on IC SN-7485*

**Circuit Connections** –

For comparing 4-bit numbers, IC SN7485 is used in this project. The IC is a 4-bit magnitude comparator that can be used for comparing direct binary numbers and BCD encoded numbers. The 16-pin IC has the following pin configuration –

*Fig. 3: Table listing the pin configuration of the 7485 IC*

The IC has the following pin diagram –

*Fig. 4: Pin diagram of 7485 4-bit magnitude comparator IC*

It may be noted that the SN7485 has additional input terminals that allow more individual comparators to be “cascaded” to compare words larger than 4 bits with “n” bit magnitude comparators being produced. These cascaded inputs are connected directly to the corresponding outputs of the previous comparator to compare words of 8, 16 or even 32 bits. In this project, simply two 4-bit numbers are compared, so there is no need for cascading.

The input binary numbers are passed to the IC to respective input pins via an 8 position DIP switch. The comparison result is checked by connecting LEDs to output pins 5, 6 and 7 of the IC.

*Fig. 5: Prototype of 4-bit magnitude comparator based on IC SN7485*

**How the circuit works** –

The circuit is based on the working of IC SN7485. When the two numbers are entered through the DIP switch, where the switches are connected to the regulated 5V DC supply, the IC performs the comparison of the two 4-bit numbers and depending on the result of the comparison, one of the three output pins is set as HIGH. . The LEDs are connected to the output pins of the IC in such a way that at the HIGH output they start glowing. So, if number A is greater than number B, the LED connected to pin 5 will start glowing. If the two numbers are the same, the LED connected to pin 6 will start to glow. If number A is less than number B, the LED connected to pin 7 will start to glow.

These types of digital comparators are used in the address decoding circuits in computers and microprocessor-based devices to select a specific input/output device for data storage.

They are also used in control applications in which binary numbers representing physical variables like temperature, position, etc. are compared with a reference value. Then, the outputs of the comparator are used to drive the actuators so as to make the physical variables closer to the set or reference value. Just as digital comparators are used in applications such as process controllers and servo motor control.

**Testing the circuit** –

The output of the circuit can be tested by passing different 4-bit binary numbers to the input pins of IC 7485. On comparison of the two binary numbers, any of the three output pins will be HIGH and the respective LED will start glowing. The following observations were made when working with the IC 7485

*Fig. 6: Table listing the output of IC 7485 based 4-bit magnitude comparator*

### Circuit diagrams

Circuit Diagram-SN-7485-IC Based 4-Bit Magnitude Comparator |