How do CPU/GPU “process”?

244 views

Like they don’t have moving parts, or do they? How does it decide where to send current based on the other currents/inputs etc coming in?

In: Technology

They don’t have moving parts, but they do have electrical switches (transistors) which control the flow of current. You can think of a transistor as an electrical component with 3 parts, the input, the output and the gate. By default current can’t flow between the input and output, but by applying a voltage to the gate you can allow current to flow.
Having these electrical switches lets you build up logic gates and adding circuits which among other things all come together for form the processor.

Transistors. They are like little valves that control the flow of electricity. The on/off of the valve is controlled by the output of another valve.

When you have enough of them, you can perform logical operations on bits such as AND, OR, and NOT. I.e. 1 and 1 = 1, 1 and 0 = 0, 1 or 0 = 1, not 1 = 0, not 0 = 1, etc.

With enough of these, you can build circuits that perform basic arithmetic such as addition, subtraction, multiplication, comparisons, etc. Once you can do that, you can pretty much do any computation you want.

1 and 0. When there is electricity it is 1, when there isn’t, it’s 0. Same with RAM, that’s how everything moves information around. Hard disks store information on the same basis (sectors wear off, because they get magnetised too much), when it is magnetised at the specific sector, it is 1 and when it’s not, it’s 0. SSDs are kinda the same as RAM, but they store the information permanently (sectors wear off when they get overwritten a lot of times and its life comes to an end at some point) by charging a sector and discharging it. When charged, it’s 1, when not, it’s 0. RAM is the same, but not permanently. GPU and CPU both calculate information which is based on charged and discharged transistors afaik. The difference is the algorithm in which both processing units calculate. This is what I’ve understood so far about how computers work and I’m open to friendly suggestions and corrections even if that means this whole thing I explained is shit.

The core problem that a cpu need to solve is calculation. Its inputs has three parts: two operands and one operator.

With basic wires/diode/transistors etc we can build circuits that calculate +-*/ etc arithmetic calculations and logical operation like AND/OR/XOR/NAND etc. We can put all those circuits into our cpu. We call this whole unit ALU(Arithmetic logic unit).

So now the cpu can calculate all the possible operations results based on the two operands that we provided. But how does it decide which one to choose?

Actually, we have another circuit structure called multiplexer (MUX), which has n+1 input and 1 output. What it does is to choose one result out of those n inputs to output based on the last input value.

Then there’s control unit, which can translate the instruction we provided and tell other components like ram how to respond to the instruction we required.

To sum up: first the control unit gets the instruction, it feeds the data including two operands to ALU and a selector value to MUX. ALU then use all of it circuits to calculate all results based on those two operands without knowing operator. Then feed all those results to MUX. At the end the MUX choose one of those results and output it.