Outputs true when inputs are the same (negated XOR).
The XNOR gate (Exclusive NOR), also called the equivalence gate, outputs 1 when both inputs are the same — both 0 or both 1. It is the negation of the XOR gate. While the XOR gate detects difference between two binary signals, the XNOR gate detects agreement. This complementary relationship makes XNOR the natural choice whenever a circuit needs to answer the question "are these two bits equal?" The XNOR function corresponds to the logical biconditional (if and only if) in propositional logic, written as A if-and-only-if B, and has been studied by logicians since the formalization of propositional calculus.
| A | B | A XNOR B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
XNOR answers the question "are the inputs the same?" It is equivalent to NOT(A XOR B), which can be expanded to (A AND B) OR (NOT A AND NOT B). The first term, A AND B, catches the case where both inputs are 1. The second term, (NOT A AND NOT B), catches the case where both inputs are 0. Together, they cover exactly the situations where the two inputs match. Another way to understand XNOR is through modular arithmetic: A XNOR B equals 1 when (A + B) mod 2 equals 0, meaning the sum of the inputs is even. This even-parity interpretation links XNOR to parity checking in the same way XOR links to odd-parity detection.
In CMOS technology, an XNOR gate can be built using approximately eight to twelve transistors, similar in complexity to an XOR gate. One common approach builds the XNOR from its definition as NOT(A XOR B) by constructing an XOR gate and appending an inverter. However, more efficient pass-transistor and transmission-gate implementations exist that compute the XNOR function directly without the intermediate XOR stage. At the gate level, XNOR can be constructed from basic gates as (A AND B) OR (NOT A AND NOT B), requiring two NOT gates, two AND gates, and one OR gate. In the TTL family, the 74266 chip provided four two-input XNOR gates with open-collector outputs, though this chip was less commonly stocked than the 7486 XOR chip because many designers simply inverted the output of an XOR gate when they needed XNOR functionality.
XNOR is the complement of XOR: wherever XOR outputs 1, XNOR outputs 0, and vice versa. This complementary pair mirrors the AND/NAND and OR/NOR pairs. However, unlike the NAND and NOR gates, XNOR is not functionally complete on its own. You cannot build a NOT gate from XNOR gates alone because XNOR preserves the constant 1 (1 XNOR 1 = 1) and maps (0, 0) to 1 as well. The XNOR gate can also be expressed through De Morgan-style manipulation: since A XNOR B = NOT(A XOR B) = (A AND B) OR (NOT A AND NOT B), it is equivalent to asking whether both inputs belong to the same class (both true or both false). In terms of the other gate relationships, XNOR completes a natural family: AND detects "both on," OR detects "at least one on," XOR detects "exactly one on," and XNOR detects "same state."
XNOR gates function as single-bit equality comparators, making them essential building blocks in digital circuits that compare binary values. A multi-bit equality comparator — a circuit that determines whether two n-bit binary numbers are identical — is built by connecting one XNOR gate to each pair of corresponding bits and then feeding all the XNOR outputs into a large AND gate. The AND gate outputs 1 only when every XNOR gate reports a match, meaning every bit position is identical. This architecture is used in cache tag comparators, content-addressable memories (CAMs), and address matching logic. In error detection circuits, XNOR gates compare received data bits against expected values to flag mismatches. In pattern matching hardware, arrays of XNOR gates perform parallel comparisons to find data that matches a target pattern, enabling high-speed search operations in network routers and database accelerators.
The logical biconditional that XNOR implements has been studied since ancient times as the "if and only if" connective in formal logic. George Boole's algebraic framework naturally accommodated this operation, though he did not single it out as a primitive. In modern machine learning, the XNOR operation has gained renewed attention through XNOR-Net, a technique for creating extremely efficient neural networks where both weights and activations are binarized to single bits. In XNOR-Net, the multiply-accumulate operations that dominate neural network computation are replaced with XNOR and popcount (population count) operations, dramatically reducing computational cost and memory usage. This makes it possible to run neural network inference on resource-constrained devices such as microcontrollers and IoT sensors. The fact that a logic gate from the 1960s found a starring role in twenty-first-century artificial intelligence research is a testament to the enduring relevance of fundamental Boolean operations.