Magnitude Comparator in Logisim-evolution: 1-Bit, 4-Bit, and 74LS85 Cascading
Direct Answer: Magnitude Comparators in Logisim-evolution
A Magnitude Comparator evaluates two $N$-bit binary numbers ($A$ and $B$) and asserts one of three mutually exclusive outputs: A > B, A = B, or A < B. In Logisim-evolution, the built-in Comparator component (Arithmetic → Comparator) supports 1 to 32 bits and includes a vital Numeric Type attribute toggling between Two’s Complement (Signed) and Unsigned comparison. At the gate level, 1-bit equality uses XNOR ($x_i = \overline{A_i \oplus B_i}$), while multi-bit inequality cascades MSB-to-LSB priority terms.
Recommended Lab Kits and Architecture Textbooks
Elegoo Electronics Component Starter Kit
Prototype 74LS85 4-bit magnitude comparators with DIP switches, LEDs, and 830-point breadboards.
Digital Design & Computer Architecture
Covers equality comparators, relational operators in Verilog/VHDL, and CPU branch-if-equal (beq) hardware.
1-Bit Magnitude Comparator Truth Table and Equations
| A | B | A > B (A · ~B) | A = B (~(A ⊕ B)) | A < B (~A · B) |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 0 | 1 | 0 |
Boolean Equations and Four Stage 4-Bit Assembly
(A > B): (A3 · ~B3) + (x3 · A2 · ~B2) + (x3 · x2 · A1 · ~B1) + (x3 · x2 · x1 · A0 · ~B0)
(A < B): (~A3 · B3) + (x3 · ~A2 · B2) + (x3 · x2 · ~A1 · B1) + (x3 · x2 · x1 · ~A0 · B0)
- Unpack Buses: Split 4-bit buses
A[3:0]andB[3:0]using two 4-way Splitters. - Compute Bitwise XNOR Equality: Place four 2-input XNOR gates generating
x3, x2, x1, x0, then feed all four into a 4-input AND gate forA = B. - Build Priority AND-OR Trees: Construct the four AND terms for
A > Band sum them in a 4-input OR gate. - Derive A < B Efficiently: Rather than duplicating the entire tree, compute
A < B = ~(A > B) & ~(A = B)(NOR of the other two outputs).
Frequent Traps in Logisim Comparator Circuits
Trap 1: Signed vs Unsigned Mode Mismatch
Fix: Logisim’s Comparator defaults to 2’s Complement, treating 1111 (-1) as less than 0001 (+1). Switch Numeric Type to Unsigned for counters and addresses.
Trap 2: Floating Cascade Inputs on 74LS85
Fix: On physical 74LS85 chips, tie the lowest-order chip’s cascade inputs to I(A=B) = 1, I(A>B) = 0, and I(A<B) = 0.
Trap 3: Reversing MSB and LSB in Gate-Level Trees
Fix: Always compare Bit 3 (MSB) first with zero gating; comparing Bit 0 first makes 0001 > 1000.
Trap 4: Comparing Two Buses of Different Bit Widths
Fix: Pass the narrower bus through a Bit Extender (Zero or Sign) before wiring to the Comparator.
Curriculum Progression from Comparators to Processors
Frequently Asked Questions About Magnitude Comparators
How do I compare two numbers without a dedicated Comparator block?
Subtract A - B with an Adder/Subtractor: if all sum bits are 0, A == B; if Carry/Borrow or N ⊕ V triggers, A < B.
How do you cascade two 4-bit 74LS85 comparators into an 8-bit comparator?
Wire the A>B, A=B, and A<B outputs of the lower-nibble 74LS85 directly into the cascade inputs of the upper-nibble 74LS85.
How do I check Greater-Than-or-Equal (A ≥ B) in Logisim?
Connect Logisim’s > and = outputs to a 2-input OR gate, or invert the < output with a single NOT gate.
Why is an XNOR equality comparator faster than a subtractor?
An equality comparator evaluates all bits in parallel with $O(\log N)$ gate depth, avoiding the $O(N)$ carry-ripple delay of a subtractor—critical for fast MIPS beq branch resolution.
