Digital Comparator (Magnitude Comparator)

A digital comparator (or magnitude comparator) is a combinational circuit that compares two binary numbers and indicates whether the first is greater than, equal to, or less than the second. It produces three mutually exclusive outputs — A>B, A=B and A<B. Comparators appear in ALUs, sorting hardware, address decoding and control logic. This guide covers the 1-bit and 2-bit designs and how they scale.

1-bit comparator

Comparing single bits A and B:

ABA>BA=BA<B
00010
01001
10100
11010

Boolean expressions:

  • A>B = A · B'
  • A=B = A ⊙ B = (A ⊕ B)' (XNOR — equality)
  • A<B = A' · B

Notice equality is exactly the XNOR gate — which is why XNOR is often called the equality gate.

Multi-bit comparison

To compare two n-bit numbers, compare from the most significant bit (MSB) down. The rule:

  1. Compare the MSBs. If they differ, that decides the result (the number with MSB = 1 is larger).
  2. If the MSBs are equal, move to the next bit and repeat.
  3. If all bits are equal, A = B.

Each bit stage uses an XNOR to test equality and passes control to the next-lower bit only when the current bits match. This is why equality (XNOR) terms chain through the whole comparator.

2-bit comparator expressions

For A = A₁A₀ and B = B₁B₀, with e₁ = (A₁ ⊙ B₁) and e₀ = (A₀ ⊙ B₀):

  • A>B = A₁B₁' + e₁·A₀B₀'
  • A=B = e₁ · e₀
  • A<B = A₁'B₁ + e₁·A₀'B₀

Cascading comparators

Standard comparator ICs and IP blocks provide cascade inputs so several can be chained to compare wide words. The higher-order comparator’s result dominates; the cascade inputs only matter when the higher bits are equal — the same MSB-first priority as above.

Where comparators are used

Inside ALUs for branch and conditional instructions, in address decoders (is this address in my range?), in priority and arbitration logic, and in sorting/searching hardware. A comparator is purely combinational, so its result is valid after the propagation delay of its gate chain.

FAQs on digital comparators

What is a digital comparator?

A combinational circuit that compares two binary numbers and outputs whether the first is greater than, equal to, or less than the second.

Which gate is used to check equality?

The XNOR gate — it outputs 1 only when its two inputs are equal, so an XNOR per bit (ANDed together) detects whole-number equality.

How does a multi-bit comparator work?

It compares from the most significant bit down. The first differing bit decides the result; lower bits only matter when all higher bits are equal.

Is a comparator combinational or sequential?

Combinational — its outputs depend only on the current input numbers, with no memory or clock.

Learn combinational and datapath design in ChipXpert’s RTL Design course. Related: combinational circuits, logic gates.

🎓 Take VLSI Courses Online → Explore ChipXpert Online  –  Live VLSI courses with practical EDA lab work.
Have questions about this topic?
Share your question in comments or talk to our mentor team for batch guidance.

Ask the Admin Team

Drop your basic question in comments: eligibility, prerequisites, tools, fee range, and placement support.

Our team reviews and responds regularly.

Tags :
Share This :