A Data Dependency in a Processor Pipeline

One instruction depends on another when it needs a value the earlier instruction has yet to produce.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Show a two-instruction dependency
  2. Preserve the intended value
  3. Match a consumer's read to a producer's readiness
  4. Check the actual data dependence at each operand

Show a two-instruction dependency

An addition writes register R. The very next instruction reads R for a comparison. Issuing both operations does not make the updated R immediately available. The register stores one visible version under the processor's update rules.

Preserve the intended value

A design may forward the result directly between stages or stall until it can be read safely. Latency and throughput distinguish the time to produce that value from the ideal rate for unrelated instructions.[1]

Match a consumer's read to a producer's readiness

Consider adding R1 and R2 into R3, then multiplying R3 by R4. The latter depends on the new R3 value. If its execution needs that value before writeback, a forwarding path or stall may supply the correct operand. See instruction latency and throughput.

ADD produces R3 at end of cycle 3
MUL needs R3 during execution
With access beginning cycle 4 via forwarding, it may start then
With no forwarding, wait for register write timing

Check the actual data dependence at each operand

An unrelated instruction using R5 can proceed earlier if resources permit. A branch or memory effect introduces additional constraints. Choose one dependent sequence and one with identical instruction kinds but disjoint registers.

References

  1. Noam Nisan and Shimon Schocken, From Nand to Tetris: Course Projects ↩