Understanding credit tokens, lifecycle, and synchronization across the link
- Understanding credit tokens, lifecycle, and synchronization across the link
- 1 . Recap: Why PCIe Needs Credit-Based Control
- 2 . What is a Credit?
- 3 . Credit Types and Granularity
- 4 . Lifecycle of a Credit
- 5 . Flow Control at Link Initialization
- 6 . How Credits Are Counted
- 7 . Credit Accounting Example
- 8 . Separate Credit Pools per TLP Type
- 9 . Link Synchronization via DLLPs
- 10 . Design Insight
- 11 . Key Advantages of Credit-Based System
- NOTES
1 . Recap: Why PCIe Needs Credit-Based Control
In PCI Express, multiple TLPs can be in-flight simultaneously across a high-speed serial link.
To prevent the transmitter from overwhelming the receiver’s buffers, PCIe uses a credit-based system — a sort of “permission token” model.
Rather than handshaking on every packet, PCIe uses credit accounting to manage how many TLPs can be transmitted.
2 . What is a Credit?
A credit represents one unit of buffer capacity at the receiver’s Transaction Layer.
When the receiver advertises a certain number of credits, it’s essentially saying:
“You can send me this many TLPs (or this much data) before I run out of space.”
Each credit corresponds to:
- One TLP header (for Header Credits)
- One Doubleword (DW = 4 bytes) of payload (for Data Credits)
💡 Credits are abstract — they don’t represent bytes directly but capacity units negotiated at link training.
3 . Credit Types and Granularity
Each Virtual Channel (VC) in PCIe maintains six types of credits, representing different TLP classes and packet components.
Credit Type | Meaning | Applies To |
PH | Posted Header | Memory Writes, Messages |
PD | Posted Data | Memory Writes, Messages |
NPH | Non-Posted Header | Memory Read / I/O / Config Reads |
NPD | Non-Posted Data | Memory Write (with response expected) |
CPLH | Completion Header | Completion / Completion with Data |
CPLD | Completion Data | Completion with Data |
Thus, for each VC, you have 6 independent counters tracking buffer space.
4 . Lifecycle of a Credit
Here’s the credit lifecycle across the PCIe link:
[1] Receiver advertises credits↓
[2] Transmitter stores credits in counters↓
[3] Transmitter sends TLP (consumes credits)↓
[4] Receiver stores packet in buffer (credit used)↓
[5] Receiver processes packet and frees buffer↓
[6] Receiver sends Flow Control Update DLLP↓
[7] Transmitter increments credit counterThis ongoing cycle ensures both sides stay synchronized.
5 . Flow Control at Link Initialization
During link training (transition to L0 state):
- The receiver sends its initial credit capacity to the transmitter via Initialization Flow Control DLLPs.
- The transmitter stores those values as its starting counters.
- Transmission begins — each outgoing TLP decrements counters.
- The receiver issues periodic Flow Control Update DLLPs to restore credits.
⚙️ If credits = 0 for a specific TLP type, the transmitter must pause sending that type until credits are replenished.
6 . How Credits Are Counted
Header Credits (H)
→ Count one per TLP header transmitted.
Data Credits (D)
→ Count per data segment, measured in doublewords (4 bytes each).
Example:
A Memory Write TLP with 16 bytes of payload consumes:
- 1 PH credit (for the header)
- 4 PD credits (16 bytes ÷ 4 = 4 DWs)
7 . Credit Accounting Example
Let’s say:
- Receiver advertises PH = 10, PD = 40
- Transmitter has PH = 6, PD = 20 remaining
Now a Memory Write TLP (with 4 DW data) is to be sent:
- Needs 1 PH + 4 PD credits
- After sending → PH = 5, PD = 16
When receiver processes that packet and issues a Flow Control Update:
- PH and PD counters increase back toward their original values.
8 . Separate Credit Pools per TLP Type
Each TLP category (Posted, Non-Posted, Completion) uses a dedicated pool of credits because:
- They have different latency and buffering requirements.
- Posted packets (like Memory Writes) never expect responses.
- Non-Posted packets (like Reads) require Completion responses.
- Completions must always have priority since they fulfill pending requests.
This segregation ensures no packet type starves another and guarantees forward progress.
9 . Link Synchronization via DLLPs
Synchronization between the two link partners occurs through:
- Initialization Flow Control DLLPs: Sent once during link bring-up.
- Flow Control Update DLLPs: Sent dynamically whenever buffers are freed.
DLLPs (Data Link Layer Packets) are lightweight control packets used solely for link management (not visible to the Transaction Layer).
10 . Design Insight
In a PCIe controller design:
- Each credit type is tracked in a register counter.
- Tx Scheduler checks counters before choosing a packet to send.
- Credit Arbiter ensures that only TLPs with available credits are allowed.
- If no credits → packet waits in Transaction Queue.
In testbenches:
assert(credits_available(type)) else $fatal(“TLP sent without credit!”);
Such assertions are essential for verifying link compliance.
11 . Key Advantages of Credit-Based System
Feature | Benefit |
Predictable Bandwidth | Flow depends on known buffer limits, not random backpressure. |
Low Latency | No round-trip wait for “ready” signals. |
Scalable | Works over multiple hops (switches and bridges). |
Lossless Operation | No overflow — link partners always in sync. |
Full Duplex | Each direction has independent credit management. |
NOTES
- Credits = permission to send packets.
- Each VC maintains six counters for different TLP classes.
- Credits are consumed when packets are sent and replenished by Flow Control Update DLLPs.
- Flow control guarantees no buffer overflow, even at multi-gigabit speeds.
- This system is the backbone of PCIe’s deterministic, pipelined performance.