Computing Library › Classical Logic Gates
Classical Logic Gates

XNOR Gate

The XNOR gate outputs 1 when its inputs are equal; it is the complement of XOR and acts as an equality detector.

What it does

XNOR, exclusive-NOR, is the complement of XOR. Its output is 1 when the inputs are the same and 0 when they differ. It is often called an equality or coincidence gate.

Truth table

Kronos motion — when
ABA XNOR B
001
010
100
111

Algebraic form

XNOR equals NOT(A XOR B), which expands to A AND B, OR NOT A AND NOT B. It is commutative and associative, and satisfies A XNOR 1 = A and A XNOR 0 = NOT A.

Equality across many bits

To test whether two multi-bit words are equal, XNOR each pair of bits and AND all the results. A single mismatch drops the AND to 0, so the final signal is 1 only for exact equality. This is the heart of a magnitude comparator's equality path.

In code

python
out = 1 - (a ^ b)      # XNOR of two 0/1 bits
equal = all(x == y for x, y in zip(word1, word2))

Where it appears

As the natural companion to XOR, XNOR provides the sameness test that pairs with XOR's difference test.