Digital Logic

Comparator

A circuit that compares two binary values and outputs their relationship (equal, greater than, less than).

Detailed Explanation

Comparators check conditions for branch decisions, sorting operations, and address decoding. An equality comparator XORs corresponding bits and NORs the results—equality means all XORs are 0. Magnitude comparators propagate comparisons from MSB to LSB.

Signed comparators must handle two's complement properly—the MSB comparison is inverted. Some comparators output encoded results (2-bit for <, =, >); others have separate output lines.