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
  • Part 5: Transactions19
  • Part 6: Concurrency and Performance17
  • Part 7: Ordering13
  • Part 8: Sharing and Arbitration12
    • Shared Media and Topologies
    • Arbitration Policies
    • Fairness and Starvation
    • Priority Inversion
    • Arbitration Granularity
    • Distributed Arbitration
    • Quality of Service
    • Virtual Channels
    • Routing
    • Multicast and Broadcast
    • Protocols Compared: Sharing and Arbitration
    • Drills: Sharing and Arbitration
  • 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 8: Sharing and Arbitration
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 8: Sharing and Arbitration
  4. Routing

Part 8 · Sharing and Arbitration · Senior (S)

Routing

How a packet finds its way through a network: deterministic and adaptive routing, source and distributed routing, and why dimension-order (XY) routing in a mesh can never deadlock.

On this page

    Note

    Level: Senior (S) · Answers: Who gets the wire?

    Before this: Virtual Channels

    In a 4×4 mesh, a packet from the bottom-left corner to the top-right corner has twenty different shortest paths. A router at each hop must pick an output. Pick cleverly, around congestion, and the network runs faster on average. Pick cleverly without care, and four packets can each wait for a link another one holds, and the network stops.

    How should a packet choose its path, and how does that choice affect deadlock?

    The obvious answer, and why it breaks

    The obvious goal is the best path for each packet: shortest, and avoiding busy links. That is adaptive routing, and it does balance load. But packets that can turn in any direction can form a cycle: each holds a buffer on one link and waits for the next link, held by the next packet, all the way round (Part 9). Routing is not only a performance choice; it decides whether cycles of waiting are possible at all.

    The idea: deterministic and adaptive

    Kind

    Path

    Strength

    Weakness

    Deterministic (for example XY)

    Fixed by source and destination

    Simple; in-order delivery per pair; easy deadlock argument

    Cannot avoid congested links

    Adaptive

    Chosen hop by hop from allowed outputs, using congestion

    Balances load, tolerates faults

    Packets can arrive out of order; needs a deadlock argument (turn restrictions or escape channels)

    A second axis is who decides: source routing (the source writes the whole path into the packet header) or distributed routing (each router computes the next hop from the destination). Most on-chip networks use distributed, deterministic routing.

    XY routing, and why it cannot deadlock

    Dimension-order routing in a 2-D mesh, XY routing, moves a packet along X until it reaches the destination's column, then along Y. That is all.

    XY routing in a 4×4 mesh: travel along X to the destination's column, then along Y. A packet never turns from Y back to X.

    A deadlock needs a cycle of packets, each waiting for a link held by the next. A cycle in a mesh must turn at least once from Y back to X (to go round a loop you must eventually come back in the X direction). XY routing forbids every Y-to-X turn: once a packet starts moving in Y, it never moves in X again. So no cycle can form, and the network cannot deadlock through routing, without needing any extra virtual channels.

    The turn model generalises the argument: forbid just enough turns to break every cycle, and adaptive routing within the remaining turns stays deadlock-free. Escape channels go the other way: let packets route adaptively on some virtual channels, but always keep one channel where they follow a deadlock-free route, so they can never be stuck for ever.

    How real systems chose

    Where

    Routing

    On-chip meshes

    Mostly XY (dimension-order) routing: deterministic, simple, deadlock-free, in-order between each pair.

    Rings

    Shortest direction, with an extra virtual channel (a dateline) to break the ring's cycle (lesson 9.6).

    Large off-chip networks

    Often adaptive, with escape virtual channels or turn restrictions for deadlock freedom.

    What breaks

    A mesh (illustrative) added a small adaptive tweak to XY routing: a packet blocked on its X link could take a Y link and come back to X later, to route around a hot spot. Under heavy traffic the network froze: four packets in a square each held one link and waited for the next. The tweak had re-allowed Y-to-X turns, restoring the cycles XY routing exists to prevent. Removing it (or adding an escape channel with pure XY) fixed the hang.

    Why this matters

    Senior lens. Treat routing as part of the deadlock design. For any routing function, ask which turns it allows and whether those turns can close a cycle; if adaptive routing is wanted, name the turn restriction or escape channel that keeps it safe. Also check ordering: adaptive routing can deliver packets between one pair out of order, which the protocol above must allow (Part 7).

    Interview

    Asked: "Why is XY routing deadlock-free?"

    Weak answer: Because it uses the shortest path.

    Strong answer: A deadlock needs a cycle of packets each waiting for a link held by the next, and any cycle in a mesh has to turn from the Y direction back to X somewhere. XY routing goes all the way in X first, then Y, and never turns from Y back to X, so no cycle of link dependencies can form. That's the turn-model argument: forbid enough turns to break every cycle. It also delivers packets between one pair in order, but it can't route around congestion.

    Follow-ups: (1) How does adaptive routing stay deadlock-free? (2) Why does a ring need extra virtual channels?

    Check yourself With XY routing in a mesh, a packet goes from (1, 3) to (3, 0). What path does it take?

    Along X from column 1 to column 3 (two hops) in row 3, then along Y from row 3 to row 0 (three hops).

    Check yourself Why can adaptive routing deliver two packets between the same pair out of order?

    They may take different paths with different congestion, so the later packet can take a faster path.

    Key takeaways

    • Routing is deterministic (fixed path) or adaptive (chosen around congestion), decided at the source or at each router.

    • XY routing never turns from Y back to X, so no cycle of link dependencies, and no routing deadlock, can form.

    • Adaptive routing needs turn restrictions or escape channels to stay deadlock-free, and may reorder packets.

    Keep going

    Next: Lesson 8.10, Multicast and Broadcast. Sending one message to many: snoops, invalidations and interrupts, and why large systems avoid broadcast.

    Related topics

    • Part 8 overview: Sharing and Arbitration

    • Architecture course: XY Routing and Deadlock

    Previous

    125 / 234

    Next: Multicast and Broadcast

    Up next

    Up nextMulticast and Broadcast

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Shared Media and Topologies
    • Arbitration Policies
    • Fairness and Starvation