Pipeline Control Hazards

Previously, we covered data hazards. If you write really late in the pipeline, and you need the value really early in the pipeline, then you could use the wrong register contents. The simplest thing you could do is to put in noops. It doesn't slow down the clock, but it requires knowledge to the programmer and does not have backwards compatibility. Also, the code bloats. Instead, you could put detect and stall hardware in so the code doesn't bloat. You might have to slow down the clock a little bit.

A more advanced feature is using detect and forward. You take the output from the ALU, and straight route back the input to the ALU in the next cycle. If you use add instructions, you don't have to stall with forwarding. However, you need to use a single noop with load instructions. The value is not ready early enough to get through without a stall. You have to wait until the memory instruction.

Control Hazards

These come up because of branches. If you branch, you may not know if you're going to jump, or where you're going to jump until you evaluate the expression.

Pipeline function for BEQ:

Three ways to handle: