Hardware interview practice
Check coherent transactions under reordering
Two masters access two cache lines. Accepted operations to each line serialize in acceptance order; responses for different lines may reorder. Design an executable reference model that checks retry handling, snoop acknowledgements, coherent data, completion uniqueness, and end-of-test drainage.
Starting point
Question code
request: master, id, op, line, data
snoop: target, line, invalidate, ack
response: master, id, status, data
IDs unique while outstanding; retry means not accepted; reset line value=0Reviewed example
Work through one case
Input
M0 and M1 share line L; M0's write is accepted, but completion arrives before M1's invalidate acknowledgementExpected output
AssertionError naming missing acknowledgement from master 1The write cannot become the coherent line owner or update expected data until every other current sharer acknowledges invalidation.
What to cover
Requirements
- Track only accepted requests by ID and update no state for a retry; the same ID may later be accepted.
- Maintain owner, sharers, and data per line; reads observe serialized line state and writes commit only after all required invalidation acknowledgements.
- Permit response reordering across lines but require acceptance order within each line and exactly one completion per accepted ID.
- Detect unknown or duplicate completion, stale read data, missing snoop acknowledgement, and nonempty outstanding state at test end.
