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!
This is delightful!
Check out my summercamp by going here and checking out any of my gold-star articles!
Thank you! ^^