An XNOR (Exclusive-NOR) gate is a digital logic gate that outputs a HIGH signal only when both of its inputs are at the exact same logic level. If you are building digital circuits, you can think of it as an equality checker: it fires a '1' when Input A equals Input B, and a '0' when they differ. Unlike basic AND/OR gates that trigger on the mere presence or absence of a voltage, the XNOR gate evaluates the relationship between two signals, making it the foundational building block for comparators, parity checkers, and phase detectors.

The Core Logic and Voltage-Level Reality

On paper, digital logic is perfectly binary. On the workbench, it is entirely analog until it hits the threshold of a specific silicon family. To understand how an XNOR gate actually behaves, we have to look past the abstract 1s and 0s and examine the voltage thresholds defined in the datasheet.

Let's run a worked numeric example using a standard 74HC266 (Quad 2-Input XNOR with open-drain outputs) powered at a nominal 5.0V. According to the Texas Instruments SN74HC266 datasheet, the guaranteed input thresholds at VCC = 4.5V are V_IH (min): 3.15V and V_IL (max): 1.35V.

Worked Bench Example: 74HC266 Equality Check
You are feeding two signals into the XNOR gate to check if a sensor voltage matches a reference voltage.
Scenario 1: Input A receives 4.8V (Valid HIGH, > 3.15V). Input B receives 0.4V (Valid LOW, < 1.35V). Because the logic states differ (1 and 0), the XNOR output transistor turns ON, pulling the output to GND (approx. 0.05V).
Scenario 2: Input A remains at 4.8V. Input B rises to 4.9V. Both inputs are now recognized as HIGH. Because the logic states match (1 and 1), the output transistor turns OFF. Note: Because the 74HC266 has open-drain outputs, the pin will float unless you have installed a pull-up resistor. With a 10kΩ pull-up to 5V, the output now reads 4.95V (Logic 1).
Standard 2-Input XNOR Truth Table
Input AInput BOutput YLogical Meaning
0 (LOW)0 (LOW)1 (HIGH)Match (Both absent)
0 (LOW)1 (HIGH)0 (LOW)Mismatch
1 (HIGH)0 (LOW)0 (LOW)Mismatch
1 (HIGH)1 (HIGH)1 (HIGH)Match (Both present)

Where You Meet XNOR in Practice

You rarely wire up a standalone XNOR gate just to flip a LED. In practical circuit design and embedded systems, XNOR logic is embedded inside larger functional blocks or used for specific signal-validation tasks.

  • Digital Magnitude Comparators: Chips like the 74HC85 use arrays of XNOR gates internally to compare two 4-bit binary words. The XNOR gates check each corresponding bit (A0 to B0, A1 to B1, etc.). Only if every XNOR gate outputs a HIGH does the comparator declare the two numbers equal.
  • Parity Generators and Checkers: In serial communication (like UART or SPI), an extra 'parity bit' is sent to detect transmission errors. XNOR trees are used to generate even parity and verify it on the receiving end. If the received data doesn't match the expected XNOR parity output, the microcontroller flags a framing error.
  • Phase Detectors in PLLs: In a Phase-Locked Loop (PLL) circuit, an XNOR gate (often implemented as a digital phase-frequency detector) compares the phase of a reference oscillator against a voltage-controlled oscillator (VCO). The width of the XNOR's output pulses is directly proportional to the phase difference, which is then filtered into a DC control voltage.
  • Direction Sensing in Quadrature Encoders: When reading rotary encoders with an FPGA or CPLD, XNOR logic is frequently combined with D-flip-flops to determine whether the encoder shaft is spinning clockwise or counter-clockwise based on the phase lead/lag of the A and B channels.

XNOR vs. XOR and NOR: Clearing Up the Confusion

The most common mistake beginners make is confusing the XNOR gate with the standard NOR gate, or misunderstanding how it relates to the XOR gate. The 'X' stands for Exclusive. A standard OR gate outputs HIGH if any input is HIGH (inclusive). An XOR gate outputs HIGH if exactly one input is HIGH (exclusive). An XNOR is simply an XOR gate with an inverter slapped on the output.

Logic Gate Comparison Matrix
Gate TypeOutputs HIGH When...Outputs LOW When...Primary Use Case
NORBoth inputs are 0Any input is 1Active-low triggers, reset circuits
XORInputs are different (0,1 or 1,0)Inputs are the sameAdders, difference detectors, toggles
XNORInputs are the same (0,0 or 1,1)Inputs are differentEquality checking, parity, phase detection

If you look at the truth tables, NOR and XNOR both output a HIGH when inputs are (0,0). But when inputs are (1,1), a NOR gate outputs LOW, while an XNOR gate outputs HIGH. Swapping these two on a PCB will completely break your logic flow.

What XNOR Changes in a Real Circuit Installation

Substituting an XNOR for an XOR (or vice versa) in a physical circuit fundamentally inverts the system's concept of 'truth'.

Imagine you are building a safety interlock for a CNC router. The door sensor and the emergency stop button must both be in the same state (both safe/closed, or both tripped/open) for the controller to allow a reset. An XNOR gate validates this equality. If you accidentally solder in a 74HC86 XOR gate instead of a 74HC266 XNOR, the circuit will now demand that the door and the E-stop be in opposite states to trigger a reset. The machine will refuse to start under normal conditions and might unexpectedly enable when a fault occurs.

Bench Warning: The Floating CMOS Input
If you are using a CMOS XNOR chip like the CD4077 or 74HC266, never leave an unused input pin unconnected. CMOS inputs have extremely high impedance. A floating pin will act as an antenna, picking up ambient AC noise from your bench lighting or switching power supplies. This drives the internal MOSFETs into their linear (partially ON) region simultaneously, causing the chip to overheat, draw massive quiescent current, and output a high-frequency oscillation rather than a clean logic level. Always tie unused XNOR inputs to VCC or GND via a 10kΩ resistor.

Frequently Asked Questions

What is the difference between an XOR and an XNOR gate?

The difference is a single logical inversion. An XOR (Exclusive-OR) gate outputs a HIGH signal when its inputs are different (one is 0, the other is 1). An XNOR (Exclusive-NOR) gate outputs a HIGH signal when its inputs are the same (both 0 or both 1). In Boolean algebra, XOR is represented as A ⊕ B, while XNOR is represented as A ⊙ B or (A ⊕ B)'. If you need to convert an XOR circuit to an XNOR circuit, you simply add a NOT gate (inverter) to the output of the XOR gate.

How do you build an XNOR gate using only NAND gates?

NAND gates are 'universal gates,' meaning you can build any logic function using only them. To build a 2-input XNOR gate, you need exactly five NAND gates. The configuration is as follows: Feed inputs A and B into the first NAND gate. Feed A and the output of the first NAND into a second NAND gate. Feed B and the output of the first NAND into a third NAND gate. Finally, feed the outputs of the second and third NAND gates into a fourth NAND gate. (A fifth NAND gate is sometimes used as an inverter on the final output depending on the specific Boolean minimization path you take, but the standard 4-NAND XOR followed by a 1-NAND inverter is the most common bench implementation). For practical prototyping, just use a dedicated HEF4077B chip to save board space and propagation delay.

Why is my 74LS266 XNOR gate output stuck LOW?

If you are using the 74LS266 (the TTL version of the quad XNOR) and your output reads a constant 0.1V regardless of the inputs, you have likely missed a crucial datasheet detail: the 74LS266 features open-collector outputs. Unlike standard push-pull outputs that actively drive the pin HIGH to VCC, an open-collector output can only actively pull the pin LOW to GND. To get a HIGH logic level, you must provide an external pull-up resistor (typically 4.7kΩ to 10kΩ) connected between the output pin and your VCC rail. Without this resistor, the output transistor simply turns off, leaving the pin floating, which your multimeter or logic probe will read as a LOW or undefined state.