How do CPUs work?


It’s a piece of silicon. What is happening physically or chemically inside the chip to make it “process” something?

Edit: some good answers. I understand Boolean logic. But what I don’t understand is how an electrical current can ask the CPU a complex question like 6462927 x 959598 and then the CPU spits out the answer. How?

In: 8

A central processing unit is made up a *billions* of transistors. Transistors are the equivalent of a light switch. They recognize on, and off. Using a form of logic called Boolean, these transistors can be arranged into circuits. Circuits in this instance would be tiny programs (gates) such as AND, IF, OR. Using these logic gates a CPU is capable of making calculations. Those calculations can in turn be used to process anything from 3d graphics to sound.

This is a very simple overlook, if you’re interested there are many examples of people using this exact type of system in games such as Minecraft to create their own versions of a CPU, albeit simple ones.

CPUs consist of billions of tiny switches known as transistors. These transistors work exactly like a switch does, if it is on, electricity is allowed to flow through, if not, then no. But the kicker here is that the transistor is on when it gets electricity flowing to its switch wire. Overall, transistors have 3 parts, input, output, and switch, and only when the switch is powered is electricity allowed to flow from the input to the output.

Now, you can have the output power the switch parts of other transistors and as a result, you can get some logic circuits with electricity if you wire the transistors together correctly. [Here are a few basic logic gates]( but it only gets more complicated from here. You wire logic gates up together to make things such as addition calculators and many other things.

And if you have a CPU with billions of transistors, you can get quite a powerful CPU.

Nandgame is a fun puzzle games which explains how processors work by walking you through building one from the simplest circuits. highly recommended!

So I think there should be a certain distinction here. CPUs are not JUST pieces of silicon. Silicon is just the base material. On top of the silicon they fabricate extremely small devices using many different materials like Cu, Al, SiO2, doped Si, etc. The most basic building block of modern computing hardware is the transistor, which has many different physical manifestations. But the basic functional principles are the same, it acts as a switch that turns on or off. All computing is based on boolean logic, and any system can be implemented using only two identifiable states. This theory of simplification onto a boolean space is what makes simple devo es like transistors so powerful, with billions of transistors on one chip (thanks to steady progress in photolithography and depoaition technologies) it is possible to make an insane amount of complex calculations in a matter of ns.

This is all a little bit more than eli5, so to summarize: CPU chips are much more than just pieces of silicon, think of them as an extremely intricate array of carefully arranged nano-sized switches that we leverage to perform all different sorts of math.

Imagine we have a light with an on/off switch. Flick the switch one way, the light goes on, flick it the other way, the light goes off.

Now let’s play a little game. Let’s say that you are going to ask me questions, but I’m not allowed to talk. I can only answer by turning the light on or off. Could I communicate anything at all in this strange way? Yes, I could. Let’s say that if I turn the light on, that means “yes”, and if I leave it off, that means “no”.

What we’ve just done with this single light is that we’ve created a simple code for how to use it to communicate some information. What if we had more lights? Then it would be possible to come up with a more interesting code, in order to use all of them to communicate more information than just a yes or a no.

What does this have to do with how a CPU works? Well, a CPU is not *just* a piece of silicon. It actually has a huge number of incredibly tiny little on/off switches inside it, and wires connecting all of them up. People figured out how to encode information so well, using large numbers of switches, that you can actually use such a setup to do calculations and communicate anything you want.