A XOR (Exclusive-OR) gate is a digital logic gate that outputs a HIGH (1) signal only when its inputs are at different logic levels. If both inputs are HIGH or both are LOW, the output drops to LOW (0). In a real circuit or installation, inserting a XOR gate changes a standard parallel data line into a controllable inverter or an error-detection node, allowing systems to flag mismatched states, generate parity bits, or perform binary addition without generating a carry bit. Think of a standard two-way stairway light switch: the light toggles state whenever either switch is flipped, regardless of the other switch's physical position. That physical toggling behavior is the exact logical function of a XOR gate.
The XOR Gate Truth Table and Real-World IC Specs
Before wiring up a breadboard, you need to select the right logic family for your voltage rails and speed requirements. The logical function remains identical across families, but the electrical characteristics—propagation delay, quiescent current, and operating voltage—vary wildly. Below is a specification comparison of the most common quad 2-input XOR ICs you will encounter in modern and legacy designs.
| Part Number | Logic Family | VCC Range | Typical Propagation Delay (tpd) | Max Quiescent Current (ICC) |
|---|---|---|---|---|
| SN74HC86 | HC (High-Speed CMOS) | 2.0V to 6.0V | 14 ns (at 5V) | 2 µA |
| SN74LS86 | LS (Low-Power Schottky TTL) | 4.75V to 5.25V | 10 ns (at 5V) | 1.6 mA |
| CD4030B | 4000-Series CMOS | 3.0V to 18.0V | 110 ns (at 5V) | 5 µA |
| SN74LVC86A | LVC (Low-Voltage CMOS) | 1.2V to 3.6V | 4.5 ns (at 3.3V) | 10 µA |
Table Note: Propagation delay (tpd) is measured with a 50pF load capacitance. Data sourced from Texas Instruments and NXP Semiconductors datasheets.
The standard truth table for any of these ICs is straightforward:
- Input A = 0, Input B = 0: Output Y = 0
- Input A = 0, Input B = 1: Output Y = 1
- Input A = 1, Input B = 0: Output Y = 1
- Input A = 1, Input B = 1: Output Y = 0
Worked Example: Timing and Power in a 4-Bit Parity Checker
To understand how XOR gates behave in a cascaded real-world circuit, let us calculate the logic states, propagation delay, and dynamic power consumption of a 4-bit odd parity checker. This circuit uses three 74HC86 gates daisy-chained together to verify if a 4-bit data word contains an odd number of HIGH bits.
The Setup:
We are using a 74HC86 powered at 5.0V. The inputs are A=1, B=0, C=1, and D=1.
- Gate 1 takes inputs A and B.
- Gate 2 takes the output of Gate 1 and input C.
- Gate 3 takes the output of Gate 2 and input D.
Step 1: Logic State Calculation
- Gate 1 (1 XOR 0) = 1
- Gate 2 (1 XOR 1) = 0
- Gate 3 (0 XOR 1) = 1
The final output is HIGH (1), correctly indicating an odd number of 1s in the input word (three 1s).
According to the 74HC86 datasheet, the typical propagation delay (tpd) at 5V is 14 ns per gate. Because the signal must pass sequentially through three gates, the total worst-case propagation delay is:
t_total = 3 × 14 ns = 42 nsIf this parity checker is placed in a high-speed data bus, the maximum theoretical clock frequency before the output becomes unreliable is dictated by the total delay. A signal must settle before the next clock edge:
f_max = 1 / (2 × t_total) = 1 / (2 × 42 ns) = 1 / 84 ns ≈ 11.9 MHzPushing the clock past 11.9 MHz risks sampling the parity bit before Gate 3 has finished resolving its state.
Step 3: Dynamic Power Dissipation
CMOS gates draw negligible current when static, but they consume power every time the output switches due to charging and discharging internal and load capacitances. The 74HC86 has a power dissipation capacitance (Cpd) of roughly 18 pF per gate. If our circuit is toggling at 10 MHz, the dynamic power per gate is:
P_dynamic = Cpd × VCC² × f = 18 pF × (5V)² × 10 MHz = 4.5 mW per gate
For all three active gates, the dynamic power draw is 13.5 mW. While small, in a 64-bit ECC memory controller using dozens of cascaded XOR gates, this dynamic switching current dictates your thermal management and decoupling capacitor placement.
Where You Meet XOR Gates in Practice
You will rarely see a XOR gate used in isolation. Its true value emerges when combined with other logic elements in specific architectural blocks:
- Half-Adders and Full-Adders: The XOR gate is the 'Sum' generator in binary arithmetic. When adding two bits (1+1), the sum is 0 and the carry is 1. The XOR gate handles the sum (1 XOR 1 = 0), while an AND gate handles the carry. Full-adders chain these together to build the ALUs inside microcontrollers.
- Parity Generators and Checkers: Used heavily in RAM Error Correction Code (ECC) and serial communication protocols (like UART and I2C). A tree of XOR gates compresses a wide data bus into a single parity bit to detect single-bit transmission errors.
- Programmable Inverters: If you tie one input of a XOR gate to a control signal and the other to your data, it acts as a software-controlled NOT gate. If the control pin is LOW, the data passes through unchanged (A XOR 0 = A). If the control pin is HIGH, the data is inverted (A XOR 1 = NOT A). This is widely used in I/O pin configuration registers.
- Phase Detectors in PLLs: In Phase-Locked Loops, a XOR gate compares the phase of a reference oscillator against a voltage-controlled oscillator (VCO). If the two square waves are perfectly 90 degrees out of phase, the XOR output is a 50% duty cycle square wave. The average DC voltage of this output is fed through a low-pass filter to adjust the VCO frequency.
Common Confusions: XOR vs. OR and XNOR
Beginners frequently conflate the Exclusive-OR with the standard Inclusive-OR, or confuse it with its complement, the XNOR. Here is how to keep them straight on the bench:
| Gate Type | Symbol | Outputs HIGH (1) When... | Primary Use Case |
|---|---|---|---|
| OR | Inclusive OR | Any input is 1, OR both are 1. | Event triggering (e.g., alarm if door OR window opens). |
| XOR | Exclusive OR | Inputs are DIFFERENT (exactly one is 1). | Difference detection, binary summing without carry. |
| XNOR | Exclusive NOR | Inputs are the SAME (both 0 or both 1). | Equality detection, digital comparators. |
The critical distinction is the word Exclusive. A standard OR gate does not care if both inputs are HIGH; it still outputs HIGH. The XOR gate explicitly excludes the 'both HIGH' state, forcing the output LOW when inputs match.
Frequently Asked Questions
Can I build a XOR gate using only NAND gates?
Yes. Because the NAND gate is a universal gate, you can construct a XOR function using exactly four 2-input NAND gates. This is a common exercise in digital logic design and is useful if you are trying to minimize your Bill of Materials (BOM) by standardizing on a single IC type like the 74HC00 quad NAND.
Why does my XOR gate output oscillate when I use a mechanical switch?
Mechanical switches suffer from contact bounce, generating a rapid series of HIGH/LOW transitions over a few milliseconds. Because the XOR gate has a propagation delay in the nanosecond range, it will faithfully output every single bounce as a distinct logic pulse. If this output feeds a clock line or a counter, you will get multiple false triggers. Always debounce mechanical switches using an RC low-pass filter and a Schmitt trigger (like the 74HC14) before feeding the signal into a XOR gate.
What is the fan-out limit for a 74HC86 XOR gate?
When driving other 74HC-series CMOS inputs at 5V, the fan-out is theoretically in the thousands because CMOS inputs draw virtually zero DC current (only leakage current in the nanoamp range). However, in practice, every input you connect adds roughly 10pF of parasitic capacitance. Driving more than 10 to 15 inputs will significantly degrade your rise/fall times and increase your propagation delay, limiting your maximum operating frequency. For high fan-out requirements, use a dedicated buffer IC like the 74HC244.






