Logo
All chapters
Volume II: Digital Logic  ›  Gate-Level Minimization

Exclusive-OR Function

XOR: output 1 when an odd number of inputs are 1 — the parity gate.

PrevOther Two-Level Implementations
NextHardware Description Languages

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

ABA⊕BA⊙B (XNOR)
0001
0110
1010
1101

Black-box view

ABXORblack boxY

Inputs on the left → outputs on the right · particles show signal direction

Logic diagram

0YA0B0NOTNOTANDANDOR

Click inputs to toggle · glowing wires carry 1 · particles show signal direction

XOR and XNOR

▶ live simulator
A0B00YXOR

Click a terminal (A/B) to toggle it · glowing wires carry a logic 1 · the lamp is output Y

ABY
000
011
101
110

The 5 Whys

  1. 1

    Why a dedicated XOR? Parity and addition need 'differ' detection.

  2. 2

    Why is it parity? Odd number of 1s flips the running XOR.

  3. 3

    Why useful for errors? A flipped bit changes parity, exposing the fault.

  4. 4

    Why useful in adders? Sum = A ⊕ B ⊕ Cin is exactly odd parity.

  5. 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.
PrevOther Two-Level Implementations
NextHardware Description Languages