FVO — Formal Verification Online
Lesson 14.4 · Handshakes and Credit-Based Flow Control

Credit-based flow control explained

Valid/ready needs the consumer's ready to reach the producer in the same cycle. On a long link — across a chip, through pipeline registers, or between dies — that is impossible. Credit-based flow control solves it with accounting:

  1. The receiver has a buffer of DEPTH entries.
  2. The sender starts with DEPTH credits — one per free slot it is allowed to fill.
  3. Sending one item costs one credit. With zero credits the sender must wait.
  4. When the receiver frees a slot (its consumer pops an entry), it sends a credit back.

The sender never asks whether the receiver is ready: it knows there is space, because it holds a credit for it.

sendercredits counterlink regreturn regreceiverDEPTH-entry bufferdata + validcreditpop frees a slotevery register adds latency in each direction
Data flows forward; credits flow back. Registers on the link add latency, but no signal has to cross the link in one cycle.

A credit link in action

Below, DEPTH = 2, the sender always has data, and the receiver pops every other tick. There is one register in each direction.

012345678stallstallclktx_validcredits21010101tx_takelink_vldrx_count010101rx_popcred_ret
Two credits are used at ticks 0–1; the sender stalls at ticks 2–3 until the first credit comes back (tick 3) and becomes usable (tick 4). At every tick credits + link_vld + rx_count + cred_ret = 2.

Sizing: credits and round-trip time

A credit returns only after a full round trip: forward link latency + time in the buffer + return latency. To send every cycle, the sender needs at least as many credits (buffer entries) as cycles in that round trip. With too few credits the link still works — it just stalls, as in the waveform. This is why credit bugs are so often performance bugs: nothing breaks, the link is merely slower than designed.

The conservation invariant

Every credit is always in exactly one place: held by the sender, travelling as data on the forward link, occupying a receiver slot, or travelling back as a returned credit. So at every tick:

credits + data_in_flight + buffer_occupancy + credits_in_flight == DEPTH

This single equation implies no buffer overflow (the buffer can never hold more than DEPTH) and no credit creation. It is also inductive: if it holds now, each update keeps it true, so formal engines prove it quickly even for large DEPTH.

Discussion

No comments yet.

Was this page helpful?

Tip: select any text on the page before clicking Report and it will be quoted in your report.