Hardware interview practice
Model a recent-ID replay stream
Verify a streaming detector that reports the first repeated transaction ID whose accepted positions differ by at most a configured distance K. Input gaps and output stalls must not affect the result.
Reviewed example
Work through one case
Input
K=2; accepted ID frame=[4,7,4] with idle gaps between transfers; stall the responseExpected output
replay_found=1; first_index=0; second_index=2; stalled fields remain stableOnly accepted transfers define positions, and the repeated 4 has distance two, meeting the configured inclusive window.
What to cover
Requirements
- Accept one configuration before a nonempty frame, number only accepted ID transfers, and limit K to 15 and the frame to 16 IDs.
- Choose the lowest second index and then the lowest first index among pairs whose inclusive distance is at most K.
- Treat K zero as no replay and distinguish repeated IDs that lie outside the configured window.
- Compare only on an accepted response and require the stalled response payload to remain stable.
- Flush configuration, partial-frame state, and pending expectations on reset.
