Processor in Computer Adventures | World Anvil


The Central Processing Unit (a.k.a. CPU)

At the center of every computer system is a very smart and special chip: the Processor. Without it, the computer doesn't know what to do or how to do things. The Processor has two very important roles: it is a super fast calculator and the conductor of all the computer components. But how does it do all that?  

Hi! I'm one of the first CPUs that was available for everyone, the Intel 4004. Back in my days, CPU's had 16 or 32 pins that allowed us to communicate with components. Nowadays, some CPUs have 1700 pins to talk with the rest of the computer!


Under the Hood

At the lowest level, the Processor consists of one fundamental electronic component: the transistor. Of course, a CPU doesn't have just one transistor, it has many, many, many of them. The function of a transistor is fairly simple, it either opens or closes an electrical circuit based on the amount of energy flowing through. They are very useful for the CPU, because they are insanely fast. Even the slightest difference in energy can cause them to switch back and forth.   Combining these transistors, allow us to create what they call "logic gates". These clusters of transistors can make certain decisions based on the current going through them as a group. Let's look at the logic gate AND, for example. Imagine there are two buttons (which are manual transistors, in a sense) connected to a lightbulb. Press one button, and nothing happens. Press both buttons at the same time, and the light turns on. So, for an AND gate to open, all transistors in the cluster must allow power through. If one of the transistors does not, the gate closes.   There are a few base varieties of these logic gates that can be combined into more advanced logic gates to make even more complex circuits.
The First Processor

Intel 4004


Executor of Instructions

Current Popular Brands



History of Processors

Favourite Joke

Why did the CPU kill the Operating System?
It was executing instructions.

So, at it's base, I'm a combination of many logic gates made up of transistors! That explains why my younger brothers got so much faster with the years! I have "just" 2300 transistors that have to do all the calculations. Meanwhile, one of my younger cousins, the AMD Ryzen Threadripper 3990X, has almost 40 billion of them.


Internal Components

With the logic gates, Processor architects build the internal components of the CPU that makes it do things. The internal workings of a CPU is a very complex subject and requires a fair few years of studying, so do not get discouraged if it is difficult. The next part attempts to explain the internal workings of a CPU in the simplest way possible. A fair note, the schematics shown are examples of CPU design. Just like there are many varieties of buildings throughout a city, there are many different ways to design CPUs so these simplified schematics don't apply to all processors.   Here is a very simplified schematic of a processor. It has three main components and their lines of communications. Each component has an important part to play in making a CPU function. Let's go over them, step by step.  

Register: The CPUs Memory

This part of the CPU stores data temporarily. Registers contain the values that the CPU needs to execute functions, or the input that it needs to do its calculations. It is a fairly small, but important part of the processor. You might have seen that processors have a "size", like 64-bit or 32-bit. This size refers to the capacity of the registers. A 64-bit CPU has registers that are 64 bits long. If, for some reason, the data input is larger than a CPU's register, the processor has some neat tricks up its sleeve to prevent things from breaking.  

ALU: The Calculator

ALU stands for Arithmatic Logic Unit, which is just a very fancy word for calculator. All those logic gates from earlier play the biggest role in this part of the CPU. The ALU needs three inputs to start calculating, just like any other simple equation! It needs two numbers that it needs to calculate with and the exact operation (or type of calculation) it needs to perform. The Control Unit let's the ALU know what operation it should perform, by giving it the OPCODE which is short for OPeration CODE. The register provides the ALU with the input data.   So, let's say we want to know what "1 + 2" equals, the numbers 1 and 2 would be the input values provided by the register. The '+' is the OPCODE that the ALU would get from the Control Unit. In turn, the ALU give the output of the calculation back to the Control Unit. That is literally all an ALU does, get input, get OPCODE, calculate, and return the output.  

Control Unit: The Conductor

As the conductor of the computer orchestra, the Control Unit is also one of the key components within the CPU. It is one of the few, if not the only, part of the CPU that communicates to the computer components outside and the internal components inside the processor. It translates the languages from other components into the "CPU language" and vice versa to direct all the components. So, whenever you run a program, it is the Control Unit that makes sure to translate and execute every instruction in the right order and at the correct time.  

This was the simplest way to explain my most important components. Of course, it is much more complex than that. So, if you want to learn even more about my internals, follow me!

Learn More!
There are many more internal components to a Processor. As a reminder, this is a complex subject! Even this more advanced schematic is still a very simple annotation of what is inside a CPU. If you want to learn even more about processor architecture and truly want to dive deeper into the subject, there are a couple online courses to look into. For now, let's look at this slightly more advanced schematic.  
Communication Bus
Computer components, whether they are the major ones like a processor or a hard drive or smaller internal components, rarely communicate directly to one another, just like we humans cannot teleport from one place to another (yet, sadly enough). Instead, we take a car (or another method of transportation), get on the road, and drive to our destination. In the same fashion, computer data in the form of Bits travel over the communication bus to their destination component which uses the data.   There are many types of busses in a computer, each with their specific use case. The CPU has two busses that it uses to get all the basic tasks done.   Internal Data Bus
This bus only runs within the processor itself. The internal components communicate with one another over this bus, from setting registers with specific values to returning the output of the ALU back to the control unit. No component outside the CPU read or even see this bus.  
Address Bus
The address bus is the highway between the processor and the Random Access Memory. This type of memory doesn't store any data permanently like a hard disk, but it is incredibly fast at finding and storing where certain bits and bytes of data are. It holds the addresses to these chunks of data and that is why their communication bus is often refered to as the address bus.   Remember the function of the ALU? It needs an OPCODE to know what to do with the two input values and gets this from the Control Unit. The Control Unit itself does not know where to find this OPCODE, so it asks RAM for the location. Then it fetches the data from that location into another register. With the OPCODE stored in a register, the Control Unit can then send the OPCODE to the ALU to perform its calculation.  
ACC and TMP Registers
The communication bus has the big advantage that sending data over it is super fast. However, the equally big disadvantage is that only one set of data can be thrown over the bus at a time. As you now know, the ALU has two inputs in order to start calculating, but both inputs cannot be sent over the bus at the same time. So, the smart people who designed the Intel 4004 added an extra register, the TMP register. As the name would suggest, this register only holds temporary information that the ALU would need to do its work.   The TMP register made it possible to do the simple calculations, because the bus can now provide both inputs to the ALU at the same time. However, sometimes a calculation has multiple steps that build upon intermediary results. Instead of saving these intermediary results in a regular register, which then sends that same data back to the ALU, the same smart CPU designers added an additional register just before the second input of the ALU. The accumulator is the register that stores intermediary results which the ALU can use immediately, removing the extra step of using regular registers.  
Flags (F/F')
Not all OPCODEs given to the ALU are "calculation codes". Sometimes, programmers want to check certain conditions before executing specific code. For example, there is a counter that only counts to ten. Every time this counter program runs, it will check if the current value is less than 10. It adds one if it is less, but if the value is already 10 the program shuts down.   The ALU processes these compare commands too, but the output would be odd. There is no way to signal that current value is more or less than 10 with just an 8-bit output system, which is why there are flags. Flags are very specific bits that the ALU can turn on or off to indicate to the Control Unit what the outcome of a comparison is. Based on these flags, the control unit can determine the next step, whether to send a new instruction to the ALU to add 1, or to send an instruction to quit the program.  

Have you had a keen look at the schematic? Do you see it too? Our schematic drawer and writer made a little oopsie!
Of course, the ALU does not communicate its output and flags directly to the Control Unit. They, too, go over the bus.
Give yourself a pat on the back if you spotted that little mistake, you're awesome!



Please Login in order to comment!
Oct 14, 2023 03:41 by Ademal

This is delightful!

Check out my summercamp by going here and checking out any of my gold-star articles!

Oct 16, 2023 11:19

Thank you! ^^

What do you want to discover in Computer Adventures?
Oct 16, 2023 13:54

Ah, I see. I see~

Nov 5, 2023 13:01

Hehe, I hope you understand, too ^^

What do you want to discover in Computer Adventures?
Oct 16, 2023 15:30 by Dr Emily Vair-Turnbull

I love this so much. I think I understand slightly more than I did before, which wasn't very much. :D

Emy x   Etrea | Vazdimet
Nov 5, 2023 13:02

Thank youu! <3 I hope I can continue to make you understand other computer thingies in the future :D

What do you want to discover in Computer Adventures?
Powered by World Anvil