S3 · Lesson 36 · Interfaces and handshakes
Valid/ready flow control, buses, bursts, credits and line coding
Every block in a chip has to pass data to its neighbors, and neither side can assume the other is always ready. The standard answer is a two-signal handshake: the sender raises valid when it has data, the receiver raises ready when it can take it, and a word moves on every clock edge where both are high. That one rule composes into pipelines, FIFOs and whole on-chip networks, and the same ideas scale up to buses with bursts, to credit-based links between chips, and to serial lanes whose line codes trade a few percent of bandwidth for reliable clock recovery.
- A valid/ready interface. FIRE = VALID & READY marks the transfers, and a 2-bit counter (C1, C0) counts them on each clock edge where FIRE is high.
- From 34 to 42 the sender has data but the receiver isn't ready: the word waits, and the sender must hold it unchanged. From 42 to 50 the receiver is ready but there's nothing to send.
- Count the edges where both are high: five transfers, so the counter ends at 01.
Predict
A receiver registers its ready signal, so the sender sees it one cycle late, and data takes one more cycle to arrive. To never lose a word while running at full rate, how many words must the receiver be able to take after it drops ready?
Two. When the receiver drops ready, the sender doesn't see it for a cycle and keeps sending, and words already on their way keep arriving: the round trip is two cycles, so two more words land after the decision. A small skid buffer absorbs them. Longer links between chips use the same idea with credits: the sender holds one credit per free buffer slot and needs at least a round trip's worth of them to run at full speed.
Name it
The valid/ready handshake
A transfer happens at a clock edge where both VALID and READY are high. Two rules keep it safe:
- Once the sender raises VALID, it holds VALID and the data stable until the transfer happens.
- VALID must never depend combinationally on READY (the receiver may make READY depend on VALID), so no combinational loop can form between two blocks.
AXI-Stream and the five channels of AXI (read and write address, write data, write response, read data) all use it.
Buses and bursts
A bus's peak bandwidth is width × clock. Each transaction also costs overhead cycles (address, arbitration, turnaround), so a burst of B beats with o overhead cycles has an efficiency of . AXI4 allows bursts of up to 256 beats.
Flow control over latency
If a ready or credit signal takes cycles to reach the sender and data takes cycles in flight, the receiver must be able to absorb words after it says stop. With credits, the sender needs at least credits to send every cycle; fewer credits cap throughput at words per cycle.
Serial links
Fast links send one bit stream per lane and recover the clock from the data, so the data must have enough transitions and no DC drift:
| Code | Payload per line bits | Used in |
|---|---|---|
| 8b/10b | 80% | older PCIe, SATA, USB 3.0 |
| 64b/66b | 96.97% | 10 G Ethernet |
| 128b/130b | 98.46% | PCIe 3.0 to 5.0 |
Payload rate = line rate × code efficiency × lanes.
Worked example
A 64-bit bus runs at 250 MHz. Transfers are 16-beat bursts, each with 4 cycles of address and turnaround overhead. What's the sustained bandwidth?
Show the solution
- Peak.
- Efficiency. so 1.6 GB/s sustained.
- Single beats. Single-beat transfers would give 1/5 of peak, 0.4 GB/s, which is why DMA engines move data in long bursts.
Answer 1.6 GB/s sustained, 80% of the 2 GB/s peak.
Worked example
What payload rate does a PCIe 3.0 x4 link carry (8 GT/s per lane, 128b/130b), and a 10 G Ethernet lane (10.3125 Gb/s, 64b/66b)?
Show the solution
- PCIe. which is 3.94 GB/s each way.
- Ethernet. which is why the odd line rate was chosen.
Answer 31.5 Gb/s (3.94 GB/s) each way for PCIe 3.0 x4, and 10.0 Gb/s for the Ethernet lane.
Worked example
Credits take 3 cycles to return to a sender, and data spends 5 cycles in flight. How many credits keep the link busy every cycle, and what throughput do 6 credits give?
Show the solution
- Round trip. The sender must cover the whole round trip: so it needs 8 credits (and the receiver 8 words of buffering).
- With 6 credits. It sends 6 words, then waits for the first credit to come back: 6 of every 8 cycles, 75% of the link.
Answer 8 credits keep the link busy; 6 credits give 75%.
Check
A 64-bit bus runs at 100 MHz. What's its peak bandwidth?
Check
Bursts of 8 beats each cost 2 cycles of overhead. What fraction of peak bandwidth is sustained?
Check
A ready signal takes 2 cycles to reach the sender, and data takes 1 cycles in flight. How many words must the receiver absorb after it drops ready, to lose nothing at full rate?
Check
A credit-based link has a 4-cycle credit return and 10 cycles of data latency, and the receiver has only 4 buffer slots. What fraction of full rate can it sustain?
Check
A link runs 1 lane(s) at 5 Gb/s each, with a line code of efficiency 0.9846. What's its payload rate?
Write units the way you normally would: 1.5 Gb/s, 1500 Mb/s and 0.0015 Tb/s are the same answer.
Check
A DMA engine moves 65536 bytes over a bus of 8-byte beats, with bursts of at most 256 beats. How many bursts does it take?
Check
A 64-bit bus at 200 MHz moves 64-beat bursts, each with 4 cycles of overhead.
(a)
What is its peak bandwidth?
(b)
What fraction of cycles carry data?
(c)
What bandwidth does it sustain?
Check
A credit-based link has r cycles of credit-return latency and d cycles of data latency; the sender holds c credits, fewer than the round trip.
Step 1
How many credits would keep it busy every cycle?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What fraction of cycles does it use with c credits?
Explain why
Why must a sender's valid signal never depend combinationally on the receiver's ready signal?
The receiver is allowed to compute ready from valid, for example to accept a word only when one is offered. If the sender also computed valid from ready, the two signals would form a loop through combinational logic in two different blocks: a change in one would ripple to the other and back within the same clock period. Such a loop can oscillate or settle to a value that depends on gate delays, and timing analysis can't handle it. Requiring valid to depend only on the sender's own state breaks the loop, so any two blocks that follow the rule can be connected safely without either designer knowing how the other built theirs.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.