What is the primary function of the CPU?
The CPU is responsible for processing all data within the computer.
What are Registers?
Registers are temporary storage/memory locations in the CPU
used for a specific purpose e.g. Program Counter (PC) , Memory Data Register (MDR) , Memory Address Register (MAR) , Current Instruction Register (CIR) , Accumulator (ACC)
What are the main components of the CPU?
The main components include the Arithmetic and Logic Unit (ALU), Control Unit (CU), and various registers.
What does the Arithmetic Logic Unit do?
Performs any arithmetic calculations and logical operations or any logical comparistons (AND, OR , NOT, XOR)
The Arithmetic Logic Unit (ALU) is made up of several components, what are they and what do they do?
Arithmetic Circuit - Carries out arithmetic calculations (add, sub, div, multiply)
Logic Circuit - Carries out logical operations (AND, OR, XOR, NOT)
Registers - Additional registers to store data
Status Flags - Includes overflow flags (if value is too large for register) or could include a zero flag (to tell if the answer is zero easily)
Buses - Used to transport data around the ALU to other parts of the CPU
What is the fetch-decode-execute cycle?
It is the process that the CPU goes through repeatedly to process instructions, consisting of fetching, decoding, and executing instructions.
Explain the FDE cycle
Fetch
Program Counter (PC) is loaded with 0
Value of PC(0) is copied to Memory Address Register(MAR)
The data from that location in memory(0) is sent across the control bus to the Memory Data Register
PC is incremented to 1
Decode
The data is sent from the MDR to the Current Instruction Register(CIR) where it is split into opcode and operand
This is sent to the Control Unit(CU) to be decoded
Execute
Which registers are used here will depend on the instruction being executed
If a value is being inputted (INP) the ACC will store the value
If a value is being outputted (OUT) this will be the value currently in the ACC
If a value is loaded from RAM (LDA) this will be sent across the data bus from RAM (in the address location in the MAR) to the MDR
If a value is to be stored (STA) it will take the value from the ACC, send it to the MDR and then send it across the data bus to RAM (to the address location in the MAR)
If a value is being added to or subtracted from another value (ADD/SUB)
If the LMC code is to branch (BRA/BRZ/BRP) the comparison will take place in the ALU
What role does the Control Unit (CU) play in the CPU?
The CU decodes instructions and controls data movement within the CPU.
What is the purpose of the Accumulator?
The Accumulator is where the values are stored temporarily, either after they’ve been inputted or loaded, or after being calculated in the ALU
What is the purpose of the Program Counter (PC)?
The Program Counter stores the address in memory of the next instruction to be fetched.
What role does the Memory Address Register (MAR) play in the CPU?
The MAR is where addresses are stored, either for where the data is being sent in memory, or where it is being fetched from
What role does the Memory Data Register (MDR) play in the CPU?
The MDR is where addresses are stored, either before it is sent to memory, or after being fetched
What role does the Current Instruction Register (CIR) play in the CPU?
When an instruction is being fetched from memory it is located here before being split into opcode and operand, after this, it will be decoded
What is Pipelining?
Pipelining is the process of carrying out multiple instructions concurrently
Each instruction will be at a different stage of the fetch-decode-execute cycle
One instruction can be fetched while the previous one is being decoded and the one before is being executed
In the case of a branch, the pipeline is flushed
How does pipelining improve processor performance?
Pipelining allows multiple instructions to be processed concurrently, reducing latency and increasing execution speed.
What is the difference between Von Neumann and Harvard architecture?
Von Neumann architecture has unified memory for both instructions and data, whereas Harvard architecture has separate memory for instructions and data.
What are the three types of buses in a CPU?
The three types of buses are the Data bus, Address bus, and Control bus.
What does the Data Bus do?
Holds data being sent to or from the CPU (Read/Write operations)
What does the Address bus do?
Holds addresses being sent to or from the CPU and RAM (Read or Write Operations)
What does the Control Bus do?
Sends signals to determine whether the other buses are in read or write mode (sends signals operations)
How is CPU performance measured?
CPU performance is measured by clock speed, number of cores, and cache.
What does cache do in a CPU?
Cache stores frequently used data and instructions for faster retrieval compared to RAM.