The CPU and the microprocessor
The CPU (central processing unit) is the part of the computer that processes instructions and data. It carries out the instructions of every program.
It does this by fetching an instruction from memory, decoding it, then executing it. Then it repeats, billions of times a second.
A microprocessor is a CPU built as an integrated circuit on a single chip. An integrated circuit is a whole electronic circuit made on one small piece of silicon.
e.g.ExampleThe chip inside a laptop, a phone or a games console is a microprocessor. A microprocessor also sits inside a microwave oven, running its timer.
Von Neumann architecture
Most computers follow the von Neumann architecture. Its key idea is the stored program: instructions and data are both stored in the same main memory.
The CPU has a control unit (CU). The CU manages the fetch–decode–execute cycle. It decodes instructions and sends control signals to the other parts.
The CPU has an arithmetic logic unit (ALU). The ALU does calculations (such as add and subtract) and logic operations (such as comparing two numbers).
The CPU also has registers: very small, very fast stores inside the CPU. The CPU is joined to memory by three buses (sets of wires).
?Why?Keeping instructions and data in one memory means the computer can run any program you load. Change the program in memory and the same hardware does a new job.
There is a diagram for this step in the IGCSE library.
The five registers
A register holds one item at a time: an address, an instruction or a piece of data.
An address is the number of a location in memory, like a locker number in a school corridor.
!Watch outPC and MAR hold addresses. MDR and CIR hold instructions or data. Mixing these up is the most common error in FDE answers.
The three buses
The address bus carries addresses from the CPU (the MAR) to memory. It is one-way (unidirectional), because only the CPU chooses addresses.
The data bus carries data and instructions between the CPU (the MDR) and memory. It is two-way (bidirectional), because data is both read and written.
The control bus carries control signals from the control unit, such as 'read', 'write' and the clock signal. It is two-way, because devices also send signals back.
!Watch outExam answers often say 'the address bus carries data'. It carries addresses only. Data and instructions travel on the data bus.
The fetch–decode–execute cycle
Every instruction goes through the same three stages. Learn the fetch stage in order: it is worth most marks.
Fetch: the address in the PC is copied to the MAR, using the address bus. The PC is incremented (1 is added), so it points to the next instruction. The instruction at that address is sent along the data bus to the MDR. It is then copied from the MDR to the CIR.
Decode: the control unit decodes the instruction in the CIR. It works out what the instruction means and what needs to happen.
Execute: the instruction is carried out. The control unit sends signals on the control bus. If there is a calculation, the ALU does it and the result goes in the ACC. Then the cycle starts again.
e.g.ExamplePC = 100. The instruction at address 100 is LOAD 105 (put the value at address 105 into the ACC).
Fetch: 100 is copied from PC to MAR → PC becomes 101 → LOAD 105 travels from address 100 to the MDR → copied to the CIR.
Decode: the CU sees 'load the value at address 105'.
Execute: 105 goes into the MAR → the value at 105 (say 7) comes back on the data bus to the MDR → it is copied to the ACC. ACC = 7.
Try it in the toy: its tiny program starts at address 0 (LOAD 5, ADD 6, STORE 7, HALT). Press Step and watch each register change. Notice when the PC goes up by 1.
?Why?The PC is incremented during fetch, so the CPU always knows where the next instruction is, even while it is busy with the current one.
There is something to try for this step in the IGCSE library.
The instruction set
An instruction set is the list of all the instructions (commands) that a particular CPU can understand and carry out.
Each instruction is a binary code, called machine code. Examples are load, add, store, compare and jump.
The CU decodes instructions using this set. Different CPU families have different instruction sets.
e.g.ExampleMost laptops use x86 processors. Most phones use ARM processors. A program compiled for one will not run directly on the other, because their instruction sets are different.
Cores, cache and clock speed
Clock speed is the number of fetch–decode–execute cycles the CPU can do per second, measured in hertz (Hz). A 3.5 GHz CPU has 3,500,000,000 clock ticks per second. Higher clock speed means more instructions per second.
Cache is a small amount of very fast memory inside or next to the CPU. It stores instructions and data that are used often, so the CPU does not have to wait for slower RAM. More cache means fewer slow trips to RAM.
A core is a complete processing unit (with its own ALU, CU and registers). A quad-core CPU has four cores, so it can process four instructions at the same time.
?Why?All three let the CPU get through more instructions in a given time. That is what 'better performance' means.
!Watch outDoubling the cores does not double the speed. Cores must communicate with each other, and some programs cannot be split into parts. Raising clock speed also makes the CPU hotter, and cache is expensive, so there are limits.
Embedded systems
An embedded system is a small computer system built inside a larger device, to do one dedicated job.
It uses a microprocessor (or a microcontroller) and usually runs one fixed program stored in ROM.
A general-purpose computer, like a laptop, can run many different programs and do many jobs.
?Why?Embedded systems are small, cheap to mass-produce and use very little power, because they only do one job. The drawbacks: they are hard to update or change, and they can only do the task they were built for.