In this article, we are going to learn about the magnitude comparator or Digital Comparator. We will also cover the 1-bit comparator, 2-bit comparator, and 4-bit comparator with their detailed analysis. So let’s start from the basic knowledge of the what id magnitude comparator.

**Magnitude Comparator**

Magnitude comparator or Digital comparator is a combinational circuit, designed to compare the two n-bit binary words applied at its input.

Or

A magnitude Comparator is a combinational circuit that **compares two digital or binary numbers** to find out whether one binary number is equal, less than, or greater than the other binary number.

The comparator has two inputs terminal where the input bits are applied for comparison and has three outputs namely one for the A > B condition, one for the A = B condition, and One for the A < B condition.

The block diagram of an n-bir Magnitude comparator or digital Comparator is shown in the figure below.

Also Read:Comparison of Logic Families

**1-Bit Comparator**

- The 1-bit magnitude comparator is a combinational logic circuit with two inputs A and B and three outputs namely A<B, A=B, and A>B.

- It compares the two single-bit numbers A and B and produces an output that indicates the result of the comparison.

**1-bit Magnitude Comparator Truth Table**

The truth table for the 1-bit magnitude comparator is shown below:

Inputs | Outputs | |||
---|---|---|---|---|

A | B | Y1 = A < B | Y2 = A = B | Y3= A > B |

0 | 0 | 0 | 1 | 0 |

0 | 1 | 1 | 0 | 0 |

1 | 0 | 0 | 0 | 1 |

1 | 1 | 0 | 1 | 0 |

**K-Map for 1-bit Magnitude Comparator**

- The K-map for the three outputs Y1, Y2, and Y3 are shown in the below Figure:

- From the above figure, we can write the expression for all three outputs as,

`\mathbf{Y_1= (A <B) = \bar A B}`

`\mathbf{Y_2= (A=B) = \bar A \bar B + AB = \overline {A \oplus B}}`

`\mathbf{Y_3= (A>B) = A \bar B}`

- The Expression for Y2 is nothing but the expression for XNOR Gate. Hence the signal bit magnitude comparator can be realized using the figure below:

**Logic Diagram of 1-bit Comparator**

Also Read:Half Adder in Digital Electronics

**2 Bit Comparator**

- For 2 bit comparator, each input word is 2-bit long.

**2 Bit Comparator Truth Table**

- The truth table of the 2-bit comparator is shown in the below table.

Inputs | Outputs | |||||
---|---|---|---|---|---|---|

A1 | A0 | B1 | B0 | A < B | A = B | A > B |

0 | 0 | 0 | 0 | 0 | 1 | 0 |

0 | 0 | 0 | 1 | 1 | 0 | 0 |

0 | 0 | 1 | 0 | 1 | 0 | 0 |

0 | 0 | 1 | 1 | 1 | 0 | 0 |

0 | 1 | 0 | 0 | 0 | 0 | 1 |

0 | 1 | 0 | 1 | 0 | 1 | 0 |

0 | 1 | 1 | 0 | 1 | 0 | 0 |

0 | 1 | 1 | 1 | 1 | 0 | 0 |

1 | 0 | 0 | 0 | 0 | 0 | 1 |

1 | 0 | 0 | 1 | 0 | 0 | 1 |

1 | 0 | 1 | 0 | 0 | 1 | 0 |

1 | 0 | 1 | 1 | 1 | 0 | 0 |

1 | 1 | 0 | 0 | 0 | 0 | 1 |

1 | 1 | 0 | 1 | 0 | 0 | 1 |

1 | 1 | 1 | 0 | 0 | 0 | 1 |

1 | 1 | 1 | 1 | 0 | 1 | 0 |

**K-Map For 2-bit Comparator**

- The K-maps for all three outputs and corresponding simplified expressions are as per below.

For A < B:\bar A_1 \bar A_0 B_0 + \bar A_1 B_1 + \bar A_0 B_1 B_0

For A > B:A_0 \bar B_1 \bar B_0 + A_1A_0\bar B_0 +A_1 + \bar B_1

**Simplification for output A = B:**

- The expression for A = B is given by,

`( A = B) = \bar A_1 \bar A_0 \bar B_1 \bar B_0 + \bar A_1 A_0 \bar B_1 B_0 + A_1A_0B_1B_0+A_1\bar A_0 B_1 \bar B_0`

` = \bar A_0 \bar B_0 (\bar A_1 \bar B_1 + A_1 B_1)+ A_0B_0(\bar A_1 \bar B_1 + A_1B_1)`

`= (\bar A_1 \bar B_1 + A_1B_1)(\bar A_0 \bar B_0+ A_0B_0)`

`= (A_1 \odot B_1) (A_0 \odot B_0)`

**2 Bit Comparator Logic Diagram**

- The logic diagram for the 2-bit comparator is shown in the figure below.

Also Read:what is hazard in digital electronics | Types of hazards in digital electronics

**4-Bit Magnitude Comparator**

- IC 7485 is a 4-bit comparator in integrated circuit (IC) form. It compares two 4-bit words A (A
_{3}– A_{0}) and B (B_{3}– B_{0}).

- It is possible to cascade more than one IC 7485 to compare words of almost any length.

**Pin Configuration and Logic Symbol of IC 7485 **

**Pin Description and Function of IC 7485**

Pin Name | Pin Number | Functions |
---|---|---|

A_{0} to A_{3}B _{0} to B_{3} | 10, 12, 13, 15 9, 11, 14, 1 | Binary input (Operand 1) Active High Binary input (Operand 2) Active High |

I (A < B) I (A = B) I (A > B) | 2 3 4 | These are the outputs. When IC 7485 is cascaded, these outputs are applied to cascading inputs of the next stage. |

A < B A = B A > B | 7 6 5 | These are the outputs. When IC 7485 are cascaded, these outputs are applied to cascading inputs of the next stage. |

**4-bit Comparator Truth Table**

**Functional Table of IC 7485 (4-Bit Comparator)**

- The below table shows the functional table of IC 7485.

- The function table shown tells us that if I (A < B) or I (A > B) is equal to 1 and if the other two cascading inputs are at logic 0 then the corresponding output ( A < B or A > B) will be active.

- But if A = B, then the corresponding output will be active if and only if I ( A = B) is at logic 1 irrespective of the other two inputs.

**Cascading of IC 7485**

- IC 7485 is a 4-bit magnitude comparator. If we want to increase the size of the words beyond 4-bit then the casting is required to be done.

- An 8-bit comparator using IC 7485 is shown in the figure below.

- The outputs of Ic 7485-1 are applied to the cascading inputs of IC 7485-2.

- The two 8-bit words to be compared are A (A
_{7}– A_{0}) and B ( B_{7}– B_{0}). These are divided into two 4-bit words each and then applied to the two comparator ICs.

**Operation of Ic 7485:**

- The MSB bits A
_{7}and B_{7}are compared first. If A_{7}= B_{7}then the next bits A_{6}and B_{6}are compared. This will continue up to A_{0}and B_{0}.

- If A
_{7}A_{6}A_{5}A_{4}= B_{7}B_{6}B_{5}B_{4}then IC 7485 (2) will check the cascading inputs.

- IC 7485 (1) will continue the comparison from A
_{3}– B_{3}to A_{0}– B_{0}as explained earlier. If A_{3}A_{2}A_{1}A_{0}= B_{3}B_{2}B_{1}B_{0}then IC 7485 (1) will check cascading inputs.

Important Note:Since Ic 7485 (1) itself is the LCB chip, we have to adjust the status of its cascade inputs so that they indicate A = b. Hence I (A = B) should be connected to +5V i.e. logic 1.

**Applications of comparator**

When comparing data is necessary for numerous actions, digital comparator, and magnitude comparator are utilized, and they have a number of advantages.

Look at a few comparison tool applications now.

- used for biometric applications and authorization purposes (like password management).
- These are used in servo motor controls as well as process controllers.
- The pressure is compared to reference levels when it is used to compare data for variables like temperature.
- used to refer to computer decoding circuitry.

Thus, the digital comparator and magnitude comparator are the main concepts here. As a result, the improved performance of comparators enabled the use of these devices in numerous applications and increased their significance in the electronics sector.

**FAQs on Magnitude Comparator**

**What is a magnitude comparator?**

A digital comparator or magnitude comparator is a hardware electronic device that takes two numbers as input in binary form and determines whether one number is greater than, less than, or equal to the other number

**What is 4 magnitude comparator?**

A 4-bit magnitude comparator compares two 4-bit numbers A and B and gives one of the following outputs: A = B, A < B, and A > B.

**What is subtractor and magnitude comparator?**

A subtractor negates the second input and adds it to the first. A magnitude comparator subtracts one number from another and determines the relative value based on the sign of the result.

**What is the importance of a magnitude comparator?**

Magnitude comparators are mostly utilized in microcontrollers and CPUs to address data comparison, register and perform all other arithmetic operations.

Must Buy Book:Best Books For Digital Electronics