#CPU#Processor#HowComputersWork How does a CPU work? We go inside a desktop processor and spend one second at its pace: from a simple switch to arithmetic, memory and programs, then the clock, cores and cache that keep it working.
We build an adding machine out of marbles, turn switches into numbers, and explore what gigahertz, cores and cache mean. Memory and storage waits become enormous on the slowed clock. Branch prediction lets the processor guess what comes next and do useful work during part of a wait; a wrong guess sends it back. We also explain why that trick mattered to the Spectre security discovery.
CHAPTERS 00:00 Four small steps 01:13 Everything is a number 02:21 Building a marble adder 04:26 Memory, a clock and a program 05:59 One second at the CPU's pace 08:07 Why a CPU guesses 10:07 Fifty years of the same idea 11:37 Credits
AI Generated·May contain errors
Video Summary
AI Generated
This video explains the fundamental workings of a computer chip, revealing how simple binary switches and basic arithmetic operations—adding, comparing, copying, and jumping—combine at immense speeds to power modern computing. It explores the physical architecture of processors, the concept of clock speed, and the clever strategies chips use to handle data latency.
Inside a desktop computer, under its cooler,
sits a small square of metal.
It's only a lid.
Under it is a sliver of silicon that has never understood
a single thing you asked of it.
It can do simple arithmetic on two numbers, like adding them together.
It can compare them.
It can copy a number from one place to another.
And it can jump to a different line in its list of instructions.
Nearly everything it does is one of those four kinds of step.
And yet a chip like that is in charge of showing you
this film right now, in color with sound.
It gets away with that on speed alone.
A single core of a fast desktop chip
can tick 5 billion times every second.
If you slowed it down until each tick lasted one second,
a single blink of your eye would go on for decades.
So today, we go inside it.
We'll build a machine that adds out of marbles,
shrink it until it fits on that sliver, and
then spend one second inside the chip at its own pace.
By the end, you'll know what gigahertz,
cores, and cache really mean, and why the
chip has to guess
the future to keep up.
Start with what the chip is made of, which is switches.
Each one is a tiny valve for electric current,
and it's either letting current through
or stopping it, so each switch can stand for one of two things,
and we call them 1 and
zero. Two symbols sounds like nothing to work with,
but they're enough to write any number you
like. You count the way you always have,
except that you run out of digits after one instead of
after nine, so you carry sooner.
One, then one zero, then one one, then one zero zero. And once
you have numbers, you have everything else.
In the code nearly every computer uses, the capital
letter A is the number 65.
A color on your screen is three numbers, one each for red, green, and
blue. A sound is a long list of numbers, one after another.
To the chip, your photos and your
messages and this film are all the same stuff.
So the real question is a small one. If everything
is numbers and all the chip has is switches,
how do you get switches to do sums? A single switch
can't do much, but wire two of them in a row
and current only gets through when both are on.
Wire them side by side and it gets through when either one is on.
Each little arrangement like
that answers one yes or no question about what's coming into it,
and engineers build them into what
they call gates. In a real chip,
the simplest gate with two inputs takes four switches, two in a row
and two side by side. Now here is a whole machine that does a sum,
and you can follow every part of
it. Each of these rockers is one digit.
Leaning left, it means zero, and leaning right, it means
one. Drop a marble onto a rocker that says zero,
and it tips over to one, and the marble stays
there. Drop a marble onto a rocker that already says one,
and it tips back to zero, lets its own
marble go, and sends the new one on down to the next rocker along.
That second case is carrying.
One and one make zero, carry one,
exactly as you learned it at school, only with two digits instead
of 10. Watch it add 5 and 3. 5 is already set on the rockers.
3, in this language, is 1-1,
so it goes in as two marbles,
one for the 1's place and one for the 2's. The first tips its
rocker back and carries.
The second sets off a little cascade, one rocker after another,
and when it's over, the rockers read 1-0-0-0, which is 8.
Nothing in the machine knows what
five is, or what adding means.
It only tips and passes things on. A chip does the same job with
switches in place of rockers.
A standard design uses 28 of them to add two digits and pass along
the carry, and you line up 64
of those to add two numbers 64 digits long, which is the size a desktop
chip handles in one step.
Real chips use quicker arrangements, but the rule underneath is the one
you just watched. An adder on its own has no memory.
Change what goes in and the answer changes
with it and the old one is gone.
So the chip needs somewhere to keep a number and it makes one by
wiring two gates so that each one's output feeds the other.
A loop like that holds on to a one or
a zero for as long as the power stays on.
Next it needs something to keep everyone in step. That's
the clock, a regular pulse that reaches every part of a processor,
and on each tick, every
stored number is allowed to change once.
Without it, a billion switches would all be shouting their
answers at different moments.
And last, it needs to be told what to do. A program is nothing more
than a list of numbers sitting in memory.
The chip fetches the next one, works out which instruction
it stands for, carries it out, and moves down the list.
One real instruction set, an open one that
anybody can build a chip around,
has a basic set of just 40 instructions, designed, its authors
write, to be enough to support a modern operating system.
All but three of the 40 are one of those
four kinds of step from the start.
Simple arithmetic. Compare, copy, and jump. The jump
is the one that makes it a computer.
Compare two numbers and jump back up the list if they're
different, and you have something that repeats
a job until it's finished. Every program on your
computer is made of loops like that,
written by people and broken down into steps this small.
Now let it run at the speed it was built for.
In a fast desktop chip, a single core can tick up to
five billion times a second.
That is what five gigahertz means. One tick lasts a fifth of a
billionth of a second, and in that timeline itself,
the fastest thing there is, travels about six
centimeters, a little under two and a half inches.
Not even the length of a bank card. Numbers like
that slide straight off the mind,
so let's slow the chip down until one tick takes one whole second.
At that pace, the numbers it's working on sit in a small,
fast memory built into the chip itself.
That's the cache.
Its nearest part is a few seconds away,
its furthest and largest nearly a minute.
But even that is tiny.
Most of what the chip works with is kept
in the sticks of memory beside it on the board,
and fetching a number from there takes about eight minutes.
Ask a fast, solid-state drive for a piece of a file,
and the wait is about three days.
Ask a spinning hard disk, and it's more than a year.
Send a message from New York to London and wait for the answer,
and about 11 years go by.
A single frame of this film stays on your screen for five years.
A blink of your eye lasts anywhere from 16 years to more than 60.
And one second of your time, one ordinary second, is nearly 160 years.
If you click the mouse twice in a second,
the chip has waited about 80 years between one click and the next.
That's how something so simple manages so much.
A core never does everything at once.
It gives each job a brief turn, a little of the film, a check
on your mouse, a look for a message, and back to the film again.
And this chip has eight cores, eight of these machines side by side,
all taking turns like that at once.
Every one of those visits
is over long before you could notice it had gone.
There's one thing a chip that fast can't stand, and that's waiting.
Remember our slowed clock, where one tick lasts a second?
On it, a number from memory takes about eight minutes to arrive.
Sometimes the next instruction depends
on that number, because it's a jump.
If the number is this, go here, and otherwise go there.
The chip could simply stop and wait,
but it would lose a great deal of its speed.
So it guesses.
It looks at which way that jump went the last few times,
picks the likelier side, and carries straight on down it,
sometimes hundreds of instructions ahead.
When the number finally arrives, the chip checks.
If the guess was right, all that work is kept,
and part of that wait was spent working instead of waiting.
If it was wrong, everything it did on the guess is thrown away,
and it goes back to the fork and takes the other side.
It has lost only the weight it would have lost anyway,
plus 10 or 20 ticks clearing up.
It's right almost every time,
because programs are creatures of habit.
A loop that has gone round a thousand times
will very probably go round once more.
For years, this was just a clever way to go faster.
Then, on the 3rd of January, 2018,
a group of researchers showed that the work thrown away
after a wrong guess doesn't vanish cleanly.
It leaves traces in that small, fast memory, and by timing them,
another program could work out secrets it was never supposed to see.
They named the attack Spectre.
It reached chips from Intel, AMD, and ARM in billions of devices,
and the makers had been warned seven months before.
The answer wasn't to stop guessing,
because a chip that waits is a chip that crawls.
Systems were patched, later designs were changed
to guard what a guess is allowed to touch,
and the guessing goes on.
The first chip of this kind that anyone could buy went
on sale on the 15th of November, 1971.
It was Intel's 4004, made for a Japanese desk calculator.
It had 2,300 switches on a piece of silicon smaller than a fingernail,
and its clock ticked up to 740,000 times a second.
Intel says it had the computing power of the first electronic computer,
a machine from 1946 that filled a room.
A chip Apple put in a laptop in 2024 has 28 billion.
That's about 12 million times as many switches.
And the clock in a fast desktop chip
can run more than 6,000 times as fast.
And for all of that, look at what hasn't changed.
It adds, it compares, it copies, and it jumps.
The film you're watching, the voice you're hearing,
every video game you've ever played,
they all come down to the same thing.
Simple sums on numbers, done by switches
so quickly that they stop looking like arithmetic at all.
The chip in your phone works the same way,
and one of the newest can tick just as fast.
So the next time your computer seems slow,
think how the weight looks from the other side.
For every second you spend deciding what to click,
it has more than a century and a half to itself.