Where we are: under the contract, into the silicon
In the earlier rungs we treated the machine from the top: an ISA contract software trusts, numbers laid out as bits and bytes, the fetch-decode-execute loop beating to a clock. We took for granted that something underneath could actually do the arithmetic and remember a value. This whole rung is that something. We are now stepping below the lowest software layer, into pure hardware, to watch a computer get built out of nothing but switches. By the end of the rung you'll understand every box in a simple processor's datapath, all the way down to the gates inside them.
The plan for this rung is a ladder of its own. This first guide builds the alphabet: the switch, the gate, the algebra. The next assembles those gates into combinational blocks that compute — multiplexers and adders. The third gives hardware a memory with latches and flip-flops. The fourth adds the clock and finds the critical path that limits speed. The fifth ties it together as a finite state machine, the controller pattern behind every real chip. Everything rests on the humble idea we start with now: a switch you can turn on and off with electricity instead of a finger.
The transistor: a switch with no moving parts
Forget the physics for a moment and picture an ordinary wall switch wired between a battery and a lamp. Flip it one way and current flows, the lamp lights — call that 1. Flip it the other way and the circuit is broken, the lamp is dark — call that 0. A computer is, at bottom, billions of such switches. The trick that made computers possible is the transistor: a switch with no lever, controlled not by a finger but by a third wire. Put a high voltage on that control wire and the switch closes; put a low voltage on it and the switch opens. A transistor as a switch is the entire foundation — a device whose output connection is opened or closed by its input voltage.
Why does "a controllable switch" matter so much? Because the control wire and the switched wire speak the same language — voltage levels, high or low, 1 or 0. That means the output of one switch can drive the control of the next. Switches can command other switches. Stack and wire enough of them and the on/off pattern at the far end becomes a chosen function of the pattern at the near end. That single property — switches steering switches — is the seed from which addition, comparison, memory, and eventually a whole CPU grow. We will never again need to think about voltages; from here up it is all 1s and 0s.
Gates: tiny circuits that compute true and false
Wire a few transistors together in a fixed pattern and you get a logic gate: a small circuit whose output bit is a fixed function of its input bits. There are only a handful you need to know. An AND gate outputs 1 only when both inputs are 1 (like two switches in series — both must be closed for current to flow). An OR gate outputs 1 when either input is 1 (two switches in parallel). A NOT gate, the inverter, simply flips its single input: 1 becomes 0, 0 becomes 1. With just these three, plus their combined cousins NAND (not-and) and NOR (not-or), you can express any logical condition you can state in words. A logic gate is the smallest unit that actually decides something.
How do we pin down exactly what a gate does, with no ambiguity? With a truth table — an exhaustive list of every possible input combination and the output it produces. Since each input is just 0 or 1, a gate with n inputs has only 2^n rows, so the table is always finite and we can simply check every case. A truth table is the hardware engineer's specification: if two circuits have the same truth table, they compute the same function, however differently they're wired inside. Here are the basic gates laid out side by side.
A B | AND | OR | XOR | NAND | NOR | NOT A ----+-----+----+-----+------+-----+------ 0 0 | 0 | 0 | 0 | 1 | 1 | 1 0 1 | 0 | 1 | 1 | 1 | 0 | 1 1 0 | 0 | 1 | 1 | 1 | 0 | 0 1 1 | 1 | 1 | 0 | 0 | 0 | 0 (XOR = 1 when inputs differ; NAND = NOT(AND); NOR = NOT(OR))
These gates aren't an abstraction you'll only meet in hardware. The very same operations show up in software as bitwise operations — the AND, OR, XOR, and NOT your programming language applies across all 32 or 64 bits of a word at once. When you write a bit mask to clear or test a flag, you are commanding a row of these exact gates inside the ALU. A bitwise operation is just a whole word's worth of gates firing in parallel, one per bit position.
Boolean algebra: the math of 1 and 0
Gates give us circuits; Boolean algebra gives us the math to reason about them without drawing a single wire. It is ordinary-looking algebra over just two values, 1 (true) and 0 (false), with AND written like multiplication (A·B), OR like addition (A+B), and NOT as a bar over a variable. The laws are mostly familiar — A·1 = A, A+0 = A — plus a few that surprise newcomers, like A+A = A and A·A = A (no exponents here; there's nothing bigger than 1 to climb to). Boolean algebra is the toolkit for proving two different gate circuits compute the same function, and for shrinking a bloated circuit into a cheaper one.
Why bother simplifying? Because fewer gates means a smaller, cheaper, cooler, and faster chip — every gate a signal must pass through adds delay, and we'll see in guide 4 that the slowest path sets the clock speed. The most useful simplification tool for small functions is the Karnaugh map, a clever re-drawing of a truth table that arranges the rows so that adjacent cells differ in only one input. Groups of 1s that sit together in a Karnaugh map reveal terms you can merge, turning a long Boolean expression into a short one almost by eye. For larger functions, automated tools do the same job, but the K-map teaches the intuition: redundancy in a truth table is wasted hardware.
One gate to build them all: NAND completeness
Here is the most beautiful fact in this guide, and one that quietly shapes how real chips are manufactured. You do not actually need AND, OR, and NOT as separate building blocks. A single gate — NAND (the negation of AND) — is enough to build every other gate, and therefore every digital circuit that has ever existed. NAND is called functionally complete: with copies of just this one gate, wired cleverly, you can reproduce any truth table at all. NAND completeness is why a fabrication plant can optimize one tiny cell to perfection and trust that everything else is reachable from it.
Let's prove it isn't magic, just wiring. Watch how the three basic operations fall out of NAND alone — feed it the same input twice for NOT, then chain NANDs to recover AND and OR. Each line below is a tiny, checkable claim you could confirm with a four-row truth table.
- NOT A = A NAND A. Feed the same signal into both inputs of one NAND; the output is the inverse of A. (Check: A=1 gives 1 NAND 1 = 0; A=0 gives 0 NAND 0 = 1.)
- A AND B = NOT(A NAND B). Take a NAND, then invert its output using the NAND-as-NOT trick from step 1. Two NANDs total give you AND.
- A OR B = (NOT A) NAND (NOT B). Invert each input first, then NAND them. By De Morgan's law this equals A OR B. Three NANDs total.
- Since AND, OR, and NOT can each be built from NAND, and any function can be written using AND/OR/NOT, every digital circuit can be built from NAND alone. That is functional completeness.
From a function to a circuit (and what's still missing)
Put the pieces together and a recipe appears for building any logic you can describe. State what you want as a truth table; read off a Boolean expression; simplify it with Boolean algebra or a Karnaugh map; translate the result into gates. The circuits you get this way — where the output depends only on the current inputs, with no memory of the past — are called combinational logic, and the whole of the next guide lives here. A combinational circuit is a pure function frozen into wires: same inputs in, same outputs out, every single time.
But notice the honest gap. "No memory of the past" is a serious limitation. A combinational circuit can add two numbers, but it cannot remember the running total; it can compare two values, but it cannot count. A processor must hold its program counter, its registers, its accumulated state between clock ticks. Pure gates, which forget the instant their inputs change, can never do that on their own. We will need a new ingredient — a circuit that can hold a bit — and that ingredient comes from wiring gates into a loop so an output feeds back to an input. That feedback turns combinational logic into sequential logic, the subject of guides 3 through 5. Memory, it turns out, is just gates that talk to themselves.