Hardware interview practice
Enforce a rolling bandwidth limit
Implement a checker allowing at most five accepted packets in any rolling ten-cycle window.
Reviewed example
Work through one case
Input
accepted packet cycles=[0,1,2,3,4]; attempt at cycle 9; attempt at cycle 10Expected output
cycle 9 packet rejected as sixth in the rolling window; cycle 10 packet accepted after cycle 0 expiresBefore checking cycle 10, events at or before 0 leave the ten-cycle window; the rejected cycle-9 event never pollutes legal state.
What to cover
Requirements
- Accept monotonically nondecreasing cycle numbers.
- Before checking a new packet at cycle c, remove events at or before c - 10.
- Reject a sixth in-window packet without adding the illegal event to legal model state.
- Use cycle counts rather than simulator time units.
