In this article you will learn about magnitude comparator. 1 Bit & 2 Bit comparators with truth table and circuit diagram.

## Magnitude Comparator

A combinational circuit that compares two digital or binary numbers and compare them in the form of A < B, A = B & A > B is known as magnitude comparator. A Magnitude comparator is also known as digital comparator.

## 1 Bit Magnitude Comparator

A magnitude comparator that compares two bits is known as 1 bit comparator. It consist of two inputs ( A & B ) each of 1 bit and has three outputs. The three outputs are A is less than B ( A < B ) , A is equal to B ( A = B ) and A is greater than B ( A > B ).

### 1 Bit Comparator Truth Table

A | B | A<B | A=B | A>B |

0 | 0 | 0 | 1 | 0 |

1 | 0 | 0 | 0 | 1 |

0 | 1 | 1 | 0 | 0 |

1 | 1 | 0 | 1 | 0 |

#### Output Expression

The output expression is written in SOP form ( A = 1 & A’ = 0 ), similarly ( B = 1 & B’ = 0 ).

The output is written only when logic 1 is obtained in the output.

**Expression for A < B**

Y = A’B

**Expression for A = B**

Y = A’B’ + AB

**Expression for A > B**

Y = AB’

## 2 bit Magnitude Comparator

A magnitude comparator that compares two bits, each of two bit is known as two bit comparator. It consist of four inputs ( A_{1}, A_{0} & B_{1}, B_{0} ) each of 1 bit and has three outputs. The three outputs are A is less than B ( A < B ) , A is equal to B ( A = B ) and A is greater than B ( A > B ).

### 2 Bit Comparator Truth Table

A | B | A<B | A=B | A>B | ||

A | A | B | 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 |

The above comparison is done on the basis of weight. Here, A_{1} & B_{1} has weight 2 and A_{2} & B_{2} has weight 1.

Lets take example of 6 and 9 and compare them

A | A | B | B |

0 | 1 | 1 | 0 |

1 | 0 | 0 | 1 |

In BCD, 6 A_{0} has weight 1 and B_{1} has weight 2. So, B will be greater than A.

In BCD, 9 A_{1} has weight 2 and B_{0} has weight 1. So, A will be greater than B.

#### Output Expression

The output expression is written in SOP form ( A = 1 & A’ = 0 ), similarly ( B = 1 & B’ = 0 ).

The output is written only when logic 1 is obtained in the output.

**K Map for A < B**

**Expression for A < B**

Y = A_{1}’B_{1} + A_{1}’A_{0}’B_{0} + A_{0}’B_{1}B_{0}

**K Map for A = B**

**Expression for A = B**

Y = A_{1}’A_{0}’B_{1}’B_{0}’ + A_{1}’A_{0}B_{1}’B_{0} + A_{1}A_{0}B_{1}B_{0} + A_{1}A_{0}’B_{1}B_{0}’

**K Map for A > B**

**Expression for A > B**

Y = A_{1}B_{1}’ + A_{0}B_{1}’B_{0}’ + A_{1}A_{0}B_{0}’

### Application of Magnitude Comparator

- Magnitude comparators are used in CPU’s ( Central Processing Unit ) and MCU’s ( Microcontrollers ).
- It is used in servo motor control.
- Used in biometric applications and password verifications.

**Author**

Akash Sharma

**Discover More –**

Learnt a lot from this blog 🙏🙏

Thank You. Keep Learning.

Informative contents 👏👏