Write the scoreboard of a FIFO bench. Keep the bytes that went in, match each byte out against the oldest one waiting, and count what never came out.
Hardware context: A FIFO checked through a scoreboard, and checks that choose their source of truth. The scoreboard of a FIFO or queue bench.
A FIFO hands bytes out some cycles after they went in, so a check cannot compare at once. The expected bytes must wait somewhere until the real ones arrive. That store is the scoreboard.
Write fifo_scoreboard. The bench's monitor calls expect_in and got_out as it sees bytes move; the bench calls final_check once at the end.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
scenario | 4 | input of each check |
Full specification
| Call | What the scoreboard does |
|---|---|
| expect_in(d) | Keep d at the back of the bytes waiting. |
| got_out(d), nothing waiting | unexpected + 1. |
| got_out(d), d equals the oldest byte waiting | Remove that byte; matched + 1. |
| got_out(d), d differs from the oldest byte waiting | Remove that byte all the same; mismatched + 1. |
| final_check() | missing = the number of bytes still waiting. |
Removing the oldest byte on a mismatch is this bench's choice. One wrong byte counts once, and the next byte meets the next expected one. Up to 64 bytes may wait at once.
Examples
Example 1
Three in, the Same Three Out, in Order- Input
in 11 in 22 in 33 out 11 out 22 out 33 final
- Output
matched = 3, mismatched = 0, unexpected = 0, missing = 0
Each byte out equals the oldest one waiting: three matches, nothing left at the end.
Example 2
One Byte Comes Out Wrong- Input
in 11 in 22 in 33 out 11 out 99 out 33 final
- Output
matched = 2, mismatched = 1, unexpected = 0, missing = 0
99 came out where 22 was waiting: one mismatch. 22 is removed all the same, so 33 still matches.
Example 3
A Byte Out with Nothing Waiting, and a Byte That Never Came- Input
out 44 in 55 in 66 out 55 final
- Output
matched = 1, mismatched = 0, unexpected = 1, missing = 1
44 came out before anything went in: unexpected. 66 never came out: missing at the end.
Constraints and Contract
- Keep the module name, the four counters and the three functions with their arguments.
- Each case uses its own fresh scoreboard.
Hints
Hint 1
A FIFO is checked against a FIFO: the oldest expected byte is the one to compare.
Hint 2
A queue grows at the back and is read from the front.
Hint 3
Bytes never received are only known at the end.
What the grader checks: Ten scripts of calls, each on its own scoreboard. They cover matches, mismatches, bytes out with nothing waiting, bytes never received, wrong order and ten bytes waiting. The bench reads the four counters after final_check.
10 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 problems on this path