Free chapter

How does a computer processor actually work?

Chapter 1 of a Doomlearning course, free to read. It’s 10 cards and takes about 5 minutes. The rest of the course is in the app.

Two women setting switches on the panels of ENIAC, a room-sized early computer
ENIAC, one of the first general-purpose electronic computers, with two of its programmers, 1946. US Army photograph.

Every photo you open, every song, every frame of every game runs through one chip a few centimetres across. It cannot see a photo or hear a song. It has switches, and each one is either on or off. Getting from that to a game is the whole story.

1. The chip that handles everything and understands none of it

A processor has no concept of a photograph. It has no concept of a number, come to that. What it has is a few billion switches, each of which is either letting current through or not.

So the first job is a translation problem. Whatever you want the machine to do has to be expressed as patterns of on and off, and any operation it performs has to be something you can build out of switches flipping other switches. That constraint is tighter than it sounds, and everything else follows from it.

2. The switch is a transistor, and it is very small

The switch in question is a transistor: a component with three connections, where voltage on one of them decides whether current flows between the other two. A switch operated by electricity instead of a finger.

That is the entire trick. It means one switch can control another, which means switches can be wired into arrangements that compute rather than just conduct.

~100bntransistors on one chipApple M-series, 2025
3nmprocess nodea marketing name, not a measurement
~5bnswitch flips per secondper transistor, at 5GHz
A modern high-end desktop chip. The count is the manufacturer's own figure; the spacing is roughly the width of a few dozen silicon atoms.

3. Two switches make a decision

Wire two transistors in series and current only flows if both are on. That arrangement answers the question “is A on AND B on?”. Wire them in parallel and you get OR. A slightly different arrangement gives NOT.

These are logic gates, and there are only a handful of them. Everything above this line in the machine is built from them, in enormous quantity.

  • ANDOutput is on only when both inputs are on. Two switches in series.
  • OROutput is on when either input is on. Two switches in parallel.
  • NOTOutput is the opposite of the input. One switch wired to invert.
Three gates. Every operation your computer performs is some arrangement of these.

4. Gates make arithmetic, which is stranger than it sounds

Take two switches, on for 1 and off for 0. Add them. 0+0 is 0, 0+1 is 1, 1+1 is 2, which in binary is 10 – a 0 with a 1 carried.

Look at the output column and the carry column separately. The carry is on only when both inputs are on: that is an AND gate. The output digit is on when exactly one input is on, which takes a slightly larger arrangement called XOR. So addition is not something a chip designer taught the machine. It is what those gates already did, once you decided to read them as numbers.

5. The processor cannot remember anything on its own

Gates have no memory. Current goes in, current comes out, and the moment the input changes the output changes with it. A machine like that can add but cannot hold the answer long enough to do anything with it.

The fix is to loop a gate’s output back into its own input, so it holds whatever state it was last pushed into. That circuit is a latch, and a row of latches is a register: a handful of numbers the processor can keep on hand while it works.

6. The clock is what stops everything happening at once

Signals take time to cross a chip, and different paths take different times. Without something to synchronise them, a circuit reads its inputs while they are still settling and gets a wrong answer for a few billionths of a second.

So a clock signal ticks across the whole chip, and nothing is allowed to move to its next state until the tick arrives. That is what the gigahertz number is: how many times a second the whole machine is permitted to take one step. 4GHz means four billion steps a second, and it also means the slowest path on the chip has a quarter of a nanosecond to finish. That deadline is why clock speeds stopped climbing.

What a higher clock buys

More steps per second, so more work done.

Straightforward speedup for anything sequential.

What it costs

Power rises faster than speed does.

Heat rises with it, and heat is the hard limit.

Every path on the chip has less time to settle.

Which is why the industry went wide instead: more cores, not faster ones.

Clock speeds plateaued around 2005. Core counts have been climbing ever since.

7. An instruction is just a number the machine agrees to obey

Somewhere in memory sits a number. Part of it is a pattern the chip is wired to recognise as “add”. Another part says which register to add. That number is an instruction, and there is nothing about it that makes it an instruction except that the processor was built to treat it as one.

The full set of patterns a given chip recognises is its instruction set. It is the boundary between hardware and software, and it is why a program built for one family of chips will not run on another.

8. The fetch-decode-execute loop, which is all it ever does

The processor keeps one number that means “where I am”: the program counter. Then it repeats four steps, forever, until you turn the power off.

  1. Fetch

    Read the instruction at the address in the program counter.

  2. Decode

    Work out which operation that pattern of bits means.

  3. Execute

    Do it: add, compare, move a number, jump somewhere else.

  4. Advance

    Move the program counter on, and start again.

Billions of times a second, for as long as the machine is on.

Word processors, weather models, the thing rendering this page. All of it is that loop, running instructions somebody arranged carefully enough.

9. Most of the time it is waiting

Reading a number from main memory takes a few hundred cycles. In that gap a 4GHz processor could have executed hundreds of instructions, and instead it sits there.

Almost every clever thing in a modern chip exists because of that gap. Caches keep recently used data close by. Pipelining starts the next instruction before the last one finishes. Branch prediction guesses which way an upcoming decision will go and runs ahead on the guess, throwing the work away if it guessed wrong. None of it makes the processor faster at arithmetic. It makes the processor better at not waiting.

10. Knowledge check

Knowledge check

Why did processor clock speeds stop increasing in the mid-2000s?

Pick one to see the answer.

What the rest of the course covers

Chapter one gets you from a switch to a running instruction. The remaining four chapters build outwards from there.

  1. Memory, and why it is a hierarchy. Registers, three levels of cache, RAM, disk — and why the difference between them is the single biggest factor in how fast software feels.
  2. Pipelining and speculation. How a chip works on several instructions at once, and how that turned into the Spectre and Meltdown security holes.
  3. Cores, threads and why more is not always faster. What parallelism actually buys you, and Amdahl’s uncomfortable law.
  4. How a chip gets made. Photolithography, why there are only three companies left who can do it, and what a 3nm process node really refers to.

Roughly forty more cards. Doomlearning pitches them at your level, and will build a course on something else entirely if you ask.

Written by AI and checked by us before publishing. If you want to go further, Ben Eater’s breadboard computer videos and But How Do It Know? by J. Clark Scott both build a working CPU from scratch.

Ask your own question

The first chapter of every course is free.

Free to try. No card needed.