1-Bit Full Comparator (Less, Equal, Greater)
Build a complete 1-bit comparator with three outputs—less than, equal to, and greater than—combining all comparison operations in one circuit!
Overview
Now that you've built each comparison operation individually, it's time to combine them into a single circuit. The full 1-bit comparator takes two inputs (A and B) and produces three outputs simultaneously: A>B, A=B, and A<B. For any pair of inputs, exactly one of these three outputs will be HIGH. This is the same logic used inside dedicated comparator ICs like the 74LS85, and it scales up to multi-bit comparison.
Components Needed
- 1x SN74HC04 IC (Hex Inverter)
- 1x SN74HC86 IC (Quad XOR)
- 1x CD4081 IC (Quad AND)
- 2x Switch
- 3x LED
- severalx Wires
Instructions
Identify the SN74HC04 Inverter IC
The SN74HC04 provides the NOT gates needed for both magnitude comparisons and the equality check. We'll use multiple inverters from this single chip.
Identify the SN74HC86 XOR IC
The XOR gate detects when inputs differ. Its output, inverted, gives us the equality signal. One XOR gate from the 74HC86 handles equality detection.
Identify the CD4081 AND Gate IC
The CD4081 provides the AND gates for magnitude comparison. One AND gate computes A AND NOT(B) for "greater than," another computes NOT(A) AND B for "less than."
Wire the Full Comparator
Place all three ICs on the breadboard. Connect power for all chips. Wire two switches for inputs A and B. Create three signal paths: (1) A and NOT(B) through an AND gate to the "greater than" LED, (2) A XOR B through an inverter to the "equal" LED, (3) NOT(A) and B through an AND gate to the "less than" LED. The three LEDs show the complete comparison result.
Test: A=0, B=0 → Output 010 (Equal)
Both switches OFF. A equals B, so only the middle LED (equal) lights up. Output pattern: 010 (Greater=OFF, Equal=ON, Less=OFF).
Test: A=0, B=1 → Output 001 (A < B)
Left switch OFF, right switch ON. A is less than B, so only the right LED (less than) lights. Output pattern: 001 (Greater=OFF, Equal=OFF, Less=ON).
Test: A=1, B=0 → Output 100 (A > B)
Left switch ON, right switch OFF. A is greater than B, so only the left LED (greater than) lights. Output pattern: 100 (Greater=ON, Equal=OFF, Less=OFF).
Test: A=1, B=1 → Output 010 (Equal)
Both switches ON. A equals B again, so the middle LED lights. Output pattern: 010. Notice that exactly one LED is always on—the three outputs are mutually exclusive and exhaustive!
Challenges
- Add a 4th LED that indicates "not equal" (OR the greater-than and less-than outputs)
- Extend this to a 2-bit comparator by comparing the MSB first, then the LSB
- Build the same circuit using only NAND gates
- Compare your gate-based design to the dedicated 74LS85 comparator IC