The Central Processing Unit or CPU is the brain of the computer system. Everything the computer does is managed and organised by the CPU. The various parts that make up your computer system are all connected in some way to the central processing unit. The CPU sends both commands and data to each component and can receive back data and instructions to allow it to make decisions on what to do next.
For example, when you first turn on your computer the CPU goes through a boot sequence to get the computer started. It first talks to some Read-Only Memory (ROM) which contains some software called the BIOS (Basic Input Output System). This allows the CPU to communicate with the essential components of the computer such as the keyboard, screen, disk drives and so on.
If you watch your PC as it starts up you might notice it say, “Press F12 to enter setup”, or some other key. If you do that you will be taken into the BIOS software where you can examine and configure the various parts of your computer. WARNING: if you’re not sure what you’re doing you can stop the computer working by turning off disk drives, disabling memory, etc. So, use the BIOS setup system with care.
Once the CPU has loaded the BIOS software it then runs several checks on your system. It will communicate with and test the RAM, hard drives and other devices and after that it will communicate with your hard drive and load your operating system (Windows, Linux, MAC OS, etc.). Once the CPU has loaded your operating system software into RAM your computer is ready to use.
Throughout this whole process the CPU is continually processing data and instructions stored in memory and received mother components to make a whole computer system work.
Modern CPUs are incredibly complex but we can break them down into a number of distinct parts that are more easy to understand. Each of these parts will contain a large amount of electronic circuitry which is built into the silicon chip on which the CPU is constructed.
The control unit manages the overall operation of the CPU. Its main job is to fetch data and instructions from the computer’s memory and other components, decode what these data and instructions mean and then make sure that the correct actions are taken using the other components of the CPU to move data, update registers and communicate with input and output devices.
If the CPU needs to fetch program instructions from memory it will go through a fetch-decode-execute cycle where it uses some internal registers (internal bits of memory) to collect the data from RAM which may then pass on to the other parts of the CPU to perform the actual operations.
The arithmetic logic unit (ALU) performs all the calculations, comparisons and logical operations for the computer. It is only able to do simple arithmetic operations such as addition and subtraction. Multiplication and division are performed using repeated addition and subtraction as are all higher-level functions such as sin, log, etc.
It can perform logic operations such as AND, OR, NOT, XOR and binary shifts where it can move all the binary digits in a piece of data one space to the left or right. It can also do simple comparisons to check if numbers are equal to 0, equal to each other or if one is greater than the other.
The ALU makes use of a number of internal registers to store both the data it’s using and the results it creates. It also uses a status register to store information about what happened during the instruction it just performed. For example, did the operation result in zero as the answer, was the answer positive, etc.
Cache memory is a very fast form of memory that’s built into the CPU. Gathering data from normal system RAM is a relatively slow process. Instead of going back to RAM for every bit of information the CPU needs it keeps a copy of regularly used data in its cache. When it next needs to use this data it checks the cache and if it’s there it uses the cached version without having to go through an external memory read cycle.
Although cache memory is much faster than external RAM it’s not as fast as internal registers which are hardwired circuitry built into the CPU designed to be used while it’s actually executing instructions. Cache memory is only designed to reduce the number of read cycles for external RAM.
Most processors only have a limited amount of cache memory as it is much more expensive than system RAM. Some processors use a number of levels of cache memory with the first level (L1 cache ) being the fastest but also the smallest and subsequent levels (L2 and L3) each getting slower but larger in size.
The CPU is basically a very complicated electronic circuit. It needs a continually pulsing electronic signal to synchronise all of the operations that are going on within its various circuits. For example, when to read data, when to push the data into a register, when to collect the next instruction from RAM. This clock signal cycles between a logic 1 voltage and a logic 0 voltage and the speed of this cycling gives us the clock speed for the processor.
Faster clock speeds usually indicate that the processor is performing its operations at a faster speed than a processor with a slower clock speed. Clock speeds are measured in Hertz (Hz) though modern processors go so fast that it is easier to measure the speed in gigahertz (GHz).
In electronics a bus is simply a collection of wires that are used to transmit data and signals from one place to another. These buses can be internal to the CPU, carrying data and signals between the control unit, the arithmetic logic unit, registers, etc., or externally to the other components of your computer system such as RAM, hard drives, etc.
Most CPUs use an address bus which signals which memory location the CPU wants to talk to, a data bus which transfers data to and from sections of the computer and a control bus which contains a number of control signals that allow the CPU to synchronise and control the operation of other devices.
Registers are individual pieces of memory built directly into the CPU. They are the fastest form of memory and are used by the CPU as it decodes and executes instructions. Registers are only a few bytes big but the CPU makes use of them as temporary storage until it finally calculates the answer to an instruction which may then move out to main memory or cache memory.
6502 processor – CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=91538
i7 processor – By Eric Gaba, Wikimedia Commons user Sting, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=68126312