Four-Bit Comparator
How a comparator produces equality, greater-than, and less-than flags for two multi-bit values.
Updated 2026-07-09
A comparator evaluates two values and reports their relationship. For unsigned four-bit inputs, the common result flags are eq for equality, gt for greater-than, and lt for less-than.
For any one input pair, exactly one of those flags should be high. Give every flag a default value of 0, then use an if / else if / else chain: equality first, greater-than next, and less-than as the remaining case.
Named comparison flags are useful in control logic because later code can read the decision directly instead of repeating the original comparison expression.