How do processors work? How are a bunch of transistors able to make logical decisions?

963 views

How do processors work? How are a bunch of transistors able to make logical decisions?

In: Engineering

9 Answers

Anonymous 0 Comments

It’s a bit like cells in a body. Cells form tissues, tissues forms organs, organs form a body, and so on.

A group of transistors form a logic gate. A group.of logic gates can be made to do certain basic functions like addition or subtraction. A group of these can them be designed to do more complex calculations. Add on machine language which tells these groups of logic gates what to do, and an operating system which then again tells that what to do.

If you look at it from the opposite perspective, complex operations all boil down to simple maths like addition and subtraction.

Anonymous 0 Comments

If you have the time, I highly recommend a youtube series by Ben Eater, in which he shows how a simple CPU can be made almost from bare transistors.

He shows how a few transistors (electronic switches) can be combined together to make _gates_. Gates usually have 2 inputs, and 1 output. With an XOR gate, for example, if one of the inputs is zero voltage, and the other is a positive voltage the output have a positive voltage; otherwise the output will have zero voltage.

He then shows how a few gates can be connected to make a _flip-flip_. The key to a flip-flop is that the output of the gates are connected to to inputs of other gates, in a loop. This results in the flip-flops having state: the outputs can have a voltage even when the inputs have been switched off.

Building from that, flip-flips can be combined to make _registers_, which are like tiny bits of RAM.

Gates can also be connected together in a different way to make _arithmetic logic units_ and _control logic_. Control logic, which to me was the most mysterious part of a CPU, is actually the least interesting, I found. It’s just a lot of gates wired together so that any particular machine code instruction (just a series of on/off bits) results in a particular set of components inside the CPU being activated or not.

Finally, everything is connected together with a _clock_, a device that pulses regularly, and causes all the other components to do their thing at the same time.

Anonymous 0 Comments

Transistors act like switches (transistor literally means trans-resistor, i.e. a resistor you can control, effectively controlling if the current flows or not). Switches are the easiest component to implement a logic function. Think about it: link two switches together and you have an AND gate, i.e. something that is on only if both switches are closed. Link two switches in parallel and you have an OR gate, i.e. something that is on when at least one switch is on. With this reasoning and some algorithms you can create every logic function you need.

Now processors are a lot more complex, they are made of many smaller components called buses, but the most important ones are two: the ALU and the cache memory.

ALUs are basically a big bundle of logic functions, you can add two inputs, you can compare them and many other things.

Cache memories are extremely fast but very expensive memories, made with groups of transistors called flip-flops (which are called flip-flop because the first ones made this sound, fun fact) which the processor uses to elaborate all the data you ask, by using an address system to understand what piece of memory its being used.

Basically you the programmer use a very simple language called Assembly to tell the computer exactly what to physically do when, for example, someone uses an add function.

I know it sounds confusing so I’ll make an example to help you understand: you want to make a program that sums whatever two numbers are written by the user, so you tell the processor to take the numbers from the cache memory (where they are stored once you input them, there’s a bus in the processor whose job is to interpret the user interface input, i.e. your keyboard, your monitor etc.), send them to the ALU and tell the ALU to add whatever you sent and send you back the result, which is stored in another cell of the cache and sent back to your monitor.

I simplified a lot and cut many things, but if you’re interested I can go on forever, this is what I do for a living 🙂

Anonymous 0 Comments

I highly recommend the book called “But how does it know?” it is a great introduction on the topic which quite honestly is a bit too elaborate for an ELI5.

On a very basic level a transistor does not know. It is how the transistors are arranged that lets it “know”. Its applying simple rules to them on how they act and combining these small parts into more and more complex parts, which is of course extremly oversimplified to fit ELI5.

Anonymous 0 Comments

So a processor can do everything it does by breaking the problem into a very simplified state, at it’s core this was the main break through , this happens by converting all mathematical operationd and logical operations into 4 basic operations.

The math on it is a bit above 5 grade level , but basically you use a number system where you are only allowed to use 1s and 0s , so if you wanna say 4 you will have to use a specific combination of 1 and 0 that represents that number.

Okay so far so good , now how to perform mathematical operationd on these numbers , well so e smart guy converted then into something called logical functions, like and and or. Like you can actually do any basic mathematical operation by these functions and a bit of memory.

Now comes the transistor, if you don’t know what and function is it basically checks whether we have both of the inputs as 1 ,if it outputs 1 otherwise it outputs 0, now how does a transistor implements that basically , if you put two switches by each other’s side , if and the state of the switch can be controlled by your input , then this combination would function as an ‘and ‘gates. You can do the same for other logical functions.

Anonymous 0 Comments

Because the transistors are arranged in a specific way that they can make, what appears to us humans to be, logical decisions. At the circuit level it’s just electricity flows or not depending on whether some other electricity is flowing. And ultimately it’s based on what input we gave it, ie. its programming.

Anonymous 0 Comments

Lots of great info in the replies so far, but one thing that’s missing is that the clock runs very very fast, and modern CPU’s have multiple cores (like multiple processors on one die) so that billions of “logical decisions” can take place every second.

Anonymous 0 Comments

No matter how hard I try I can’t think of an ELI5 answer.

But this 15 minute video does a great job answering this question with good visuals.

Anonymous 0 Comments

**Please read this entire message**

Your submission has been removed for the following reason(s):

* ELI5 requires that you *search the ELI5 subreddit for your topic before posting*.

Users will often either find a thread that meets their needs or find that their question might qualify for an exception to rule 7.

Please see this [wiki entry](http://www.reddit.com/r/explainlikeimfive/wiki/how_to_search) for more details (Rule 7).


If you would like this removal reviewed, please read the [detailed rules](https://www.reddit.com/r/explainlikeimfive/wiki/detailed_rules) first. **If you believe this submission was removed erroneously**, please [use this form](https://old.reddit.com/message/compose?to=%2Fr%2Fexplainlikeimfive&subject=Please%20review%20my%20thread?&message=Link:%20https://www.reddit.com/r/explainlikeimfive/comments/k156sg/-/%0A%0APlease%20answer%20the%20following%203%20questions:%0A%0A1.%20The%20concept%20I%20want%20explained:%0A%0A2.%20Link%20to%20the%20search%20you%20did%20to%20look%20for%20past%20posts%20on%20the%20ELI5%20subreddit:%0A%0A3.%20How%20is%20this%20post%20unique:) and we will review your submission.