Skip to main content
Be Bitwise

What Is a CPU?

CPU Basics · Foundations track

3 min read

In this module

The Brain of the Computer

The CPU, or Central Processing Unit, is the component that actually executes the instructions that make software run. Every time you open an application, type a character, or scroll a page, the CPU is doing the underlying work. It reads instructions from memory, works out what each one means, and carries it out.

That's really what a CPU does, over and over, billions of times per second: fetch, decode, and execute instructions.

Here are the main parts you'll meet in this module and how they connect. The bold path is the one every instruction takes first: the program counter supplies an address, memory sends back the instruction stored there, and the control unit decodes it.

Don't worry about memorising it now. Each box gets its own lesson, and you can come back to this picture whenever you lose track of where something lives.

Fetch, Decode, Execute

Every program you run lives in memory as a sequence of instructions. The CPU grinds through them in a cycle:

  1. Fetch the next instruction from memory.
  2. Decode it. What's it asking for? Add two numbers? Store a value? Jump elsewhere in the program?
  3. Execute the operation.

That three-step loop is the fundamental heartbeat of every processor ever built. We'll dig into it later in this module, where saving the result gets its own fourth step, writeback, split off from execute.

You can watch it now. The simulator below holds a two-instruction program for a small teaching CPU: put 5 in register R0, then add 3 to it. Press Step once per instruction. Watch the PC register move from 0 to 2 to 4 (each instruction here is two bytes long), and watch R0 change only when an instruction executes.

For the best simulation experience, use a desktop browser.

Assembly

200ms

Registers

R00
0x0000
R10
0x0000
R20
0x0000
R30
0x0000
R40
0x0000
R50
0x0000
R60
0x0000
R70
0x0000
PC0
0x0000
SP255
0x00FF
FLAGS0x00
ZCVN

ALU

Idle

Memory

PCSPWatched
Memory contents — rows indexed by base address, columns by hex offset
Address0123456789ABCDEF
0000000000000000000000000000000000
1000000000000000000000000000000000
2000000000000000000000000000000000
3000000000000000000000000000000000
4000000000000000000000000000000000
5000000000000000000000000000000000
6000000000000000000000000000000000
7000000000000000000000000000000000
8000000000000000000000000000000000
9000000000000000000000000000000000
A000000000000000000000000000000000
B000000000000000000000000000000000
C000000000000000000000000000000000
D000000000000000000000000000000000
E000000000000000000000000000000000
F000000000000000000000000000000000

Pipeline

Cycle 0
Fetch
Decode
Execute
Writeback
→
→
→
No instruction loaded
Key Concept

The CPU operates in a continuous fetch-decode-execute cycle. It reads an instruction from memory, determines what that instruction means, and then carries it out. This cycle repeats for every single instruction a program contains.

Clock Speed and Cycles

The CPU doesn't work at a random pace. It's driven by a clock, an electrical signal that ticks at a fixed rate. Each tick is one clock cycle, and most operations take one or more cycles to finish.

Clock speed is measured in hertz. A 3 GHz processor ticks three billion times per second. Faster clocks generally mean more instructions per second, but clock speed alone doesn't tell the whole performance story. Architecture matters too.

A Brief History

The earliest computers used vacuum tubes as switches: large, hot, and notoriously unreliable. In the late 1950s, transistors displaced vacuum tubes, making computers smaller and far more dependable. The integrated circuit followed soon after (Jack Kilby's 1958 invention), packing many transistors onto a single chip. Modern CPUs cram billions of transistors onto a piece of silicon smaller than a postage stamp.

The fundamental idea hasn't budged. The CPU still fetches, decodes, and executes. The hardware just got extraordinarily fast.