CPUs and architecture

In a pipeline, when the next instruction immediately uses the result of the previous one (a data hazard), which technique passes the result directly to the next instruction without waiting for it to be written to the register?

  1. AForwarding (bypassing)
  2. BVirtual memory
  3. CBranch prediction
Show answer and explanation

Answer: A. Forwarding (bypassing)

Forwarding (bypassing) routes an execution unit's output directly to a following instruction's inputs without waiting for the register write. Even if "r1 = r2 + r3" is immediately followed by "r4 = r1 × 2," no multi-cycle stall is needed. In a basic five-stage pipeline, a load result used immediately still causes a one-cycle stall because the data has not yet arrived (a load-use hazard); in deeper pipelines this stall is longer.

5-stage pipeline and a load-use hazard bubble Time (clock) 1 2 3 4 5 6 7 8 9 Instruction lw x1, 0(x2) IF ID EX MEM WB add x3, x1, x4 IF ID Bubble EX MEM WB sub x5, x6, x7 IF ID EX MEM WB or x8, x9, x10 IF ID EX MEM WB add uses x1 right after lw loads it (load-use hazard) Even with forwarding (arrow), a 1-cycle bubble remains Without stalls, one instruction completes per clock IF fetch · ID decode & register read EX execute · MEM memory access · WB write-back
5-stage pipeline and a load-use hazard bubble · View in diagrams
  • A. Correct. The result is routed directly to the next instruction.
  • B. Virtual memory manages address spaces and is not a hazard countermeasure.
  • C. Branch prediction addresses control hazards from branches.

Related calculators

Books on CPUs and architecture Ad

As an Amazon Associate I earn from qualifying purchases.

More CPUs and architecture questions

  1. Which correctly describes little-endian byte order?
  2. Which technique lets one CPU core process instructions from multiple threads at the same time to make better use of the core's execution units?
  3. In microcontrollers and similar devices, which scheme assigns peripheral registers to the same address space as memory and operates them with ordinary memory read/write instructions?
  4. What is the role of the watchdog timer built into microcontrollers?
  5. When a program calls a subroutine (function), which area is generally used to temporarily save the return address and similar information?

Comparisons in this topic