- Asked 2/22
- 2082 Baisakh · 5 marks
4-bit equality comparator
Short answer
Compare each bit pair with an XNOR gate: xi = Ai ⊙ Bi. AND all four outputs: X = x3·x2·x1·x0. X=1 iff A=B. Alternatively, XOR each pair and NOR the results: X = ̅(A3⊕B3)+...+(A0⊕B0).
Design a circuit that compares two 4-bit numbers, A and B, to check if they are equal. The circuit has one output X, so that X = 1 if A = B and X = 0 if A ≠ B.
Two 4-bit numbers and are equal only when every pair of corresponding bits is equal. Equality of one pair is detected by an XNOR gate.
Bit-equality signals
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Output
only if all four :
Equivalent form with XOR and NOR:
A full truth table would have rows with in only 16 of them (), so the bit-wise method is used instead of a K-map.
Logic circuit
A3 --+
B3 --+--[XNOR]-- x3 --+
A2 --+ |
B2 --+--[XNOR]-- x2 --+
+--[AND 4]--- X
A1 --+ |
B1 --+--[XNOR]-- x1 --+
A0 --+ |
B0 --+--[XNOR]-- x0 --+
Gates: four 2-input XNOR gates and one 4-input AND gate.
Examples
| A | B | X | |
|---|---|---|---|
| 1011 | 1011 | 1111 | 1 |
| 1011 | 1001 | 1101 | 0 |
| 0110 | 1110 | 0111 | 0 |
This is the "A = B" part of the 7485 4-bit magnitude comparator.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- 2-bit equality comparator · Digital Logic, chapter 4 · asked 2×
- Hazards in asynchronous design; 2-bit comparator · Digital Logic, chapter 4
- 2-bit magnitude comparator · Digital Logic, chapter 4 · asked 6×
- 3-bit magnitude comparator · Digital Logic, chapter 4 · asked 6×
- C program: sum of two 8-bit BCD numbers · Embedded System, chapter 9