How a CPU Works: From a Single Transistor to Billions of Switches

The Chip in Your Phone Contains More Switches Than There Are People Who Have Ever Lived

A modern smartphone processor holds somewhere in the region of 15 to 20 billion transistors on a piece of silicon smaller than a postage stamp, and each of those transistors can switch on or off several billion times a second. Every photograph you take, every word you type and every frame of video you watch is reduced to a storm of those switches flipping between two states. Yet the design underneath has barely changed since 1945: fetch an instruction from memory, work out what it means, carry it out, store the result, repeat. What has changed is the scale, the speed and an extraordinary set of tricks for doing many of those steps at once. This explainer takes a CPU apart from the transistor upwards.

Illustration of a silicon processor chip glowing blue, its surface opening into a vast grid of microscopic circuitry.
More switches than there are people who have ever lived, on one chip.

It covers what a transistor is and how it becomes logic, how a processor is organised, what clock speed, cores and cache actually mean, why chips got faster for forty years and then stopped, and what the numbers on a spec sheet are telling you. No electronics background is needed.

From Transistor to Logic Gate

A transistor is a switch with no moving parts. In the type used in processors, the MOSFET, a small voltage applied to a terminal called the gate either allows or blocks current flowing between two other terminals, the source and the drain. Current flowing is a 1; current blocked is a 0. That is the whole of digital electronics: a signal that is either high or low, and a device that can turn one signal into another.

Wire a few transistors together and you get a logic gate. A NAND gate, built from four transistors, outputs 0 only when both its inputs are 1. Every other gate, AND, OR, NOT, XOR, can be built from NANDs, and from gates you can build anything: a circuit that adds two numbers, one that compares them, one that stores a bit and holds it until told to change. A one-bit adder is a handful of gates. A circuit that adds two 64-bit numbers is a few hundred. A processor is billions of these, arranged into a small number of functional blocks.

The Anatomy of a Processor

Almost every CPU, from the one in a washing machine to the one in a data centre, follows the layout described by John von Neumann in 1945: a processing unit, a control unit, memory holding both instructions and data, and a bus connecting them.

The arithmetic logic unit

The ALU does the sums: addition, subtraction, comparison, bitwise operations. Modern processors have several, plus separate floating-point units for decimal arithmetic and vector units that perform the same operation on many numbers at once, which is what makes video and image processing fast.

Registers

Registers are a handful of tiny, extremely fast storage slots inside the processor itself, each holding one number. An instruction such as "add the contents of register 1 to register 2" runs in a single clock cycle because the data is already there. Getting data into registers from main memory is where most of a processor's time goes.

The control unit

The control unit reads each instruction, decodes what it is asking for, and sets the switches that route data through the right parts of the chip. The instructions it understands are defined by the instruction set architecture: x86, used by Intel and AMD in most PCs and servers, or Arm, used in nearly every phone and in Apple's Mac processors. A program compiled for one will not run on the other without translation.

Cache

Main memory, RAM, is far away from the processor in electronic terms: fetching a value takes around 100 nanoseconds, during which a 4 GHz processor could have done 400 operations. Cache is a small amount of very fast memory on the chip itself that keeps copies of recently used data. There are usually three levels: L1, a few tens of kilobytes per core, reached in about a nanosecond; L2, a few hundred kilobytes to a few megabytes; and L3, tens of megabytes shared between cores. The processor guesses what you will need next and fetches it early. When it guesses right, which is most of the time, the program flies; when it guesses wrong, it stalls.

The Fetch-Decode-Execute Cycle

Everything a processor does is a loop. A register called the program counter holds the address of the next instruction. The processor fetches the instruction from that address, decodes it, executes it, writes back any result, and advances the counter. Branch instructions, "if this is true, jump to that address", change the counter directly; they are how loops and decisions happen.

Done naively, one instruction at a time, this is slow, because each step uses a different part of the chip and the others sit idle. The solution, pipelining, treats the cycle like a car assembly line: while one instruction is being executed, the next is being decoded and the one after is being fetched. A modern processor may have a pipeline 15 to 20 stages deep, with several instructions in flight at every stage.

Clock Speed: What the GHz Figure Means

The clock is a signal that ticks at a fixed rate, and every stage of the pipeline advances one step per tick. A 3.5 GHz processor ticks 3.5 billion times a second. Higher clock speed means more steps per second, but it is not the whole story, because processors differ enormously in how much work they do per tick. A chip that can execute six instructions per cycle at 3 GHz outperforms one that manages two at 4 GHz. For this reason, comparing clock speeds across different processor families tells you almost nothing.

Clock speeds rose from under 1 MHz in the 1970s to around 3 GHz by 2004 and then stopped rising. The reason is heat. Every switching transistor dissipates energy, and power rises steeply with frequency and voltage. Beyond roughly 4 to 5 GHz, a desktop chip cannot be cooled at a sensible cost, and the industry turned to other ways of getting faster.

Doing More Per Tick: Superscalar, Out-of-Order and Speculative Execution

A superscalar processor has several execution units and can issue multiple instructions per cycle if they do not depend on each other. Out-of-order execution lets the chip run instructions in whatever order their data becomes available, rather than the order the program lists them, and then reassemble the results so the program cannot tell. Branch prediction guesses which way an "if" will go before the condition is known and starts executing down that path; modern predictors are right well over 95 per cent of the time, and when they are wrong the wasted work is thrown away.

These tricks are why a single core today does far more per clock cycle than a core from 2004 at the same frequency. They are also the source of the Spectre and Meltdown security flaws disclosed in 2018, which exploited the fact that speculative work leaves traces in the cache even when it is discarded.

Cores: Why Your Processor Is Really Several Processors

When clock speed hit the wall, chipmakers began putting multiple complete processors, cores, on one chip. A dual-core chip appeared in mainstream PCs in 2005; today a phone has eight cores, a desktop eight to sixteen, and a server chip may have over a hundred. Each core runs its own instruction stream. The gain is real only if the software can split its work into independent pieces: a video encoder or a web browser with many tabs can, a single-threaded game loop often cannot. Many chips also use hyper-threading or simultaneous multithreading, in which one core juggles two instruction streams to fill gaps when one is waiting for memory.

Phone processors typically mix large, fast cores for demanding tasks with small, efficient cores for background work, switching between them to save battery. Apple's M-series and the latest Intel desktop chips use the same idea.

How Chips Are Made

A processor begins as a disc of extremely pure silicon, a wafer, 300 millimetres across. Layers of material are deposited, patterned by shining ultraviolet light through masks onto a light-sensitive coating, and etched away, dozens of times over, to build up transistors and the wiring that connects them. The most advanced factories, run by TSMC in Taiwan, Samsung in South Korea and Intel, use extreme ultraviolet lithography machines made by a single Dutch company, ASML, each costing well over $150 million. Process names such as "3 nanometre" no longer describe a physical dimension; they are marketing generations, though the transistors in them are indeed only tens of atoms across.

Gordon Moore's 1965 observation that the number of transistors on a chip doubled roughly every two years held for five decades. It has slowed, and the industry now gains performance increasingly through design, specialised accelerators and stacking chips in three dimensions rather than through shrinking alone.

CPU, GPU, NPU: Who Does What

A CPU is a generalist: a few powerful cores designed to run any program fast, with heavy investment in prediction and caching. A GPU is a specialist: thousands of simple cores that all do the same thing to different data at once, which is what drawing pixels and multiplying matrices require. That is why graphics chips became the engine of machine learning. Neural processing units, now in most phones and laptops, go further and are built only for the arithmetic of neural networks. The CPU still runs the operating system and coordinates everything; the others are tools it hands work to.

Reading a Spec Sheet

  • Cores and threads: how many independent instruction streams the chip can run. More helps with multitasking and parallel workloads, less with single-threaded ones.
  • Base and boost clock: the guaranteed and the maximum frequency. Boost is used briefly when temperature and power allow.
  • Cache: larger L2 and L3 caches help workloads with large data sets, such as games and databases.
  • TDP: thermal design power, roughly how much heat the cooling system must handle at sustained load. A 15-watt laptop chip and a 125-watt desktop chip are built to different goals.
  • Process node: newer generally means more efficient, but compare within a manufacturer, not across them.

Frequently Asked Questions

What is the difference between a CPU and a processor?

None in everyday use. "Processor" sometimes refers to the whole chip package, which in a phone includes the CPU, GPU, modem, memory controller and more on one piece of silicon, known as a system on a chip.

Does a higher clock speed always mean faster?

Only within the same processor family. Across families, instructions per cycle matters as much, and for many tasks memory speed and cache matter more than either.

Why does my computer get hot?

Every switching transistor converts a little electrical energy into heat. Billions of them switching billions of times a second add up to tens or hundreds of watts in a space the size of a coin, which must be carried away by a heatsink and fan.

What is a 64-bit processor?

One whose registers and memory addresses are 64 bits wide, allowing it to work with very large numbers directly and to address far more than the 4 gigabytes of memory a 32-bit design could reach. Almost every processor sold today is 64-bit.

Sources

Next Reads

Previous
Previous

Trump Family Has at Least 10 Financial Links to Nvidia, New York Times Finds, as Jensen Huang Faces Congress Behind Closed Doors

Next
Next

How the Internet Actually Works: Packets, DNS and Cables Under the Sea