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
  • Part 9: Deadlock and Liveness13
  • Part 10: Reliability and Recovery20
  • Part 11: Bring-Up and Link Management10
    • Reset Semantics
    • Reset Sequencing Across Interfaces
    • Presence and Hot-Plug
    • Link Training
    • Capability Negotiation
    • Enumeration and Discovery
    • Link State Machines
    • Versioning and Compatibility
    • Protocols Compared: Bring-Up and Link Management
    • Drills: Bring-Up and Link Management
  • 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 11: Bring-Up and Link Management
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 11: Bring-Up and Link Management
  4. Link State Machines

Part 11 · Bring-Up and Link Management · Senior (S)

Link State Machines

Everything in this part, gathered into one controller: the link state machine that moves between down, training, active, recovery and low power. Its states, what traffic is allowed in each, and the rules that keep the two ends in step.

On this page

    Note

    Level: Senior (S) · Answers: How do the two sides agree at start-up?

    Before this: Link Training, Presence and Hot-Plug

    A link-layer engineer is asked a simple question during debug: "Is the link up?" The honest answer is "which part of it?" Lanes may be detected but not locked, locked but not configured, configured but with flow-control credits still uninitialised, or fully up but about to retrain. Each of those is a different state, with different rules about what may be sent. A link is not up or down. It is a state machine.

    What does the state machine that runs a link look like, and what does each state allow?

    The obvious answer, and why it breaks

    The obvious design is a single "link up" bit. It hides the cases that cause bugs: traffic sent before credits are initialised, requests queued while the link is retraining, a low-power entry while packets are still in flight. Each of those needs a distinct state, explicit transitions, and a rule for what the layers above may do in it.

    The idea: states, transitions, and what each allows

    Only ACTIVE carries traffic; RECOVERY retrains without losing state, SLEEP is the low-power state, and DOWN is reached from recovery only when retraining fails.

    State

    What may be sent

    What the layers above see

    DOWN

    Nothing (maybe detection pulses)

    Link down: outstanding requests failed, new ones refused or errored

    TRAINING

    Training patterns only

    Not yet available

    INIT

    Link-layer initialisation (credits, sequence numbers)

    Not yet available

    ACTIVE

    Everything

    Link up

    RECOVERY

    Training patterns only; packets wait

    Link up, stalled: requests queue, replay buffer keeps its contents

    SLEEP (low power)

    Nothing until wake

    Link up, with added latency on the next request

    Rules that keep the two ends in step

    • Both ends must agree on every transition, using training patterns or explicit messages. A side that thinks it is active while the other is training sends packets into a receiver that ignores them.

    • Recovery keeps state, down discards it: retraining should not lose sequence numbers or buffered packets; dropping to DOWN must fail everything outstanding (lesson 11.3).

    • Every state needs a timeout: a link stuck in TRAINING or RECOVERY for ever is a hang (lesson 9.9); time out to DOWN and start again.

    • Expose the state: debug depends on knowing which state the link is in and how often it has visited RECOVERY.

    How real protocols chose

    Protocol

    Link state machine

    PCI Express

    The LTSSM: Detect, Polling, Configuration, L0 (active), Recovery, the low-power states L0s, L1 and L2, plus Disabled, Loopback and Hot Reset. Flow-control initialisation completes in the data link layer before transactions flow. Controllers expose the current LTSSM state for debug.

    DCLink

    Step 10 negotiation ends in ACTIVE; the replay of step 9 runs inside it; step 11 adds a low-power state.

    What breaks

    A link controller (illustrative) left RECOVERY one cycle earlier on one side than the other. For that cycle, the first side sent a packet the second still treated as a training pattern and discarded. Usually replay fixed it, but when the packet was an acknowledgement, the sender waited for a replay timeout every time. Making the exit depend on receiving the partner's exit pattern, not on a local timer, fixed it.

    Why this matters

    Senior lens. Draw the link state machine before writing the link layer, and for each state write down what may be sent, what the upper layers see, what happens to buffered packets, and what timeout leaves it. Then check every transition is agreed by both ends. Most link bugs live in transitions, and an exposed state counter turns a week of debug into an hour.

    Interview

    Asked: "Can a link carry traffic during recovery?"

    Weak answer: Yes, at a lower rate.

    Strong answer: No. In recovery the link sends only training patterns while it relocks and retunes, so transaction packets wait. But the upper layers don't see a link-down: packets queue, the replay buffer keeps its contents and sequence numbers are preserved, so when the link returns to the active state traffic resumes without loss. Only if recovery fails does the link go down, and then outstanding requests have to be failed.

    Follow-ups: (1) Why does every state need a timeout? (2) What is the difference between recovery and down for the transaction layer?

    Check yourself Why is a separate INIT state needed between training and active?

    The physical link works, but link-layer state such as credits and sequence numbers must be initialised before packets can be sent safely.

    Check yourself What should exit RECOVERY: a local timer or the partner's pattern?

    The partner's pattern, so both ends leave together; a local timer lets them drift apart by a cycle or more.

    Key takeaways

    • A link is a state machine: down, training, initialisation, active, recovery and low power.

    • Each state defines what may be sent and what the upper layers see; recovery keeps state, down discards it.

    • Agree every transition with the partner, time out every state, and expose the state for debug.

    Keep going

    Next: Lesson 11.8, Versioning and Compatibility. Old and new devices on the same link: how protocols evolve without breaking what is installed.

    Related topics

    • Part 11 overview: Bring-Up and Link Management

    Previous

    168 / 234

    Next: Versioning and Compatibility

    Up next

    Up nextVersioning and Compatibility

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Reset Semantics
    • Reset Sequencing Across Interfaces
    • Presence and Hot-Plug