XOR
A logic gate that implements "exclusive or".
XOR: the gate that says yes to one input, never both
An XOR gate is a digital logic circuit that produces a high output (1) when its two inputs differ from each other, and a low output (0) when they are identical. If you feed it 0 and 1, you get 1. Feed it 0 and 0, or 1 and 1, you get 0. This behavior, called exclusive or, is fundamental to arithmetic and control logic in electrical systems.
XOR gates are built from transistors arranged in specific patterns. The most common implementation uses four transistors in a configuration that mirrors the gate's truth table. At the IC level, XOR functions appear as discrete gates (like the 7486 TTL chip, which contains four independent 2-input XORs), or as embedded logic within larger circuits. Modern systems implement XOR behavior in programmable logic devices and microcontroller firmware. The gate itself consumes minimal power in CMOS technology, drawing only leakage current when inactive.
Where XOR Solves Real Problems
XOR is the workhorse of binary addition. A full adder circuit uses XOR gates to generate the sum bit when adding two numbers; the carry logic uses AND and OR. Beyond arithmetic, XOR detects change. If you XOR a sensor reading with its previous value, a 1 output means something shifted. Error detection and parity checking rely on this: run data through a series of XORs and a single bit flip anywhere upstream will flip the parity output. Programmable logic controllers use XOR to compare signals that should remain synchronized.
The weakness of XOR is speed and fan-in. Standard XOR is inherently a 2-input function. Extending it to three or more inputs requires chaining gates, each adding propagation delay. In a ripple-carry adder, this delay stacks across bit positions and limits clock speed. For multiplication or complex combinatorial logic, the XOR tree becomes deep and slow. This is why faster adders use carry-lookahead logic, which predicts carries in parallel rather than waiting for ripple.
The name 'exclusive or' comes from Boolean algebra and contrasts with inclusive or. An inclusive OR outputs 1 if any input is 1, even if both are 1. Exclusive OR outputs 1 only if inputs differ, excluding the case where both are true. Early logic designers chose this name to clarify the distinction in mathematical notation. In practice, electrical engineers often treat XOR as a specialized comparison operator rather than a true logical gate, which reflects how it is actually used in circuit design.