Problems

30. Valid/ready pipeline stage (skid buffer)

HardWrite the moduleAbout 45 min
handshakepipelinevalid-readybackpressure

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

Module skid_buffer

PortDirBitsWhat it is
clkin1Clock.
rstin1Synchronous reset, active high.
in_validin1Upstream has a word.
in_datain8Upstream word.
in_readyout1This stage can take a word.
out_validout1This stage has a word for downstream.
out_dataout8Word for downstream.
out_readyin1Downstream 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.

Stuck? . Sign in to save your progress. You can solve the free problems without an account.

Verilogskid_buffer.v
14px
Loading the editor…

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.

Valid/ready pipeline stage (skid buffer): Verilog interview question | breadboardhub