Menu

Fetch Decode Execute Cycle

The Fetch Decode Execute Cycle

The fetch-decode-execute cycle is the continuous process the CPU carries out for every instruction. It always runs in the same order: fetch, then decode, then execute. The cycle then starts again, so it repeats for as long as a program is running.

Fetch

The CPU holds the address of the next instruction in a register. It sends that address to main memory together with a read signal, and memory returns whatever is stored at that address. The instruction is held in a register so that it is not lost, and the stored address is increased so that it now points at the instruction that follows.

Decode

The control unit interprets the instruction and works out which operation is required, such as an addition, a value to be loaded or a jump to another address. The control unit also coordinates all the activity inside the CPU, sending the control signals that tell the other components what to do and when to do it.

Execute

The instruction is carried out: data may be loaded from memory, data may be stored to memory, or an arithmetic or logical operation may be performed by the arithmetic logic unit (ALU). The ALU carries out arithmetic such as addition, subtraction, multiplication and division, and logical operations such as comparing two values to see which is larger or whether they are equal.

For example, a game takes a life away when a player falls into a pit. The fetched instruction means "subtract 1 from the number of lives". The control unit decodes it as a subtraction and directs the ALU, which works out 4 - 1 and returns 3 as the new number of lives. The CPU stores that result, then begins the cycle again with the next instruction.

Fetch, decode and execute in a loop that starts again after each instruction, with the lives example: the instruction 'subtract 1 from the number of lives' is fetched, the control unit decodes it as a subtraction, and the ALU works out 4 - 1 so 3 lives are stored.

Practise this