Caffeinated Coder
Book an appointment
Lesson 33 · Build a processor

Pipeline hazards

A pipeline overlaps instructions, one per stage, so a new one can start every clock cycle. That breaks when an instruction needs something that is not ready yet. Using the course CPU TINY-8, watch OUT r0 try to read r0 before ADD r0, r1 has written its 5, and fix it two ways: stall with bubbles, or forward the result straight back. Then see why a late JNZ decision fetches the wrong instructions, how flushing and branch prediction deal with it, and why one shared memory causes a structural hazard.

12 min10 steps5 questionsIntermediate
Fig 33 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.