In a 5-stage pipeline, the first instruction is an ADD, the second instruction is a LOAD that causes a 2-cycle data hazard stall, and the third instruction is a branch with a 1-cycle control hazard delay. How many clock cycles are needed to complete the execution of 5 instructions?

  • The first instruction takes 5 cycles.
  • The second instruction (LOAD) requires a 2-cycle stall, taking 7 cycles (5 + 2).
  • The third instruction (branch) introduces a 1-cycle delay, taking 8 cycles (7 + 1).
  • Each of the remaining 2 instructions takes 1 additional cycle: 5+2+1+(5−3)=10