Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
    • Flip-Flops and Registers
    • Counters and Timers
    • Shift Registers and LFSRs
    • Pipelining
    • Stalls, Bubbles and Hazards
      • Structural Hazard and Stall Logic
      • Pipeline Flush on Branch Resolve
      • Retiming-Friendly Coding Notes
      • Data Hazards and Forwarding
      • A Round-Robin Arbiter from a Priority Encoder
    • Retiming
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
  • Glossary and Notation
Loading lesson

‹Sequential Design
  1. Topics
  2. RTL Design
  3. Sequential Design
  4. Stalls, Bubbles and Hazards

Part 3 · Sequential · Intermediate

Stalls, Bubbles and Hazards

Stalls hold work in place, bubbles ride empty slots, and flushes discard wrong-path work.

  • 5topics
  • 5lessons

Topics in this section

  1. 1Structural Hazard and Stall Logic1 lesson
  2. 2Pipeline Flush on Branch Resolve1 lesson
  3. 3Retiming-Friendly Coding Notes1 lesson
  4. 4Data Hazards and Forwarding1 lesson
  5. 5A Round-Robin Arbiter from a Priority Encoder1 lesson
On this page

    A pipeline flows when every stage works on a different, independent item each cycle. Three events break that flow, each with a standard response.

    Event

    What it means

    Typical response

    Stall

    A stage must wait (resource busy, data not ready)

    Freeze earlier stages; hold their contents

    Bubble

    A stage holds no useful work (an invalid slot)

    Carry a valid bit so nothing downstream acts on it

    Flush

    Work already in flight must be thrown away (wrong branch)

    Clear the valid bits of the affected stages

    A three-stage pipeline with one stall: in cycle 4 Fetch and Decode hold C and B, and Execute receives a bubble instead of B

    Read each column as one cycle and each row as one stage. An item moves down one row per cycle when nothing stops it.

    • Cycle 4, Fetch and Decode: B cannot leave Decode, so both stages hold their items. That is the stall.

    • Cycle 4, Execute: nothing arrived, so Execute holds an empty slot. That is the bubble.

    • Cycles 5 and 6: the flow resumes; every item is one cycle later than it would have been, and nothing was lost.

    Lessons in this topic

    5 lessons, about 25 min

    1. 1Structural Hazard and Stall LogicYou can write the arbiter and hold logic for a shared resource, and explain how a conflict becomes a bubble downstream.3 min
    2. 2Pipeline Flush on Branch ResolveYou can write the redirect and flush for a branch resolved in execute, and estimate the average CPI penalty from the branch and taken rates.3 min
    3. 3Retiming-Friendly Coding NotesYou can write a pipeline that a synthesis tool can retime, and separate adding register ranks from the legal movement of registers.4 min
    4. 4Data Hazards and ForwardingYou can find the read-after-write pairs in an instruction sequence, write the forwarding mux with the youngest producer first, and write the load-use stall equation.7 min
    5. 5A Round-Robin Arbiter from a Priority EncoderYou can build a round-robin picker from a mask and two priority encoders or from a double-width search, add the pointer register, and trace the grant for any pointer and request vector.8 min

    Interview

    A classic: “What is a pipeline hazard? Name the three kinds.” Structural (resource conflict), data (dependency on a result not yet written), control (branch not yet resolved). This topic builds all three: a structural hazard, a control hazard and a data hazard.

    Check yourself What is the difference between a stall and a bubble?

    A stall holds work in place (the stage waits). A bubble is an empty slot travelling forward. Stalling the front of a pipe while the back keeps draining creates bubbles behind the stall.

    Revision sheet

    The whole topic on one page, taken from each lesson's Remember box. Read it before an interview, or print it.

    Structural Hazard and Stall Logic

    • Fixed priority gives the port to the older stage and stalls the front.

    • A stalled stage holds both its data and its valid bit.

    • A global stall is a high-fanout net; local valid/ready handshakes scale better.

    Pipeline Flush on Branch Resolve

    • On a taken branch, redirect the PC and clear the valid bits of all younger stages.

    • With the branch resolved in stage k, the sketch discards k - 1 instructions.

    • Flush must also stop side effects such as register writes and stores before commit.

    Retiming-Friendly Coding Notes

    • Write data every cycle and qualify its use with valid, rather than gating the data write.

    • Adding N output ranks adds N cycles of latency; extend the valid delay and the consumers.

    • Retiming moves register names, so check equivalence at the outputs.

    Data Hazards and Forwarding

    • Forward from every stage that holds a result not yet in the register file, youngest producer first.

    • A load in X has only its address; its consumer waits one cycle, then takes the data from W.

    • Check against an in-order reference model: hazard bugs give wrong values, not hangs.

    Rule of thumb: if the producer is still in the pipe, the consumer reads the pipe, not the register file.

    A Round-Robin Arbiter from a Priority Encoder

    • Mask the requests strictly above the last winner; if any survive take their first, else wrap to the first overall.

    • The double-width form searches {req, req} from bit last + 1 with dbl & ~(dbl - base) and folds the halves.

    • Load the pointer with the winner, and only when someone was granted.

    Rule of thumb: the pointer moves on a grant and only on a grant; the mask starts one above the last winner.

    Practise it

    • Mini project: a programmable timer with prescaler, compare and interrupt

    • Practice question: Structural hazard detection unit

    • Code lab: Pipeline stall logic

    • Practice question: Branch misprediction flush logic

    • Practice question: Forwarding unit for pipeline data hazards

    • Code lab: Round-robin arbiter

    • Interview: run a mock interview on this topic

    PreviousNext: Structural Hazard and Stall Logic

    Up next

    Up nextStructural Hazard and Stall Logic

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Flip-Flops and Registers
    • Counters and Timers
    • Shift Registers and LFSRs