The fetch-execute cycle describes how a computer retrieves and processes instructions, allowing it to perform tasks step by step in a continuous loop.
1. Describe the steps involved in the fetch-execute cycle and explain what happens at each stage.
Every computer, regardless of its size or purpose, uses a central processing unit (CPU) to carry out instructions. These instructions are stored in memory, and the fetch-execute cycle (also called the fetch-decode-execute cycle) is the sequence of steps that the CPU follows to retrieve and run these instructions.
The cycle repeats continuously as long as the computer is powered on. Understanding how the CPU performs this cycle is essential to understanding how computers work at a fundamental level.
The cycle has four key stages:
Fetch
Decode
Execute
Store (sometimes considered part of the Execute stage, but treated separately in this syllabus)
Each stage has specific actions that take place, involving different parts of the CPU and memory.
The Fetch Stage
Purpose of the Fetch Stage
The fetch stage involves retrieving the next instruction that the CPU needs to execute. This instruction is stored in the main memory (RAM).
Key Components Involved
Program Counter (PC): Holds the address of the next instruction.
Memory Address Register (MAR): Temporarily stores the address to be fetched.
Memory Data Register (MDR): Temporarily holds the data fetched from memory.
Current Instruction Register (CIR): Stores the instruction that is currently being decoded or executed.
Steps in the Fetch Stage
The Program Counter (PC) sends the address of the next instruction to the MAR.
The MAR places this address on the address bus, allowing the memory to access the correct location.
The instruction at that memory address is retrieved and sent to the MDR via the data bus.
The instruction is then copied into the CIR, where it will be decoded in the next stage.
The Program Counter is incremented by 1 so that it points to the next instruction to be fetched after this one.
Key Points
Fetching happens very quickly and is repeated continuously.
The address bus carries the memory address from the MAR to RAM.
The data bus carries the fetched instruction from RAM to the MDR.
The Decode Stage
Purpose of the Decode Stage
Once the instruction has been fetched, the CPU must understand what the instruction is telling it to do. This happens during the decode stage.
Key Component Involved
Control Unit (CU): The part of the CPU responsible for interpreting instructions and coordinating how data moves around the CPU.
Steps in the Decode Stage
The instruction stored in the Current Instruction Register (CIR) is passed to the Control Unit.
The Control Unit interprets (decodes) the instruction by identifying:
What action the instruction is asking for (e.g., add, load, jump)
What data is needed, and where it is located
Which components of the CPU are needed (e.g., Arithmetic Logic Unit)
Based on the type of instruction, the Control Unit prepares the necessary components for the execution stage.
Key Points
This stage does not involve any actual processing of data, only understanding the instruction.
It may involve translating the binary instruction into signals that activate specific parts of the CPU.
Some instructions may include an operand (data to be used) and an opcode (the operation to perform). These are interpreted here.
The Execute Stage
Purpose of the Execute Stage
This is where the instruction is carried out by the CPU. It may involve performing calculations, moving data, or interacting with input/output devices.
Key Component Involved
Arithmetic Logic Unit (ALU): Performs mathematical and logical operations.
Types of Operations That May Be Executed
Arithmetic calculations (e.g., addition, subtraction)
Logical comparisons (e.g., comparing two numbers)
Data transfer (e.g., loading or storing data in memory)
Control instructions (e.g., branching to a different part of the program)
Steps in the Execute Stage
The Control Unit sends signals to the appropriate components of the CPU to carry out the decoded instruction.
If it’s an arithmetic instruction, the ALU performs the operation.
If it’s a memory instruction, data may be loaded from or written to memory.
If it’s a control instruction (such as a jump or branch), the Program Counter may be updated to a new value.
Key Points
This is the only stage where actual processing occurs.
Registers may be used to temporarily hold data during execution.
The result of the operation may be stored in a register, memory, or used to update the Program Counter.
The Store Stage
Purpose of the Store Stage
After the instruction has been executed and a result has been produced, the result often needs to be stored so it can be used later.
Possible Storage Destinations
Registers (e.g., the Accumulator)
Main memory (RAM)
Steps in the Store Stage
The result of the execution is placed into the appropriate register or written back to memory.
If the instruction was to update a variable, the new value replaces the old one in memory.
If the result is needed for a future instruction, it is stored in a register for quick access.
Key Points
This step ensures that the results are not lost and can be reused.
The data bus is used again here to transfer data back to memory if necessary.
This step is essential when calculations or data manipulations must be saved.
Summary of All Stages in Sequence
To help understand how all these stages fit together, here’s a simplified bullet-point summary of the whole cycle:
Fetch:
PC → MAR (address of next instruction)
MAR → memory location
Instruction → MDR → CIR
PC is incremented
Decode:
CIR → Control Unit
Control Unit decodes instruction and prepares necessary components
Execute:
Operation is carried out (math, logic, movement, etc.)
ALU or other parts of the CPU are used
Store:
Result is stored in a register or memory
Data bus may be used to write back to RAM
Additional Key Terms
Registers
Registers are small, fast storage locations within the CPU. Important registers involved in the fetch-execute cycle include:
Program Counter (PC): Keeps track of the next instruction
Memory Address Register (MAR): Holds the address to be fetched
Memory Data Register (MDR): Holds the data fetched from memory
Current Instruction Register (CIR): Stores the current instruction
Accumulator: Often used to store results of arithmetic operations
Buses
The CPU uses special communication pathways called buses:
Address Bus: Carries memory addresses
Data Bus: Carries actual data
Control Bus: Sends control signals between CPU and other components
Real-Life Analogy
To help visualize the fetch-execute cycle, imagine a vending machine:
Fetch: You select a product (like the CPU fetching an instruction).
Decode: The machine checks your selection and matches it to a product.
Execute: The machine releases the item.
Store: You receive the item (result), and it’s stored in your hand or pocket.
Why Is the Fetch-Execute Cycle Important?
It explains how every single task in a computer is processed.
It helps students understand how programming instructions are handled at the hardware level.
It forms the foundation of how all CPUs work, from simple calculators to advanced gaming computers.
By understanding each stage and the components involved, students can appreciate how powerful and precise even basic computer systems are.
FAQ
If an error occurs during any stage of the fetch-execute cycle, the CPU may trigger an exception or interrupt, depending on the nature of the error. For example, if the memory address provided by the Program Counter points to an invalid location (one that does not contain any data), the system may generate a memory access violation error. In other cases, the instruction might be unreadable or corrupted, causing a decoding error. The CPU typically handles these errors through its control logic by halting the current process and redirecting to a special routine in memory known as an interrupt handler or exception handler. This routine may log the error, attempt to recover, or shut down the offending process. In more severe cases, the system might freeze or crash. Proper error detection and handling are essential for maintaining system stability. Without them, errors in the fetch-execute cycle could lead to data corruption or system failure.
The system clock plays a crucial role in timing the fetch-execute cycle. It generates a consistent series of electrical pulses, called clock cycles, which synchronize all operations within the CPU. Each stage of the fetch-execute cycle is timed to occur during one or more of these clock pulses. For instance, one pulse might trigger the fetch, the next the decode, and so on. A faster clock speed (measured in gigahertz, GHz) means more cycles can be completed per second, allowing the CPU to process instructions more quickly. However, increasing the clock speed can also lead to more heat and higher power consumption. The system clock ensures that all components—registers, buses, ALU, and control unit—work in harmony, with no overlap or timing conflicts. Without it, instructions could arrive at the wrong time, causing malfunctions. Therefore, the clock is fundamental in ensuring the orderly and efficient execution of the fetch-execute cycle.
The fetch-execute cycle is considered a continuous process because it runs non-stop from the moment the computer is powered on until it is shut down. The CPU doesn’t take breaks or wait for human input during this process. It moves from one instruction to the next, constantly reading from memory, interpreting commands, executing them, and storing results. This cycle enables the computer to perform all its functions—from running applications to managing input and output devices—seamlessly and efficiently. Even if an instruction tells the CPU to pause or wait, that still counts as a part of the fetch-execute cycle, because the instruction itself had to be fetched and interpreted. The process is driven by the system clock, which provides regular pulses to trigger each step in the cycle. This regularity is crucial for timing and synchronization. Without a continuous fetch-execute cycle, a computer would be unable to respond to instructions or complete any task.
Yes, in more advanced CPU architectures, multiple instructions can be in different stages of the fetch-execute cycle simultaneously. This technique is known as pipelining. Although not required knowledge at this level, understanding pipelining helps clarify how performance is improved in modern processors. In a pipelined CPU, while one instruction is being fetched, another can be decoded, and a third can be executed. Each stage is handled by a separate part of the processor, allowing several instructions to be processed at once. It’s like an assembly line: each stage of the cycle is handled in parallel, rather than sequentially. This dramatically increases the throughput of the CPU, allowing more instructions to be completed in less time. However, pipelining adds complexity and can introduce problems such as data hazards or instruction conflicts, which must be managed carefully. In a basic fetch-execute model like that used in the GCSE syllabus, only one instruction is processed at a time.
The control bus is a vital part of the CPU’s communication system, responsible for carrying control signals between the processor and other components like memory and input/output devices. During the fetch-execute cycle, the control bus manages when specific components should be active or idle. For example, when the CPU sends a signal to memory to read or write data, it uses the control bus to send a read or write command. Similarly, it uses the control bus to activate particular CPU parts during decoding or execution. These signals help synchronize actions across the CPU and the rest of the system. Unlike the address and data buses, which carry specific content (like memory addresses or binary data), the control bus carries timing and command signals. These ensure that each step of the fetch-execute cycle happens in the correct order and at the correct time. Without the control bus, there would be no way to coordinate the different actions of the cycle.
Practice Questions
Describe the steps involved in the fetch-execute cycle and explain what happens at each stage.
The fetch-execute cycle includes four main stages: fetch, decode, execute, and store. First, the Program Counter sends the memory address of the next instruction to the MAR. The instruction is fetched from RAM and moved to the MDR, then into the CIR. In the decode stage, the Control Unit interprets the instruction. During execute, the ALU or other components carry out the instruction. Finally, the result is stored in a register or memory. This cycle is repeated continuously, allowing the CPU to process instructions and manage tasks efficiently.
Explain the roles of the Program Counter, MAR, and MDR in the fetch stage of the fetch-execute cycle.
During the fetch stage, the Program Counter (PC) holds the memory address of the next instruction to be executed. This address is sent to the Memory Address Register (MAR), which places it on the address bus. The memory then uses this address to locate the instruction. The instruction is retrieved from RAM and placed into the Memory Data Register (MDR). From the MDR, the instruction is transferred to the Current Instruction Register. The PC is then incremented to point to the next instruction, preparing the CPU for the next cycle.