XOR with 0, with itself, or with 1 — three handy patterns in one picture. A ready-made basics circuit you can open in the TorchAnvil simulator.
XOR, three ways
XOR is "is the sum odd?" — it outputs 1 when an odd number of its
inputs are 1. That single rule gives it three very useful personalities
when one input is held at a fixed value.
This sample wires the same lever A into three different XOR gates,
each with a different second input: constant 0, A itself (fan-out),
and constant 1.
How it works
Work through each XOR with the rule XOR(x, y) = x ≠ y:
A ⊕ 0: A differs from 0 exactly when A is 1. So the output is A.
XOR with 0 is a pass-through.
A ⊕ A: A always equals itself, so the output is always 0. XOR
with yourself is a forced zero.
A ⊕ 1: A differs from 1 exactly when A is 0. So the output is
!A. XOR with 1 is a conditional inverter.
A
A ⊕ 0
A ⊕ A
A ⊕ 1
0
0
0
1
1
1
0
0
Why it matters
These three identities show up all the time in real circuits:
XOR with 0 is how you "do nothing" when building a configurable
adder/subtractor — flip a control bit from 0 to 1 and the same XOR
suddenly becomes an inverter, letting one circuit add or subtract.
XOR with itself is the bedrock of parity and error-detection
schemes: a signal XOR'd with a delayed copy of itself detects
changes.
XOR with 1 is the cheapest conditional NOT in existence. Whole
cipher rounds (AES, DES, etc.) are built from exactly this pattern.
Try this
Flip the lever. Watch the three lamps follow three different rules.
The middle one never moves.
Mentally swap the constants: what if the top XOR used 1 instead
of 0? (Spoiler: the top and bottom lamps would swap behavior.)
Notice the fan-out on the middle XOR: the lever's single output
drives both inputs — exactly the trick that forces the output to 0.