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
  • Part 4: Flow Control17
    • Why Flow Control
    • On/Off Flow Control
    • Credit-Based Flow Control
    • Credit Initialisation
    • The Credit Loop and Buffer Sizing
    • Credit Classes and Pools
    • Credit Return Latency and Batching
    • Credit Bugs
    • Window Flow Control
    • Rate-Based Shaping
    • Hop-by-Hop or End-to-End
    • Lossless or Lossy
    • Switching Modes
    • Head-of-Line Blocking
    • Choosing Flow Control
    • Protocols Compared: Flow Control
    • Drills: Flow Control
  • 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 4: Flow Control
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 4: Flow Control
  4. Switching Modes

Part 4 · Flow Control · Senior (S)

Switching Modes

Store-and-forward, cut-through and wormhole switching: when a router may start forwarding a packet, what that does to latency, and how much buffering each mode needs.

On this page

    Note

    Level: Senior (S) · Answers: How much may I send before I hear back?

    Before this: Lossless or Lossy, Flits, Phits and Packing

    An on-chip network moves 256-byte packets across four routers. Its first version took 72 cycles per packet with the network idle, three times what the designers expected from the wire and router delays. Every router was fast. The time went into waiting for something that does not need to be waited for.

    When may a router start sending a packet on, and what does the choice cost?

    The obvious answer, and why it breaks

    The obvious design receives a whole packet, checks it, and only then forwards it. That is simple and safe: the router knows the packet is complete and intact before passing it on. But every router then pays the full time to receive the packet, its serialisation time, and over many hops those add up. A router only needs the header to decide where a packet goes; the rest can follow.

    The idea: three switching modes

    Mode

    A router forwards

    Buffer per router

    If the next hop is blocked

    Store-and-forward

    After the whole packet has arrived

    A whole packet

    The packet waits, complete, in this router

    Cut-through (virtual cut-through)

    As soon as the header arrives

    A whole packet (used only when blocked)

    The rest of the packet is collected here, then it waits

    Wormhole

    As soon as the header arrives

    A few flits

    The packet stops where it is, spread over several routers

    With H hops, a packet of L flits at one flit per cycle, and r cycles of routing per router, the latencies with no contention are:

    Tstore-and-forward​=H(r+L),Tcut-through​=Twormhole​=Hr+L

    Store-and-forward pays the serialisation L at every hop; cut-through and wormhole pay it once. With no contention, cut-through and wormhole behave identically. They differ only in what happens when a packet is blocked: cut-through needs room for the whole packet in each router so it can collect it there, while wormhole saves that buffering and leaves the packet strung across the path, holding links that other packets may need.

    Build it: latency of each mode

    The model evaluates both formulas for a 256-byte packet of sixteen 16-byte flits across four hops, with two cycles of routing per router.

    example.py
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    """Latency of a 256-byte packet across 4 hops under three switching modes.
    
    Links carry 16 bytes per cycle (one flit per cycle). Each router adds 2 cycles to make
    its routing decision. Illustrative numbers.
      store-and-forward: each router waits for the whole packet before sending it on
      cut-through:       a router forwards as soon as the header arrives (buffers a whole
                         packet only if blocked)
      wormhole:          like cut-through, but a blocked packet stays spread across routers,
                         holding a few flit buffers in each
    With no contention, cut-through and wormhole have the same latency; they differ in buffering.
    """
    P, F, HOPS, T_ROUTER = 256, 16, 4, 2
    flits = P // F                                   # cycles to serialise the packet on one link
    saf = HOPS * (T_ROUTER + flits)
    ct = HOPS * T_ROUTER + flits
    print(f"packet: {P} B = {flits} flits; {HOPS} hops; {T_ROUTER} cycles per router")
    print(f"store-and-forward: {saf} cycles")
    print(f"cut-through:       {ct} cycles")
    print(f"wormhole:          {ct} cycles (no contention); buffers per router: a few flits, not a packet")
    assert saf == HOPS * (T_ROUTER + flits) and ct < saf
    print("PASS: store-and-forward pays the packet's serialisation at every hop; cut-through pays it once")

    It prints:

    Diagram
    packet: 256 B = 16 flits; 4 hops; 2 cycles per router
    store-and-forward: 72 cycles
    cut-through:       24 cycles
    wormhole:          24 cycles (no contention); buffers per router: a few flits, not a packet
    PASS: store-and-forward pays the packet's serialisation at every hop; cut-through pays it once
    The model's formulas for 1 to 6 hops. Store-and-forward grows by 18 cycles per hop; cut-through by 2.

    At four hops, 72 cycles against 24: store-and-forward spends 64 of its 72 cycles receiving the same packet four times. At one hop the two are equal, which is why the difference only matters in multi-hop networks.

    The design space

    Mode

    Latency

    Buffering

    Risk

    Store-and-forward

    Highest: H(r + L)

    A packet per router, always used

    Can check a packet's CRC before forwarding it, so a corrupted packet is never passed on

    Cut-through

    Lowest: Hr + L

    A packet per router, used when blocked

    Forwards packets before checking them; errors are caught downstream

    Wormhole

    Lowest: Hr + L

    A few flits per router

    A blocked packet holds links in several routers; more prone to blocking and deadlock, usually managed with virtual channels (Part 9)

    How real systems chose

    • On-chip networks almost always use wormhole switching with virtual channels: lowest latency with the least buffer area, and the deadlock risk handled by routing rules and channel classes.

    • Network switches offer store-and-forward and cut-through: store-and-forward can drop corrupted frames before forwarding them; cut-through gives lower latency where that matters.

    What breaks

    The opening network (illustrative) used store-and-forward routers because they were simple to verify. Moving to wormhole cut the idle latency from 72 to 24 cycles, and then the first heavy-traffic simulation deadlocked: two long packets, each strung across several routers, each waited for a link the other held. Wormhole's saving in buffers had turned a blocked packet from a local wait into a chain of held links. The design added virtual channels and a deadlock-free routing rule, the subject of Part 9.

    Why this matters

    Senior lens. Switching mode is a three-way trade between latency, buffer area and what a blocked packet holds. Ask how many hops a typical packet crosses (store-and-forward costs grow with them), how much buffer area each router may have (wormhole minimises it), and whether a blocked packet can hold links others need (wormhole's risk). For wormhole networks, the deadlock argument and the virtual-channel plan are part of the switching decision, not an afterthought.

    Interview

    Asked: "Compare store-and-forward, cut-through and wormhole switching."

    Weak answer: Wormhole is the fastest.

    Strong answer: Store-and-forward waits for the whole packet at each router, so latency is H(r + L): serialisation paid every hop, but it can check a packet before forwarding. Cut-through forwards once the header arrives, so latency is Hr + L, and keeps a packet's worth of buffer per router to absorb a blocked packet. Wormhole has the same idle latency as cut-through but only a few flits of buffer per router, so a blocked packet stays spread across routers and holds their links, which is why NoCs pair it with virtual channels for deadlock freedom.

    Follow-ups: (1) Which needs the most buffering? (2) Why are cut-through and wormhole latencies equal with no contention?

    Check yourself A 32-flit packet crosses 3 hops with 1 cycle of routing per router. Give both latencies.

    Store-and-forward 3 × (1 + 32) = 99 cycles; cut-through 3 × 1 + 32 = 35 cycles.

    Check yourself What does cut-through need that wormhole does not?

    Room for a whole packet in each router, so a blocked packet can be gathered into one router instead of staying spread over several.

    Check yourself Why can store-and-forward avoid passing on corrupted packets?

    It holds the whole packet before forwarding, so it can check the packet's CRC and drop it if it is bad.

    Key takeaways

    • Store-and-forward pays the packet's serialisation at every hop: H(r + L). Cut-through and wormhole pay it once: Hr + L.

    • Cut-through keeps a packet of buffer per router for blocked packets; wormhole keeps a few flits and leaves blocked packets strung across routers.

    • On-chip networks favour wormhole with virtual channels; the deadlock plan is part of the choice.

    Keep going

    Next: Lesson 4.14, Head-of-Line Blocking. One blocked packet at the front of a queue holds back everything behind it, even traffic for idle outputs.

    Related topics

    • Part 4 overview: Flow Control

    • Architecture course: Credit Flow Control and Buffers

    Previous

    63 / 234

    Next: Head-of-Line Blocking

    Up next

    Up nextHead-of-Line Blocking

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Why Flow Control
    • On/Off Flow Control
    • Credit-Based Flow Control