
Exclusive-OR Function
XOR: output 1 when an odd number of inputs are 1 — the parity gate.
Description
A gate that outputs 1 when its inputs disagree (odd number of 1s). It builds adders, parity/error-detection, and comparators efficiently. A ⊕ B = A′B + AB′; chain XORs for n-input parity.
- A ⊕ 0 = A; A ⊕ 1 = A′ (controlled inverter).
- A ⊕ A = 0; XOR is associative and commutative.
- Multi-input XOR = 1 for an odd count of 1s (parity).
- What: A gate that outputs 1 when its inputs disagree (odd number of 1s).
- Why: It builds adders, parity/error-detection, and comparators efficiently.
- How: A ⊕ B = A′B + AB′; chain XORs for n-input parity.
- Where: Adder sum bits, parity generators/checkers, CRC, cryptographic mixing.
- When: Anywhere you need parity, equality testing, or controlled inversion.
- Analogy — XOR is a 'spot the difference' detector: output lights up only when the two inputs disagree. Chain them and it becomes an 'odd number of 1s?' counter — that's parity.
At a glance
What
A gate that outputs 1 when its inputs disagree (odd number of 1s).
Why
It builds adders, parity/error-detection, and comparators efficiently.
How
A ⊕ B = A′B + AB′; chain XORs for n-input parity.
Where
Adder sum bits, parity generators/checkers, CRC, cryptographic mixing.
When
Anywhere you need parity, equality testing, or controlled inversion.
Think of it like…
XOR is a 'spot the difference' detector: output lights up only when the two inputs disagree. Chain them and it becomes an 'odd number of 1s?' counter — that's parity.
Key properties
- A ⊕ 0 = A; A ⊕ 1 = A′ (controlled inverter).
- A ⊕ A = 0; XOR is associative and commutative.
- Multi-input XOR = 1 for an odd count of 1s (parity).
XOR / XNOR truth table
| A | B | A⊕B | A⊙B (XNOR) |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Black-box view
Inputs on the left → outputs on the right · particles show signal direction
Logic diagram
Click inputs to toggle · glowing wires carry 1 · particles show signal direction
XOR and XNOR
▶ live simulatorClick a terminal (A/B) to toggle it · glowing wires carry a logic 1 · the lamp is output Y
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
The 5 Whys
- 1
Why a dedicated XOR? Parity and addition need 'differ' detection.
- 2
Why is it parity? Odd number of 1s flips the running XOR.
- 3
Why useful for errors? A flipped bit changes parity, exposing the fault.
- 4
Why useful in adders? Sum = A ⊕ B ⊕ Cin is exactly odd parity.
- 5
Root cause: 'inequality/odd-count' is a recurring primitive worth its own gate.
Cheat sheet
Working principle
- A ⊕ B = A′B + AB′; chain XORs for n-input parity.
- A gate that outputs 1 when its inputs disagree (odd number of 1s).
Formulas & Boolean expressions
- A ⊕ 0 = A; A ⊕ 1 = A′ (controlled inverter).
- A ⊕ A = 0; XOR is associative and commutative.
- Multi-input XOR = 1 for an odd count of 1s (parity).
Key facts
- A ⊕ 0 = A; A ⊕ 1 = A′ (controlled inverter).
Why it exists
- Root cause: 'inequality/odd-count' is a recurring primitive worth its own gate.