Menu

Stored Program Computers

Fetch-Decode-Execute Cycle

The fetch-decode-execute cycle is the continuous process a CPU uses to run a program: it takes one instruction at a time from main memory, works out what it means and carries it out. Under the stored program concept, the CPU fetches each instruction from main memory in this way.

Fetch

During fetch, the CPU keeps the address of the next instruction in one of its registers, small and very fast stores inside the CPU. That address is sent along the address bus to main memory, and the control bus carries the signal to read it. The instruction stored at that address travels back along the data bus and is placed in a register in the CPU, while the stored address is updated to point to the next instruction.

Fetch, decode and execute in a loop that repeats. In fetch, the CPU sends the address of the next instruction to main memory along the address bus, the instruction comes back along the data bus and is held in a register, and the address is updated to point to the next instruction.

Decode and execute

During decode, the control unit interprets the fetched instruction to work out what must happen. During execute, the CPU carries the instruction out: the arithmetic logic unit (ALU) may perform a calculation, data may be moved between registers, or main memory may be read from or written to. Any result produced is stored in a register or written back to main memory.

The cycle repeats

The three stages form a continuous loop. Once one instruction has been executed, the CPU fetches the next instruction from the address it has stored, and the cycle starts again. Each cycle is extremely short, so a processor can complete many millions of cycles every second while a program is running.

Practise this