Hardware interview practice
Synchronize a one-outstanding producer and consumer
Implement two finite testbench threads in which the producer may send the next packet only after the consumer acknowledges the previous one. Consumer processing takes 0 through 5 clocks.

Starting point
Question code
mailbox #(packet) data_mb = new(1);
mailbox #(bit) ack_mb = new(1);Reviewed example
Work through one case
Input
consumer delay = 5 clocks for every packetExpected output
packet IDs 0 through 9 are received once in order, with at most one packet outstandingThe producer blocks on ack_mb.get() after every put, so it cannot enqueue the next packet until the consumer completes the prior one.
What to cover
Requirements
- Block the producer after each data put until one acknowledgment is received.
- Have the consumer receive one packet, wait 0 through 5 clocks, and send exactly one acknowledgment.
- Transmit packet IDs 0 through 9 exactly once and wait for both threads to finish.
- Use persistent mailbox tokens rather than a bare event whose trigger could be missed.
