30. Valid/ready pipeline stage (skid buffer)
Build one pipeline register stage for an 8-bit stream that uses a valid/ready handshake on both sides. A word moves across an interface on a rising clock edge where valid and ready are both 1. The sender keeps valid and data steady until its word is taken.
Requirements:
- No data is lost, duplicated or reordered.
- Full throughput: with out_ready held at 1, one word per cycle passes through.
- in_ready must come straight from this stage's registers. It must not depend on out_ready in the same cycle (that is the point of the stage: it breaks the combinational ready path).
- out_valid and out_data come from registers too.
Because in_ready cannot react to out_ready at once, the stage needs room for one extra word: when the output is stalled and a word arrives anyway, it waits in a second ("skid") register. in_ready is 1 exactly when that skid register is empty. When the output side frees up, the word in the skid register goes out next, before any new input.
rst (synchronous, active high) empties both registers. out_data is not checked while out_valid is 0.
Ports
| Port | Dir | Bits | What it is |
|---|---|---|---|
clk | in | 1 | Clock. |
rst | in | 1 | Synchronous reset, active high. |
in_valid | in | 1 | Upstream has a word. |
in_data | in | 8 | Upstream word. |
in_ready | out | 1 | This stage can take a word. |
out_valid | out | 1 | This stage has a word for downstream. |
out_data | out | 8 | Word for downstream. |
out_ready | in | 1 | Downstream can take a word. |
Example
Words 0x10, 0x11, 0x12 arrive back to back. The output holds 0x11 when downstream stalls, and 0x12 (already accepted) goes into the skid register, so in_ready drops. When out_ready returns, 0x12 comes out next, then the waiting 0x13.
Written hints
AI hint
Submissions
No submissions yet. Submit your answer and it shows here. Sign in to keep them.
Submit your answer to have it graded. The hidden test runs on the server; you see whether it passes and, if not, the first case it gets wrong.
Press Build to check your code with Yosys. Errors and warnings show here, and a clean build draws the logic diagram.
Build your design to drive it by hand and see its signals here.