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. Credit Initialisation

Part 4 · Flow Control · Working (W)

Credit Initialisation

How a sender learns how many credits it starts with: fixed by design or advertised at start-up; what "infinite credits" means; and what happens to credits across reset.

On this page

    Note

    Level: Working (W) · Answers: How much may I send before I hear back?

    Before this: Credit-Based Flow Control

    A chip is reused with a different partner. The new partner has half the receive buffering of the old one, but the sender's credit counter still starts at the old value, hard-wired in its RTL. The first heavy burst overflows the partner's buffer. Nothing in the credit mechanism was wrong except the number it started from.

    How does a sender learn how many credits it starts with, and what must happen to them on reset?

    The obvious answer, and why it breaks

    The obvious answer is to build the initial credit count into the sender as a constant equal to the receiver's buffer size. That couples the two sides: every receiver must have exactly that buffer, forever, or the constant must be changed and the sender rebuilt. It breaks the moment two independently designed devices meet, which is the normal case for any protocol between chips.

    The idea: the receiver advertises its own buffers

    Credit protocols between independently designed parts let the receiver tell the sender how many credits it is granting, during start-up and before any data flows:

    • Advertise. After the link comes up, each receiver sends a message stating its credit limit for each credit type.

    • Confirm. The protocol repeats or acknowledges the advertisement so both sides know initialisation is complete; a lost message must not leave one side with no credits.

    • Then send. Only after initialisation may data flow; from then on credits are returned as slots free.

    This keeps the contract minimal (lesson 0.1): the receiver's buffer size is the receiver's own business, stated at run time, not a constant both sides must share.

    The receiver advertises its limits before any data flows; the sender starts from them.

    Infinite credits

    Some receivers can promise to accept a type of traffic always, for example because they only receive responses to requests they issued themselves and reserved space for in advance. Such a receiver can advertise infinite credits for that type: the sender stops counting and never waits for that traffic. It is a strong promise, and protocols use it where a stall would be dangerous: a requester that refuses its own responses can deadlock the system (lesson 9.5).

    Reset and retraining

    Credits are state at both ends, so every event that resets one end must reset the other's view of it:

    • Link reset or retraining: both sides discard their credit counts and repeat initialisation. Credits in flight at the time are forgotten, and so are the words they covered, which is why a link reset is also a transaction-layer event.

    • One side resets alone: its partner still holds credits for buffers that were just emptied (or that no longer exist). The protocol must force the partner back through initialisation, or credits and buffers disagree from then on.

    The design space

    Approach

    What it costs

    When it wins

    Fixed initial credits in the sender

    Couples sender to one receiver design

    Both ends designed together, on one chip

    Advertised at start-up

    An initialisation step before data; messages that carry limits

    Independently designed devices

    Infinite credits for a type

    The receiver must truly always accept it

    Responses to the receiver's own requests

    Re-advertise after every reset

    A start-up delay after each reset

    Always, for any link where one side can reset alone

    How real protocols chose

    Protocol

    Its choice

    PCI Express

    Credits are advertised during flow-control initialisation (InitFC1 and InitFC2 data link layer packets) and returned during operation with UpdateFC packets. A receiver may advertise infinite credits for a credit type, turning flow control off for it; endpoints must advertise infinite completion credits, so they can never refuse a completion for lack of credit.

    PCIe's two initialisation phases are the "advertise, then confirm" pattern: the second phase makes sure both sides know the first one completed before data is allowed to flow.

    What breaks

    A device resets its receive logic after an internal error without telling its link partner (illustrative). Its buffers are now empty, but the partner still believes some slots are occupied and holds fewer credits than it should: the link runs slowly forever. The opposite case is worse: a partner that believes it holds credits for buffers the device no longer has will overflow them. The fix is a protocol rule, not a counter tweak: any reset of the credit-holding logic must force both sides back through credit initialisation.

    Why this matters

    Senior lens. Initialisation is where credit protocols are most fragile, because it is the one time both ends' state must be created consistently from nothing. Review three things: the order (no data before both sides have initialised), the robustness of the advertisement (repeated or acknowledged, so one lost message cannot leave a side stuck), and every path by which one side can reset without the other. Infinite credits deserve a separate review: they are a promise the receiver can never take back.

    Interview

    Asked: "What does "infinite credits" mean and when is it allowed?"

    Weak answer: The receiver has a very large buffer.

    Strong answer: The receiver promises to always accept that type of traffic, so the sender stops counting credits for it. It's allowed only when the receiver can always accept, typically for responses to requests it issued and already reserved space for. PCIe requires endpoints to advertise infinite completion credits for exactly that reason: a requester that could refuse its own completions could deadlock the system.

    Follow-ups: (1) How does a sender learn its initial credits in PCIe? (2) What must happen to credits when one side resets?

    Check yourself Why does the receiver, not the sender, decide the initial credit count?

    Only the receiver knows its own buffer sizes. Advertising them at start-up keeps the two designs independent.

    Check yourself A link retrains while words and credits are in flight. What happens to them?

    Both sides discard their credit state and re-initialise; the in-flight words and credits are lost from the link layer's view, so higher layers must recover any lost transactions.

    Check yourself Why is an infinite-credit promise dangerous to get wrong?

    The sender never waits for that traffic. If the receiver ever cannot accept it, there is no flow control to stop the sender, and data is lost or the receiver must stall something else.

    Key takeaways

    • Between independently designed parts, the receiver advertises its credit limits at start-up, before any data flows.

    • Infinite credits mean "I will always accept this type"; protocols require it where refusing would deadlock.

    • Any reset of either side's credit state must send both back through initialisation.

    Keep going

    Next: Lesson 4.5, The Credit Loop and Buffer Sizing. How many credits does full throughput need? The credit loop and the bandwidth-delay product.

    Related topics

    • Part 4 overview: Flow Control

    Previous

    54 / 234

    Next: The Credit Loop and Buffer Sizing

    Up next

    Up nextThe Credit Loop and Buffer Sizing

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Why Flow Control
    • On/Off Flow Control
    • Credit Classes and Pools