Scheduling dependent instructions through a CPU pipeline

A CPU executes instructions in order through a five-stage pipeline, allowing different instructions to occupy different stages during the same clock cycle. The stages are instruction fetch (IF), decode and register read (ID), execute (EX), memory access (MEM), and register write-back (WB). Each stage takes one cycle.


Five connected boxes show the instruction fetch, decode, execute, memory and write-back stages of the given CPU pipeline.


Starting with an empty pipeline, the CPU fetches the first of these instructions in cycle 1:

  1. LOAD R1, [R2] reads a memory value into R1, using the address in R2.
  2. ADD R3, R1, R4 adds R1 and R4, writing the result to R3.
  3. SUB R5, R3, R6 subtracts R6 from R3, writing the result to R5.

All three instructions pass through all five stages. Instruction and data memory accesses do not conflict, memory always responds within the MEM stage, and there are no other delays.


Compare two configurations:

  • No forwarding: an instruction reads its operands only from registers in ID. A register write occurs in the first half of WB and can be read during ID in the second half of that same cycle.
  • With forwarding: forwarding supplies a result directly to a dependent instruction's EX stage. An arithmetic result is available after EX, and a load result is available after MEM. Either can be used by an EX stage in the following cycle. These paths support both dependencies in the sequence.

When an instruction waits in ID for an operand, IF also waits while earlier instructions continue. Each extra cycle spent waiting in ID counts as one stall cycle.


Complete the table with exact integers. Report the total stall cycles and the cycle number in which the final instruction finishes WB.

ConfigurationTotal stall cyclesFinal WB cycle
No forwarding
With forwarding

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More CPU Architecture Questions: