Skip to content
Lesson 5 of 36 ยท Chips from zero

How does a CPU work?

A CPU repeats a simple loop: fetch an instruction, decode it, do it, save the result, billions of times each second.

  1. 1. fetchget it2. decoderead it3. executedo it4. write backsave it

    1. Four steps, over and over

    Like a cook with a recipe, the CPU fetches an instruction, decodes it, executes it and writes back the result. Unlike a cook, it does not think: the program decides every step.

  2. fetchDdecodeCexecuteBwrite backAeach tick, all move one step4 instructions at onceA started first, nearly done

    2. Several at once

    To go faster, the CPU works on several instructions at once, each at a different step. This is a pipeline: each tick, every instruction moves forward one step, like dishes moving from station to station in one kitchen.

  3. copiescorecacheRAMnear: fastfar: slower

    3. A shelf beside the stove

    A cache is a small, fast memory beside the core, like a shelf by the stove. It holds copies of recent data, so the core looks there first, before the slower main memory (RAM).

  4. clock ticksmost powerclock stoppedless powerswitched offalmost none

    4. Resting when idle

    When a core has no work, it stops its clock or switches off to save power. It wakes up quickly when work arrives.

Words to know

Pipeline
Steps lined up so several instructions are in progress at once.
Clock
A steady beat that keeps every step in time. 4 GHz (gigahertz) means 4 billion ticks a second.
Cache
A small, fast memory next to the core that keeps copies of recently used data.
RAM (random access memory)
The main memory: big, but slower than a cache.

Where you meet it at work

Chips manage power on top of this loop: busy cores tick faster, and idle cores stop their clocks or switch off. Testers check that both happen at the right time.

Check yourself

What four steps does a CPU repeat for every instruction?Think first, then tap to see the answer.

Fetch, decode, execute and write back.