2-Bit Magnitude Comparator
Compares two 2-bit numbers A (A1A0) and B (B1B0), outputting which is greater or if equal. IC reference: 74HC85.
2-Bit Comparator — IC 74HC85
A 00 = 0
=
B 00 = 0
A = B
Truth Table (all 16 combinations)
| A | B | A>B | A=B | A<B |
|---|---|---|---|---|
| 0 (00) | 0 (00) | 0 | 1 | 0 |
| 0 (00) | 1 (01) | 0 | 0 | 1 |
| 0 (00) | 2 (10) | 0 | 0 | 1 |
| 0 (00) | 3 (11) | 0 | 0 | 1 |
| 1 (01) | 0 (00) | 1 | 0 | 0 |
| 1 (01) | 1 (01) | 0 | 1 | 0 |
| 1 (01) | 2 (10) | 0 | 0 | 1 |
| 1 (01) | 3 (11) | 0 | 0 | 1 |
| 2 (10) | 0 (00) | 1 | 0 | 0 |
| 2 (10) | 1 (01) | 1 | 0 | 0 |
| 2 (10) | 2 (10) | 0 | 1 | 0 |
| 2 (10) | 3 (11) | 0 | 0 | 1 |
| 3 (11) | 0 (00) | 1 | 0 | 0 |
| 3 (11) | 1 (01) | 1 | 0 | 0 |
| 3 (11) | 2 (10) | 1 | 0 | 0 |
| 3 (11) | 3 (11) | 0 | 1 | 0 |
How the Comparator Works
A > B
A1·B̄1 + EQ1·A0·B̄0
A1>B1, OR bits are equal and A0>B0
A = B
XNOR(A1,B1) · XNOR(A0,B0)
All bits are equal (XNOR → 1 when inputs match)
A < B
Ā1·B1 + EQ1·Ā0·B0
Symmetric to A>B — A1<B1, or equal high bits and A0<B0
Key property
Exactly one output is always HIGH. GT + EQ + LT = 1 for all input combinations.