This page assumes you have seen the five-stage pipeline only in passing. We will rebuild every word, box, and arrow the parent note leans on, starting from absolute zero.
Before any hazard can exist, we need a place where numbers are stored so instructions can read and write them.
Look at the figure: the three lockers coloured differently are the ones this one instruction touches. R2 and R3 are the sources (read from), R1 is the destination (written to). The whole wall of lockers together is called the register file.
Why does the topic need these names? Because the hazard-detection rule is a comparison of roles across two instructions: "is the destination of the earlier one equal to a source of the later one?" You cannot state that without names for the roles.
The parent note lists three flavours of data hazard. We only fix one of them on this page, so let's name all three so you know which shelf we're standing at.
Read the figure diagonally: at cycle 3, three different instructions occupy three different stages at the same time. This overlap is the whole point of pipelining — it is why it's fast. But it is also exactly why the number written in WB (cycle 5) can arrive after a later instruction already read the register in its ID (cycle 3). The overlap that gives speed also creates the RAW hazard.
How does a value computed in EX physically survive until WB, three ticks later? It sits in a buffer between the stations.
This is the key that unlocks forwarding. The answer is already sitting on a tray (EX/MEM or MEM/WB) long before it reaches the register file in WB. Forwarding is a wire that grabs the value off that tray and hands it straight back to the ALU.
Look at the figure. Each ALU input has a MUX in front of it. Normally the MUX passes the value read from the register file. But when a hazard is detected, the forwarding unit flips the switch so the MUX instead passes the value grabbed off the EX/MEM or MEM/WB tray. That switch flip is forwarding. No MUX, no forwarding — you'd have nowhere to inject the shortcut value.
Everything above assumed the produced value exists at the end of EX — true for ALU ops. Loads are different, and this is the one case forwarding cannot fully rescue.
The box below is a Mermaid diagram — a way of drawing a flow chart from text. Each A["..."] is a labelled box, and each --> is an arrow meaning "feeds into / is needed before". Read arrows as "you need the box at the tail before you can understand the box at the head".
One number, in one tiny fast box; the processor has a small fixed set of them (the register file).
Why can writing to R0 never cause a hazard?
R0 is hardwired to zero, so a write to it changes nothing real — no later instruction ever gets fresh data from it.
Which stage reads source registers, and which stage writes the destination?
ID reads sources (Rs,Rt); WB writes the destination (Rd).
What do the functions Destination(i) and Source(j) return?
Destination(i) = the destination register number (Rd) of instruction i; Source(j) = a source register number (Rs or Rt) of instruction j.
Why must the hazard check be done twice for the consumer?
The consumer has two sources Rs and Rt; the earlier result can arrive through either, so you compare the producer's destination against both.
Which three data-hazard types exist, and which one does this page fix?
RAW, WAR, WAW — and only RAW matters (and is fixed) in the in-order 5-stage pipeline.
In the full condition, what does RegWrite(i)=1 guard against?
A false hazard from a producer that doesn't actually write a register (e.g. a store or branch).
What does the equals sign mean inside a logic condition like RegWrite(i)=1?
A test for equality — "is this value 1?" (true/false) — not an assignment.
When both EX/MEM and MEM/WB hold the wanted register, which wins and why?
EX/MEM wins, because it carries the more recent result; the forwarding unit checks it first.
Why does a load-use dependency still cost one stall even with forwarding?
A load's data is only ready at the end of MEM, one cycle too late for the next instruction's EX, so one bubble is unavoidable before forwarding can supply it.