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

  • How to Use This Course
  • Reading Paths
  • Concept Map
  • How to Read the Diagrams
  • Part 0: What Is a Protocol?10
  • Part 1: Timing and Clocking11
  • Part 2: Encoding and Framing12
  • Part 3: Handshakes13
    • Valid-Only Streams
    • Wait States and Stretching
    • The Valid/Ready Handshake
    • The Valid/Ready Rules
    • Request/Acknowledge: Two-Phase and Four-Phase
    • Push and Pull
    • Global Stall or Elastic Pipeline
    • Register Slices
    • Skid Buffers
    • Bubbles and Half Throughput
    • Latency-Insensitive Design
    • Protocols Compared: Handshakes
    • Drills: Handshakes
  • Part 4: Flow Control17
  • Part 5: Transactions19
  • Part 6: Concurrency and Performance17
  • Part 7: Ordering13
  • Part 8: Sharing and Arbitration12
  • Part 9: Deadlock and Liveness13
  • Part 10: Reliability and Recovery20
  • Part 11: Bring-Up and Link Management10
  • Part 12: Power8
  • Part 13: Shared State and Coherence9
  • Part 14: Security and Isolation7
  • Part 15: Specifying and Verifying11
  • Part 16: Protocols Dissected17
  • Part 17: Capstones5
  • Part 18: Interview Preparation6
Loading lesson

‹Part 3: Handshakes
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 3: Handshakes
  4. Wait States and Stretching

Part 3 · Handshakes · Foundation (F)

Wait States and Stretching

The simplest way for a receiver to push back: hold the current transfer open until it is ready. APB wait states and I2C clock stretching, and what they cost.

On this page

    Note

    Level: Foundation (F) · Answers: Is the receiver ready?

    Before this: Valid-Only Streams, Reading Timing Diagrams

    A register block on a configuration bus answers most reads in one cycle. One of its registers, a counter in another clock domain, needs four cycles to read safely. The bus has to let that register take longer without slowing every other access, and without the processor reading a half-updated value.

    How can a target slow down one transfer without adding a whole new handshake?

    The obvious answer, and why it breaks

    One obvious answer is a fixed latency long enough for the slowest register: every read takes four cycles. Every fast register now pays for the slow one. The opposite answer is valid-only (lesson 3.1): the target must answer in one cycle, which the slow register cannot do. What is wanted sits in between: one cycle when possible, more only when needed, decided by the target, transfer by transfer.

    The idea: the target holds the transfer open

    In a wait state scheme, the initiator starts a transfer and keeps every signal steady; the target signals "done" when it is ready. Each cycle the target is not done is a wait state, and the transfer simply lasts longer. Only one transfer is in flight, so there is nothing to buffer and nothing to reorder: the initiator just waits.

    A clock-stretching scheme does the same on a bus where the initiator drives the clock: the target holds the clock line in its waiting state, and the initiator cannot advance to the next bit until the target lets go.

    Both are back-pressure, like valid/ready, but simpler: back-pressure on the current transfer only, because the protocol allows no more than one at a time.

    Watch it: an APB wait state

    This is the APB write and read from lesson 0.4, simulated. The write takes one wait state; the read takes none.

    • Slot 2: the write is in its access phase but pready is low: a wait state. Address and data must stay exactly as they are.

    • Slot 3: pready is high, so the write completes at the edge that ends slot 3, one cycle later than it could have.

    • Slots 4 and 5: the read's completer is ready immediately, so the read takes only the two mandatory cycles.

    The slow counter register from the opening would hold PREADY low for three cycles; every other register keeps answering in the minimum time.

    Clock stretching on I2C

    On an open-drain bus, a slave stretches the clock simply by holding SCL low; the master sees the line stay low and waits.

    I2C's wires are open-drain: any device can pull a line low, and the line is high only when nobody pulls it. That wired-AND behaviour is what makes stretching free: the master releases SCL to let it go high, notices it is still low, and waits. No extra signal is needed.

    The design space

    Scheme

    What it costs

    When it wins

    Fixed latency

    Every transfer pays the slowest target's time

    All targets equally fast

    Wait states (target signals done)

    One extra signal; the initiator is blocked while it waits; one transfer at a time

    Register buses: simple targets, low traffic

    Clock stretching

    Nothing extra on open-drain buses; the whole bus waits

    Slow multi-drop buses where the initiator drives the clock

    valid/ready handshakes (lesson 3.3)

    A handshake per channel

    Streams and buses that keep several transfers moving

    The limitation of wait states is the same one that makes them simple: while the target waits, everything waits. The initiator cannot start the next transfer, even to a different, fast target. Buses that need more throughput separate the request from the response (lesson 5.5) so other transfers can proceed.

    How real protocols chose

    Protocol

    Its push-back mechanism

    APB

    Wait states: the access phase lasts until the completer drives PREADY high; address, control and write data stay constant meanwhile. PREADY arrived in APB3; earlier APB had no wait states.

    I2C

    Clock stretching: a slave may hold SCL low, and the open-drain wiring makes the master wait.

    What breaks

    A completer drives PREADY low forever after a bug in its state machine (illustrative). Because APB allows any number of wait states, the processor's access never completes, the processor stalls, and the whole system hangs with no error. Wait-state protocols need a timeout somewhere: a bus monitor that ends a transfer after a maximum number of wait states and reports an error (Part 9). The scheme's simplicity, "just wait until done", is also its risk: nothing in the protocol limits how long "until" is.

    Why this matters

    Senior lens. Wait states and stretching are the right answer for low-traffic configuration paths, and the wrong one for anything on the performance path, because they block the initiator. In reviews, check that every wait-state target has a bounded worst case, that a bus timeout exists for the unbounded failure, and that nobody has put a slow target on a bus that also carries latency-critical accesses. One slow register can stall a processor's every access to that bus.

    Interview

    Asked: "How does an I2C slave slow the master down?"

    Weak answer: It sends a busy signal.

    Strong answer: By clock stretching: it holds SCL low. I2C lines are open-drain, so SCL is high only when nobody pulls it low. When the master releases SCL to make it go high, it sees the line still low and waits until the slave releases it. No extra wire is needed; the cost is that the whole bus waits.

    Follow-ups: (1) How does APB do the same thing? (2) What protects a system from a target that never finishes waiting?

    Check yourself In the APB waveform, why must PADDR and PWDATA stay constant during the wait state?

    The completer may capture them on the edge that finally completes the transfer, which it chooses. The requester does not know which edge that will be, so it must hold them until completion.

    Check yourself Why do wait states limit throughput even when most targets are fast?

    Only one transfer is in flight. While one slow target holds the transfer open, the initiator cannot start anything else, even to fast targets.

    Check yourself What property of the wiring makes I2C clock stretching need no extra signal?

    Open-drain (wired-AND) lines: any device pulling SCL low keeps it low, so the slave can hold it low against the master.

    Key takeaways

    • Wait states let the target hold the current transfer open until it is ready; clock stretching does the same when the initiator drives the clock.

    • They are back-pressure on one transfer at a time: simple, but the initiator is blocked while it waits.

    • Unbounded waiting needs a timeout somewhere, or one stuck target hangs the system.

    Keep going

    Next: Lesson 3.3, The Valid/Ready Handshake. Back-pressure that keeps transfers flowing: one signal each way and one shared rule.

    Related topics

    • Part 3 overview: Handshakes

    • Lesson 0.4: Reading Timing Diagrams

    Previous

    39 / 234

    Next: The Valid/Ready Handshake

    Up next

    Up nextThe Valid/Ready Handshake

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • The Valid/Ready Rules
    • Request/Acknowledge: Two-Phase and Four-Phase
    • Push and Pull
    clkpselpenablepwritepaddr04pwdata0a50preadyprdata0a50
    Simulation output from lesson 0.4: the completer drives PREADY low for one cycle of the write's access phase, stretching it; the read completes immediately.