Computer engineering · also Electrical engineeringLevel 5 · Research Engineer
Pipelining, hazards and the Iron Law
A processor's run time is instruction count times cycles per instruction times cycle time: the Iron Law. Pipelining splits each instruction into stages such as fetch, decode, execute, memory and write-back, so several instructions are in flight at once and the cycle can be shorter. Ideally n instructions on k stages finish in k plus n minus 1 cycles. Hazards break the ideal: data hazards when an instruction needs a result not yet written, control hazards at branches, and structural hazards when two stages need the same hardware. Forwarding, stalls and branch prediction are the classic fixes, and each one shows up as a change in CPI.
Why it mattersEvery phone and laptop processor is pipelined, and its real speed depends on how rarely hazards stall that pipeline.