Computers have a brain?
No, no they don't. But they have a piece of hardware called the Central Processing Unit (CPU) that this guide is going to focus on. The CPU functions as the brain of the computer. Every action your computer (or phone, tablet, laptop etc) performs, is performed through the CPU.
Hardware-wise, the CPU is made up of loads of on-off switches called transistors, and they are assembled to create circuits that in turn control the computer and perform the actions you choose while using it. For a more in-depth guide to the hardware components that make up the CPU, check out our guide here.
Everything the CPU does follows three essential steps, called the fetch-execute cycle. These steps are as follows:
The CPU fetches an instruction from memory
It decodes these instructions so it knows what it needs to do
It then executes those steps to get the desired result
The CPU uses a language called machine code to execute these instructions, and these instructions are represented using binary. If you are yet to stumble upon the wonders of binary, check out our short guide here. The fetch execute cycle uses registers to complete the different steps, explored in detail below.
The fetch stage:
The address of the next instruction to be executed is copied rom the PC and placed into the MAR.
The control unit fetches the data from the address saved in the MAR. This data is then copied into the MDR.
The value stored in the PC is incremented, pointing to the next instruction in the program. This will be needed for the next iteration of the cycle.
The decode stage:
The control unit takes the data stored in the MDR and places it into the Current Instruction Register (CIR) and decodes it into machine code, thus allowing the CPU to know what it has to do to complete the instruction.
The execute stage:
The CPU executes the decoded instruction, still stored in the CIR. This may use other registers or hardware in the CPU (such as the ALU to perform mathematics or logic functions).
This cycle then repeats.. constantly, allowing the CPU to perform every instruction in your computer. The steps in the fetch-execute cycle can be written in register notation, a shorthand that shows the steps of the fetch execute cycle.
MAR ← [PC] MDR ← [Memory]MAR address; PC ← [PC] + 1 CIR ← [MDR] [CIR] Decoded then executed
Von Neumann Architecture
There are many types of CPU architecture, but the main one that you need to know about on the GCSE specification, is the Von Neumann Architecture. This architecture is when a computer has the data and instructions stored in the same area of memory, but are so similar that they are nyon impossible to tell apart. This gives the CPU the extra job of deciding what is data and what are instructions. Modern computers use Von Neumann Architecture in their design, and the fetch-execute cycle is a main staple of Von Neumann architecture.