Hardware interview practice
How a Ready/Valid Skid Buffer Handles Backpressure
Design a two-entry ready/valid skid buffer that can accept one extra item after downstream stalls, keeps output data stable while stalled, and removes the combinational ready path from downstream to upstream.
Example
start with occupancy=1 and front=A
cycle 1: s_valid=1,B; m_ready=0
cycle 2: s_valid=1,C; m_ready=1 (buffer is full)
cycle 3: s_valid=1,C; m_ready=1cycle 1: B is accepted into the second slot; output A stays stable; occupancy=2
cycle 2: A retires, s_ready=0 so C is not accepted; occupancy=1
cycle 3: B retires and C is accepted; occupancy remains 1Explanation: The second slot captures B after the stall. Because ready is registered from occupancy, a pop observed while full cannot simultaneously admit C on cycle 2.
Reasoning requirements
- Accept input only on s_valid && s_ready and retire output only on m_valid && m_ready.
- Preserve ordering across push-only, pop-only, and simultaneous push/pop cycles.
- Drive s_ready from registered occupancy rather than combinationally from m_ready; when already full, a newly observed pop cannot also accept a replacement that edge.
- When m_valid is high and m_ready is low, hold m_valid and m_data stable.
Concise answer
The answer and the key reason
Deeper explanation
Work through the implementation and tradeoffs
Compute push only from s_valid and registered-capacity s_ready, and pop only from m_valid and m_ready. A push into an empty buffer fills the head; a second push fills the spare slot. A pop from two entries promotes the spare. When one entry is simultaneously popped and replaced, the incoming item becomes the new head.
Deriving s_ready solely from occupancy breaks the long combinational path from downstream ready to upstream ready. The tradeoff is deliberate: at occupancy two, an output handshake cannot also authorize an unadvertised input handshake on that edge, so the buffer can briefly bubble at the full boundary. Stability assertions should cover every downstream stall.
What to remember
- Use depth-two occupancy
- Freeze output under stall
- Expect a full-boundary bubble
Practice the complete prompt
