Schematex
logic·IEEE 91·hardware, education·complexity 3/3·since v0.1.0

2-bit magnitude comparator

Gate-level comparator for two 2-bit numbers with GT, EQ and LT outputs — XOR, NOT, AND, OR and NOR gates in ANSI distinctive-shape symbols with real fan-out.

For the digital logic instructor

Open in Playground →
schematex§ source-defined
2-bit Magnitude Comparator Logic gate diagram with 10 gates, 4 inputs, 3 outputs NOT NOT XOR XOR NOR NOT AND AND OR NOR A1 A0 B1 B0 GT EQ LT 2-bit Magnitude Comparator
16 lines · 457 chars
✓ parsed·0.0 ms·0 B
100%

Scenario

The circuit every digital-logic course draws at least once: compare A = A1A0 with B = B1B0 and raise exactly one of three outputs — A greater than B (GT), equal (EQ), or less than (LT). Ten gates cover most of the ANSI symbol set, and several signals feed two gates each.

Annotation key

How to read

Signals flow left to right. The two XORs flag which bit positions differ; EQ is the NOR of those flags, so it is true only when both bits match. GT is true when the high bit decides (A1 is 1 and B1 is 0) or when the high bits match and the low bit decides (A0 is 1 and B0 is 0). LT is whatever is left: the NOR of GT and EQ. A filled dot marks a wire that splits to feed several gates; wires that only cross have no dot.

Logic syntax