Eli5: what is inside a cpu, and how does it perform thousands of calculations a second?

1.46K views

Eli5: what is inside a cpu, and how does it perform thousands of calculations a second?

In: Technology

10 Answers

Anonymous 0 Comments

Before we had CPUs, we had devices we called “electromechanical”. Ever seen an old jukebox, the kind that has records inside? Those are very complicated machines but don’t have a computer inside of them! Even before we had electricity, we had devices that did computer-like work. For example, in the 1800s Ada Lovelace and Charles Babbage worked on a fancy calculator. Today’s CPUs are just REALLY tiny versions of the work that started there.

So how it works gets sort of complex, but it all comes back to switches. Just like light switches. Turn the switch on, and electricity flows through it. Turn the switch off, and electricity doesn’t flow through it.

Non-electric machines didn’t use electrcity, they used gears and shafts that moved when you flipped a switch. Hundreds of switches were carefully connected so if you flipped one switch, it interacted with all the others in predictable ways. Electromechanic machines (like the jukebox) are just like that. When you push buttons, electricity makes motors move that turn gears. Those gears flip switches, and that makes other motors turn, and so on. It’s very complicated, but fun to watch! CPUs and other kinds of computer circult use transistors, which are ultimately microscopic switches.

Over decades, we played with this concept of switches and found a lot of neat ways to arrange them. We gave them silly names like “latches” or “flip-flops”. We figured out we can use those arrangements to make more useful things, like an “Arithmetic Logic Unit” or ALU. For that to work, we have to say, “flipping the switches this way is how we represent numbers”, and “flipping the switches that way is how we tell it whether to add or subtract”. There are some switches called “outputs” that will turn on or off after we set number switches and whether to add or subtract. But the point of an ALU is you give it two numbers and it will do math and give you the result as a number. Neat!

If we wire up a lot of light switches and light bulbs the same way as those “circuits”, we can operate a very slow “computer” by turning switches on and off in patterns. That’s what’s happening inside your CPU at a very small scale. There are literally billions of tiny switches inside of it, carefully arranged to do exactly the right thing if you flip them in the right order. The CPU has “input” switches that tell it what it should do next, and the result shows up in the “output” switches the rest of the computer is connected to. There are millions of steps to go from “here is a picture file” to “the picture is on my monitor”, so forgive me if I don’t walk you through an example!

How’s a CPU go so fast? Well, that’s a little hard to answer but I’ll try.

One of the switches the CPU listens to is attached to a crystal. Some crystals vibrate when we charge them with electricity. The neat thing is they always vibrate at exactly the same speed. So we figured out how to make a device we call a “clock”. It has a crystal, the crystal gets electricity, and there’s some fancy wiring that turns the switch on and off every time the crystal vibrates. If the switch is off, the CPU isn’t “listening” to its other switches. That’s when all the things inside the computer set up all the switches just how they want. When the clock turns on, The CPU lets electricity in through switches, and the patterns of the ones that turn on make it do things. The end result is a bunch of other switches on the other side turn on or off. That’s the “output”.

Clocks are very fast. Most computers today “tick” more than 2 billion times per second. The only reason they can’t go faster has to do with some weird science. All that electricity makes heat, and it takes more electricity to stop the CPU from melting itself. At some point, the CPU makes so much heat we couldn’t possibly cool it. We used to be able to deal with this by making the little wires connecting all the switches smaller. But they are so small now, even weirder science happens. Think about a wire like a “lane” that electricity goes down. If the lane gets too small, it’s hard for the electricity to stay in its lane. If we make the lanes much smaller than we make them right now, that happens a lot. Since everything depends on the switches being wired together perfectly, having electricty go in the wrong lane breaks the entire system. So we’re currently a little stuck in terms of making them very much faster. We’re working on it, though. We usually find a way.

You are viewing 1 out of 10 answers, click here to view all answers.