# How does a processor work?

25 views
0

How does a processor work?

In: 1

Assuming you mean computer processor (CPU, central processing unit), there’s not a good way to ELI5 that.

Electricity controls logic gates, and there are upwards of 100 million of them in a CPU.

So, by controlling how much electricity goes where in a processor, is like asking the processor to remember just a little bit of information, but a really large number of times. Then you can ask it for the answer when it manages all those tiny bits of information as a whole.

We need to go to bit of an ELI5 rabbit hole for that but lets give it a shot. We need to sequentially ELI5 following questions
1. ELI5: what is and how does transistor work
2. ELI5: what is and how do digital logic gates and multivibrators work
3. ELI5: what is and how do Arithmetic logic circuits work
4. ELI5: what is and how does ALU
5. ELI5: what is and how does CPU work

So lets get cracking.
1. Transistor is a one of the fundamental semi-conductive electronic component. Meaning, that whether it allows electricity to flow, depends on something. For transistor, which has three terminals (legs) it requires specified voltage (for unipolar transistor) or current (for bipolar transistors) applied to one terminal, in order for electricity to flow through the other two.

2. Logical gate is a number of transistors put together in such a way, that input signal or signals will cause a defined output. For example an AND gate will output 1 if both inputs are 1, and 0 if inputs are 00 01 or 10. NAND does the opposite it returns 1 in all cases except when inputs are 11. Bi-stable Multivibrator, is also a set of transistors, which is capable of keeping a set level, it is essentially a 1-bit memory. There are other types of multivibrators, but lets not get too carried away.

3. Arithmetic logic circuit is a number of logical gates, which when put together perform a most basic math operations on digital data. for example a half adder, will accept two bits of data and add them. Ie 0+0=0, 0+1 = 1, 1+0 = 1 and 1+1 = 0 As you can see the 1+1 is not quite right, it is not 0 but we lack the ability to express the result. We need the half adder to tell us, that the result is bigger then 1 bit. And here comes magic, we can link multiple half adders together and use that to add bigger numbers and get bigger results. In same way divider, multipliers… can be constructed. By linking multiple simple arithmetic logic circuit we get ability to perform mathematical operations on “normal” numbers as they can be expressed in these bits.

4. When we take number of Arithmetic logic circuits and logic gates and put them together we get an Arithmetic-Logic Unit, this core of the processors accepts two kind of inputs input data (for example two numbers) and an instruction what to do with these data. The instruction changes the way the data flows into the ALU, and what circuits are used. So when you request addition the data will be lead to the set of arithmetic logic circuits, which can add numbers and outputs the result.

5. Finally a CPU is a complex mix of circuits and memory. What it does, is looks at the code (which is made of 0s and 0s) , the code tells it to where in the memory are the data, and what operation should be done with them and where to then save the result. CPU then sends this instruction to ALU as well as the data and then stores the results where the code requested. So for example if the code says

Multiply Data in Memory1 with data in Memory1 and save it to Memory3
Multiply Data in Memory2 with data in Memory2 and save it to Memory4
Add Data in Memory3 with data in Memory4 and save it to Memory5
Apply Square root on Data in Memory5 with and save it to Memory6

You will have solved the Pythagoras theorem using numbers in Memory1 and Memory2 and saved it to Memory6 as a result of a^2 + b^2 = c^2.