Hardware interview practice
Match transactions in strict order
Implement the core of an in-order scoreboard. Expected and actual transactions arrive independently, but every actual transaction must match the oldest unmatched expected transaction.
Reviewed example
Work through one case
Input
push expected=(id=1,data=A), then (id=2,data=B); actual arrivals=(1,A), then (2,B)Expected output
two ordered matches; expected queue empty at finishEach actual compares only with the cloned queue front and consumes exactly one expectation, so reversing the actual arrivals would fail immediately.
What to cover
Requirements
- Clone expected transactions before storing them so later producer edits cannot mutate scoreboard state.
- Report an actual transaction when no expected item is available.
- Compare against the queue front and consume exactly one expected entry per actual entry.
- At end of test, report any expected transactions that never arrived.
