An XOR (Exclusive-OR) gate boolean expression outputs a logic HIGH (1) only when its inputs are at different logic levels, mathematically written as Y = A ⊕ B or Y = A'B + AB'. In a physical circuit, this expression changes a standard signal path from a passive routing trace into an active state-comparing engine, allowing you to detect mismatches, generate parity bits, or perform binary addition. The most common mistake beginners make is confusing the XOR gate with a standard inclusive OR gate; while an inclusive OR outputs HIGH if any input is HIGH, the XOR strictly requires an odd number of HIGH inputs (which, for two inputs, means exactly one must be HIGH and the other must be LOW).
The Core Math and Truth Table
To use the XOR gate effectively in programmable logic (like FPGAs) or discrete IC design, you need to understand its algebraic expansion. The standard symbol is ⊕, but because most logic synthesis tools and breadboard builds rely on fundamental AND, OR, and NOT gates, the expanded boolean expression is:
Y = (A AND NOT B) OR (NOT A AND B)
| Input A | Input B | Output Y (A ⊕ B) | Algebraic Evaluation |
|---|---|---|---|
| 0 | 0 | 0 | (0·1) + (1·0) = 0 |
| 0 | 1 | 1 | (0·0) + (1·1) = 1 |
| 1 | 0 | 1 | (1·1) + (0·0) = 1 |
| 1 | 1 | 0 | (1·0) + (0·1) = 0 |
A standard OR gate (
Y = A + B) will output a 1 when both A and B are 1. The XOR gate forces a 0 in that specific state. If you are designing a circuit where a motor should run if either of two limit switches is triggered, but must stop if both are triggered simultaneously (an error state), you need an XOR gate, not an inclusive OR.
Worked Numeric Example: 5V Logic on a 74LS86
Let’s move from abstract algebra to the workbench using a Texas Instruments SN74LS86 quad 2-input XOR IC running on a standard 5.0V TTL supply. This IC contains four independent XOR gates in a 14-pin DIP package.
The Setup:
We apply VCC = 5.0V to Pin 14 and GND to Pin 7. We feed two signals into Gate 1 (Pins 1 and 2) and monitor the output at Pin 3.
- Input A (Pin 1): 4.2V (Measures as Logic 1, well above the TTL V_IH threshold of 2.0V)
- Input B (Pin 2): 0.3V (Measures as Logic 0, well below the TTL V_IL threshold of 0.8V)
The Boolean Evaluation:
Substituting our logic states into the expression Y = A'B + AB':
- A = 1, B = 0
- NOT A (A') = 0, NOT B (B') = 1
- Y = (0 AND 0) OR (1 AND 1)
- Y = 0 OR 1 = 1
The Bench Result:
The multimeter reads 3.4V at Pin 3. In the LS (Low-power Schottky) logic family, a HIGH output typically sources around 3.4V under light load. The gate draws approximately 1.6mA of supply current, and the signal transition experiences a maximum propagation delay of 22ns. If we were to raise Input B to 4.5V (Logic 1), the boolean expression would evaluate to 0, and the output voltage at Pin 3 would drop to roughly 0.35V (Logic 0).
Where You Meet XOR in Practice
You won't often see an XOR gate used as a standalone switch in home wiring or basic analog circuits, but it is a foundational building block in digital electronics, embedded systems, and telecommunications.
1. Half-Adders and Full-Adders
In binary arithmetic, the sum bit of two single bits is exactly the XOR function. If you add 1 + 0, the sum is 1. If you add 1 + 1, the sum is 0 (with a carry of 1). The boolean expression for the Sum output in a half-adder is literally Sum = A ⊕ B, while the Carry output is an AND gate (Carry = A · B). Every ALU (Arithmetic Logic Unit) inside your microcontroller relies on cascaded XOR gates to perform math.
2. Parity Generators and Error Detection
When transmitting data over UART, I2C, or SPI, noise can flip bits. By cascading XOR gates (using a chip like the CD4030 CMOS quad XOR), you can generate a parity bit. If you XOR all the data bits in a byte together, the result is 1 if there is an odd number of 1s, and 0 if there is an even number. The receiver runs the same boolean expression to verify the data integrity.
3. Phase Detectors in PLLs
In a Phase-Locked Loop (PLL) like the classic CD4046, an XOR gate acts as a Type I phase detector. If you feed two square waves of the same frequency but different phases into the XOR inputs, the boolean expression outputs a pulse train whose average DC voltage is directly proportional to the phase difference between the two signals. This DC voltage is then filtered and used to tune a VCO (Voltage-Controlled Oscillator).
Frequently Asked Questions
How do you write a 3-input XOR gate boolean expression?
A 3-input XOR gate outputs a HIGH only when an odd number of its inputs are HIGH. The boolean expression is written as Y = A ⊕ B ⊕ C. Expanded into fundamental gates, it evaluates to:
Y = A'B'C + A'BC' + AB'C' + ABC.
Notice that the output is 1 if exactly one input is 1, or if all three inputs are 1. This is a common point of failure for students who assume a 3-input XOR only outputs 1 when exactly one input is HIGH.
What is the difference between XOR and XNOR boolean expressions?
The XNOR (Exclusive-NOR) gate is simply the logical inverse of the XOR gate. It acts as an equality detector, outputting a HIGH only when both inputs match.
XOR: Y = A'B + AB' (Outputs 1 when inputs are different).
XNOR: Y = AB + A'B' (Outputs 1 when inputs are the same).
In physical ICs, if you need an XNOR but only have a 74LS86 (XOR) on hand, you can simply wire a standard NOT gate (like a 74LS04) to the output of the XOR gate to invert the boolean result.
How do you convert an XOR boolean expression to NAND-only logic?
In FPGA synthesis and ASIC design, it is often cheaper to build all logic using a single universal gate: the NAND. You can implement the Y = A ⊕ B expression using exactly four NAND gates. The sequence is:
1. N1 = NAND(A, B)
2. N2 = NAND(A, N1)
3. N3 = NAND(B, N1)
4. Y = NAND(N2, N3)
This 4-NAND implementation is a standard optimization trick that saves silicon area compared to building discrete AND, OR, and NOT gates.
Why is the XOR gate boolean expression essential for binary adders?
Binary addition follows modulo-2 arithmetic for the sum bit. When you add 1 + 1 in binary, the result is 10 (zero, carry one). The sum bit wraps around to 0. The inclusive OR gate fails here because 1 OR 1 equals 1. The XOR boolean expression naturally handles this modulo-2 wrap-around, outputting 0 when both inputs are 1, making it the only logical choice for the sum generation in half-adders, full-adders, and ripple-carry adder chains.






