Reference
The logic gates
A gate takes one or two inputs, each on (1) or off (0), and gives one output. Six gates build everything a computer does. The little table under each gate is its truth table — it shows the output for every possible input. Back to the lab anytime: Open the circuit lab →
- AND
&On only when BOTH inputs are on. Think "a and b are both true".
a b out 0 0 0 1 0 0 0 1 0 1 1 1 - OR
≥1On when AT LEAST ONE input is on. Off only when both are off.
a b out 0 0 0 1 0 1 0 1 1 1 1 1 - NOT
¬Flips one input: on becomes off, off becomes on. The only one-input gate.
a b out 0 — 1 1 — 0 - XOR
=1On when the two inputs are DIFFERENT (exactly one is on). This is the "sum" bit of adding.
a b out 0 0 0 1 0 1 0 1 1 1 1 0 - NAND
&̄AND, then flipped — off only when both inputs are on. Every other gate can be built from just NAND.
a b out 0 0 1 1 0 1 0 1 1 1 1 0 - NOR
≥1̄OR, then flipped — on only when both inputs are off.
a b out 0 0 1 1 0 0 0 1 0 1 1 0
Adding two bits needs just two gates: the sum is a XOR b and the
carry is a AND b. Chain those and you have built an adder — the heart of a CPU.
Try a challenge →