Hardware interview practice
Wait for drain with a deadline
Wait for all outstanding work and expected transactions to drain, but fail if the deadline expires.
Reviewed example
Work through one case
Input
timeout_cycles=5; outstanding reaches0 at poll2; expected queue becomes empty at poll4Expected output
wait returns successfully after poll4Drain requires both conditions simultaneously; completion before the fifth poll avoids the fatal deadline.
What to cover
Requirements
- Check both the outstanding counter and expected queue.
- Count at most timeout_cycles.
- Report a fatal error when either remains non-empty.
