What is a CPU?
A CPU (Central Processing Unit) is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logic, controlling, and input/output (I/O) operations specified by the instructions
There are several components to the CPU. These include:
- Control Unit – Controls the flow of data in the CPU
- Memory Unit – Stores data
- Buses – Wires connecting the components which enable the transfer of data, address details and control signals
- Arithmetic Logic Unit – Does any arithmetic(add/subtract/multiply/divide) and Logic(comparing values) operations
Computers need to take an input, process it and then output a result. From this we know there are 4 main stages or parts :
This is done using the fetch execute cycle.
What is the fetch-execute cycle?
The computer will fetch an instruction from memory
It will then decode it
Finally it will execute it
What are the components of a CPU?
There are 8 key components of a CPU
- Program counter
- Memory address Register
- Memory Data Register
- Current Instruction Register
- Arithmetic Logic Unit
- Control Unit
- Interrupt Register
There are 3 buses
- Control Bus
- Data Bus
- Address Bus
How does the CPU work?
- The Program Counter fetches the address of the next instruction to be processed.
- This is passed to the memory address register to hold
- The memory address register will pass this on the address bus to primary memory(usually RAM)
- Primary memory will look for the address and collect the contents. This will be data or an instruction
- This will be put on the data bus to the memory data register to hold
- If it is data it is passed to the arithmetic logic unit to have operations applied -> Results are stored in the accumulator
- If it is an instruction it is passed to the current instruction register -> passed to the decode unit to be decoded
Note: The control unit controls the flow of data