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
    • Error Models
    • Parity
    • Hamming Distance
    • CRC
    • ECC and SECDED
    • Forward Error Correction
    • Error Responses
    • Poison and Containment
    • ACK and NAK
    • Sequence Numbers
    • Replay Buffers
    • Go-Back-N or Selective Repeat
    • Idempotency and Safe Replay
    • Link-Level or End-to-End Protection
    • Error Classes and Reporting
    • Recovery and Degradation
    • Interface Protection and Safety
    • The Reliability Budget
    • Protocols Compared: Reliability and Recovery
    • Drills: Reliability and Recovery
  • 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 10: Reliability and Recovery
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 10: Reliability and Recovery
  4. Idempotency and Safe Replay

Part 10 · Reliability and Recovery · Principal (P)

Idempotency and Safe Replay

Retransmission is only safe if doing an operation twice has the same effect as doing it once. Which operations are idempotent, which are not (side-effect reads, increments, FIFO pops), and how protocols suppress duplicates so replay stays safe.

On this page

    Note

    Level: Principal (P) · Answers: What if bits go wrong?

    Before this: Go-Back-N or Selective Repeat, Register Semantics

    A request crosses a link, reaches a device, and the device pops a byte from its receive FIFO to answer it. The response is corrupted on the way back. The requester times out and sends the request again. The device pops another byte. The requester now has the second byte; the first is gone for ever. The replay that was meant to recover from an error caused one.

    When is it safe to perform a request again, and how do protocols make replay safe?

    The obvious answer, and why it breaks

    The obvious recovery for a lost or damaged message is to send it again. For reading memory, that is harmless: reading twice gives the same value. But many operations change something: popping a FIFO, clearing a status bit, incrementing a counter, starting a DMA transfer. Doing them twice has a different effect from doing them once. Whether a replay is safe depends on the operation, and on whether the replay can reach the target a second time.

    The idea: idempotency

    An operation is idempotent if performing it twice has the same effect as performing it once.

    Operation

    Idempotent?

    Why

    Read of normal memory

    Yes

    Reading does not change anything

    Write of a value to normal memory

    Yes

    Writing 5 twice leaves 5 (if nothing wrote in between)

    Read of a FIFO data register

    No

    Each read pops an entry (lesson 5.4)

    Read-to-clear status

    No

    The second read sees nothing

    Increment, fetch-and-add, other atomics

    No

    Each performs the change again

    Write to a "start" or "push" register

    No

    Starts the job or pushes the item twice

    Two ways to make replay safe

    • Replay only below the target. A link-level replay (lesson 10.11) resends a packet only until the receiver at the far end of that link has it, and that receiver discards duplicates by sequence number. The target behind it sees each request once, whatever the operation. This is why link replay is always safe.

    • Suppress duplicates end to end. When a request is retried end to end (after a timeout, through a fabric), the target must recognise a repeat and answer it from a saved result instead of performing it again: a tag or sequence number per request, and a record of recent completions.

    What is never safe is an end-to-end retry of a non-idempotent request with no duplicate suppression: the opening FIFO story.

    How real systems chose

    Where

    Replay safety

    PCI Express data link layer

    Replays packets on one link only; the receiver discards duplicates by sequence number, so the transaction layer sees each request once.

    Requests after a completion timeout

    Software decides whether to retry, because the hardware cannot know whether the target performed the request.

    Network protocols

    Duplicate suppression with request identifiers for non-idempotent operations.

    What breaks

    The opening system (illustrative) added an automatic end-to-end retry in an interconnect after a timeout, to hide occasional lost responses. Memory accesses were fine. Device register reads that popped FIFOs or cleared status bits occasionally lost data when the response, not the request, had been the casualty. The retry was removed for device regions, where the timeout now returns an error to software, which knows whether it may try again.

    Why this matters

    Principal lens. Distinguish link-level replay (always safe: the far receiver suppresses duplicates) from end-to-end retry (safe only for idempotent operations or with duplicate suppression at the target). Any hardware that retries requests on its own must be restricted to regions marked idempotent, usually normal memory, and device accesses must surface errors to software instead of retrying silently.

    Interview

    Asked: "Can a read be replayed safely?"

    Weak answer: Yes, reads don't change anything.

    Strong answer: Only if it's idempotent. A read of normal memory is, but reads of device registers often aren't: popping a FIFO, read-to-clear status, acknowledging an interrupt. Replaying those after a lost response loses data. Link-level replay is still safe for them, because the receiver on that link discards duplicates by sequence number so the target sees the request once. An end-to-end retry is safe only with duplicate suppression at the target, so hardware retries should be limited to memory regions.

    Follow-ups: (1) Why is link-level replay always safe? (2) What does a target need to suppress duplicates?

    Check yourself A fetch-and-add's response is lost and the requester retries it end to end without duplicate suppression. What happens?

    The add is performed twice; the counter is wrong by one increment.

    Check yourself Why can PCIe replay a TLP that targets a FIFO register without popping it twice?

    The replay happens on one link, and the link's receiver discards the duplicate by sequence number before it reaches the transaction layer and the device.

    Key takeaways

    • Replay is safe only for idempotent operations: twice must have the same effect as once.

    • Link-level replay is always safe, because the far receiver discards duplicates before the target.

    • End-to-end retry needs idempotent targets or duplicate suppression; device accesses should surface errors to software.

    Keep going

    Next: Lesson 10.14, Link-Level or End-to-End Protection. Per-hop checks and end-to-end checks, and why links use both.

    Related topics

    • Part 10 overview: Reliability and Recovery

    Previous

    154 / 234

    Next: Link-Level or End-to-End Protection

    Up next

    Up nextLink-Level or End-to-End Protection

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Error Models
    • Parity
    • Hamming Distance