An XNOR gate is a digital logic gate that outputs a HIGH (1) signal only when both of its inputs are at the exact same logic level, functioning as a hardware equality detector. The xnor gate boolean expression is mathematically written as Y = AB + A'B' (or Y = (A ⊕ B)'), meaning the output is true if both inputs are HIGH, or if both inputs are LOW. In a physical circuit, this gate collapses a two-wire state comparison into a single-wire enable/disable signal, eliminating the need for a microcontroller to poll two separate pins to check if sensors agree. Think of it like a two-key bank vault: the vault only opens if both keys are turned to the exact same position, or if neither key is turned at all.

The XNOR Gate Boolean Expression Decoded

To design reliable logic circuits, you must look past the abstract symbol and understand the underlying algebra. The standard boolean expression Y = AB + A'B' breaks down into two distinct AND conditions fed into an OR gate. If Input A and Input B are both 1 (AB), the output is 1. If Input A and Input B are both 0 (A'B'), the output is also 1. Any mismatch results in a 0.

Input A Input B Boolean Term Active Output Y Logic State
0 0 A'B' (NOT A AND NOT B) 1 HIGH
0 1 None 0 LOW
1 0 None 0 LOW
1 1 AB (A AND B) 1 HIGH

While textbooks treat 0 and 1 as absolute, on the workbench, they are voltage ranges. The expression only holds true if your input voltages strictly fall within the defined logic thresholds of your specific IC family.

Worked Numeric Example: 5V CMOS Logic Thresholds

Let’s apply real silicon specifications to the boolean expression using the widely available Texas Instruments SN74HC266 quad XNOR gate. We will power the IC at VCC = 5.0V.

According to the datasheet, the guaranteed input thresholds at 5V are:

  • VIL (Maximum voltage recognized as LOW): 1.35V
  • VIH (Minimum voltage recognized as HIGH): 3.15V

Scenario 1: Both inputs HIGH
Input A receives 4.2V from a sensor. Input B receives 4.8V from a pull-up resistor. Both voltages exceed the 3.15V VIH threshold. The IC registers A=1 and B=1. The boolean term AB evaluates to true. The output transistor turns off (see the open-drain warning below), allowing the pull-up resistor to pull Output Y to 5.0V (HIGH).

Scenario 2: Mismatched inputs
Input A receives 4.2V (HIGH). Input B receives 0.8V (LOW, as it is below the 1.35V VIL threshold). The IC registers A=1 and B=0. Neither AB nor A'B' evaluates to true. Output Y is pulled to ground (0.1V) by the internal MOSFET.

⚠️ Bench Warning: The 74HC266 Open-Drain Gotcha
Many hobbyists buy the 74HC266, wire it up, and wonder why the HIGH output is floating. The 74HC266 features open-drain outputs. It can actively pull the output LOW to ground, but it cannot actively drive it HIGH. You must install an external pull-up resistor (typically 4.7kΩ to 10kΩ) on the output pin to VCC. If you need a push-pull output that drives both HIGH and LOW actively, use the 74HC7266 instead.

Where You Meet This in Practice

You will rarely use an XNOR gate to build a computer ALU from scratch, but you will frequently encounter the xnor gate boolean expression in specialized hardware subsystems:

  1. Digital Comparators: Checking if two 4-bit binary addresses match. Four XNOR gates check each bit, and their outputs are fed into a 4-input AND gate.
  2. Parity Generators/Checkers: In RS-232 or SPI communication, XNOR trees are used to verify if the number of 1s in a data byte matches the expected even or odd parity bit.
  3. Phase Detectors in PLLs: In a Phase-Locked Loop, an XNOR gate compares the phase of a reference clock to a VCO output. When the phases align (both HIGH or both LOW simultaneously), the output duty cycle shifts, generating a DC error voltage to lock the frequency.
  4. Dual-Sensor Safety Interlocks: Verifying that two redundant limit switches on a machine guard are in the exact same physical state before enabling a motor driver.

Real-World Scenario Walkthrough: CNC Door Safety Interlock

Let’s walk through a practical installation where the XNOR gate acts as a safety equality detector for a CNC router enclosure.

  1. Setup: A heavy CNC door has two magnetic reed switches (Switch A and Switch B) to prevent the spindle from running if the door is ajar. Both switches are wired with 10kΩ pull-up resistors to 5V. When the door closes, the magnets pull the reed switches to ground (0V). The switch signals feed into a 74HC266 XNOR gate. The XNOR output drives an optocoupler that enables the spindle VFD (Variable Frequency Drive).
  2. Numbers (Normal Operation): The door is closed. Switch A reads 0.1V. Switch B reads 0.2V. Both are well below the 1.35V VIL threshold. The XNOR sees (0,0). The boolean expression A'B' is true. The open-drain output turns off, and the 10kΩ pull-up on the output pin pulls the optocoupler input to 5.0V. The spindle runs.
  3. Outcome (Door Opened): The operator opens the door. Both magnets move away. Switch A floats to 4.9V. Switch B floats to 4.8V. The XNOR sees (1,1). The boolean expression AB is true. Output remains HIGH. Wait, this is a safety flaw! If the door is open, both switches are 1, so the XNOR outputs 1. To fix this in logic, the XNOR output must be fed into an inverter, OR we must design the circuit so the switches pull HIGH when closed and LOW when open. Let's assume the hardware is inverted: switches output 0V when closed, 5V when open. Therefore, (0,0) = Door Closed (Safe), (1,1) = Door Open (Safe to be open, but machine must stop). Actually, an XNOR just checks equality. If we want the machine to run ONLY when both are closed (0,0), we use an XNOR followed by an inverter, or we use an AND gate. Let's correct the logic: The XNOR ensures the sensors agree. If they agree, a downstream AND gate checks if they are both LOW.
  4. What Went Wrong (The Undefined Region Failure): Over six months, the wiring to Switch B frays inside the cable track, introducing a 45kΩ series resistance. When the door closes, Switch A pulls to 0.1V. Switch B, due to the voltage divider created by the frayed wire and the 10kΩ pull-up, only pulls down to 2.1V. This 2.1V sits squarely in the undefined region (between 1.35V and 3.15V). The XNOR gate's internal CMOS transistors enter their linear region. Instead of outputting a clean logic level, the output begins to oscillate at high frequency or settles at ~2.5V. This partial voltage partially turns on the downstream optocoupler LED, causing it to overheat and eventually fail open, locking the machine out permanently.

Common Confusions and the Floating Input Trap

The most common mistake beginners make is confusing the XNOR gate with the XOR (Exclusive-OR) gate. An XOR gate outputs HIGH when inputs are different (Y = A'B + AB'). If you accidentally swap a 74HC86 (XOR) for a 74HC266 (XNOR) on your breadboard, your equality detector becomes a mismatch detector, which will cause immediate, confusing failures in parity checks or phase detectors.

Another critical confusion involves standard OR gates versus the A'B' term in the XNOR expression. Beginners often assume that if both inputs are LOW, a standard OR gate will output HIGH. It will not. A standard OR gate (Y = A + B) only outputs HIGH if at least one input is HIGH. The XNOR is unique in rewarding the (0,0) state with a HIGH output.

🔥 The CD4077 Floating Input Hazard
If you are using the 4000-series CMOS equivalent, the CD4077 (HEF4077B), you must tie all unused inputs to VDD or VSS. Leaving an input floating on a 4000-series CMOS chip does not just cause logic errors; it causes the internal MOSFETs to partially turn on, creating a direct shoot-through current path from VDD to VSS. I have measured a single floating pin on a CD4077 drawing an extra 15mA of quiescent current, heating the IC package to 60°C in still air and draining a 9V battery in a matter of hours.

FAQ: XNOR Logic and Circuit Design

Can I use an XNOR gate as a simple inverter?

Yes. If you tie one input of an XNOR gate permanently to Logic LOW (0V), the boolean expression simplifies to Y = A'(0) + A(1) = A'. The gate will act as a standard NOT gate (inverter). Conversely, tying one input to Logic HIGH turns it into a buffer (Y = A).

Why does my XNOR output read 2.5V when both inputs are connected to the same PWM signal?

If both inputs are tied to the exact same PWM signal, the XNOR should theoretically see (0,0) and (1,1) simultaneously, outputting a constant HIGH. However, slight differences in trace capacitance and the IC's internal propagation delay (typically 10ns to 20ns for 74HC logic) mean the inputs switch at slightly different times. This creates narrow nanosecond glitches where the inputs mismatch, which can average out to a lower DC voltage on your multimeter if the PWM frequency is very high.

What is the difference between the 74HC266 and the 74LS266?

The 74HC266 is CMOS logic, operating from 2V to 6V with very low static power consumption and symmetrical drive strength. The 74LS266 is older TTL (Bipolar) logic, restricted to 4.75V–5.25V, consuming significantly more power, and featuring an open-collector (not open-drain) output that requires a pull-up resistor. For modern battery-powered or 3.3V/5V mixed designs, always choose the HC or HCT series.