Hardware interview practice
Match out-of-order responses by ID
Requests use unique 8-bit IDs, and responses may return in any order. Build an ID-indexed scoreboard for operand-squared results, duplicate detection, exact comparison, and end-of-test leftovers.
Starting point
Question code
req: id[7:0], operand[15:0]
rsp: id[7:0], result[31:0]
expected result = operand * operand
maximum 32 outstanding requestsReviewed example
Work through one case
Input
Requests (1,3), (2,4); responses (2,16), (1,9)Expected output
Both responses pass and the associative array becomes emptyEach response is matched by ID rather than arrival position.
What to cover
Requirements
- On each request, compute the expected result and store it in an associative array indexed by ID; reject a duplicate outstanding ID.
- On each response, require the ID to exist, compare result exactly, then delete that ID after the comparison.
- Report an unexpected ID, duplicate request ID, data mismatch, and any entries still present at end of test as distinct errors.
- Do not compare responses by arrival order; the only ordering key is the response ID.
