H1.8 Reset During Adapter Backpressure

HardFixVerilator · serverReview the topic

Fix a stream checker so that a reset cancels every value written before it.

Hardware context: Clocked FIFO plus ready/valid output adapter. Reset while the stream adapter holds a value and reject stale post-reset output.

A reset cancels everything the FIFO and the adapter hold. A checker must cancel its expectations too. If it does not, it waits for old values that will never come, and blames the correct design.

The class reset_auditor watches the FIFO-to-stream adapter from outside. It keeps a ledger, an ordered list of written values not yet delivered or cancelled. The tests call sample() once per edge and finish() at the end.

The auditor checks four things. Every valid offer must be the oldest ledger value. A stalled offer must hold still. Reset must clear the output. With ready = 1 for three edges in a row, a waiting value must move.

The tests run it on a correct adapter and on six faulty ones. Find the bug that makes it blame the correct adapter, and fix it.

Signals in the Timeline

SignalWidthRole
profile2input of each check
controls96input of each check
values256input of each check
fault3input of each check
Full specification
The class (keep these names and types)
class reset_auditor;
  function new();
  function void sample(input int cycle, input bit reset, accepted_write, input bit [31:0] write_data,
                       input bit ready, pre_valid, input bit [31:0] pre_data,
                       input bit post_valid, input bit [31:0] post_data);
  function bit [79:0] finish();
endclass
Adapter ruleMeaning
One creditThe adapter has one holding register for the stream and room for one read in flight. It never has two reads in flight.
Issue a readread_request = !reset && !pending && (!out_valid || ready) && !fifo_empty, using values before the edge.
TimingA read accepted on edge k gives FIFO data after edge k. The adapter captures it on edge k+1. The stream can take it on edge k+2 at the earliest.
CaptureCapturing a FIFO response never waits for ready. pending clears when the response is captured.
StallWhile out_valid = 1 and ready = 0, out_valid and out_data hold their values exactly.
Hand overThe edge where the stream takes the held value may also issue the next read.
ResetReset cancels every stored entry, the read in flight and the held value. After the edge, out_valid = 0 and out_data = 0.
Error bitRaised when
0A valid offer is not the oldest ledger value, or there is no value to offer.
1post_valid or post_data is not 0 after a reset edge.
2A value stalled on the previous edge (valid with ready = 0) is gone or changed now. This is checked even on the edge that takes it.
3A ledger value waited through three edges in a row with ready = 1 and no transfer.
4finish() finds the ledger not empty. Edge 31 is then marked as failing.
Edge typeWhat sample() does
ResetCancel the whole ledger, clear the stall history and the ready count, and check that the output is 0. Count the reset edge.
OtherCheck the offer and the stall. A transfer happens when pre_valid = 1 and ready = 1; count it and pop the ledger. Then append an accepted write.

The ready count restarts on reset, on ready = 0 and on a transfer. A new write starts waiting on the next edge.

Keep counting truthfully when a faulty adapter sends extra values. The counts may then fail to balance.

Faulty adapterWhat is wrong
1The held value survives reset.
2The read in flight survives reset.
3The held value is dropped while stalled.
4Bit 0 of the data is flipped.
5A read is issued over a stalled value.
6A cancelled value is replayed one edge after reset.

Examples

Example 1

Reset Cancels, Then Fresh Values Flow
Input
Depth 3, correct adapter: write 0x31, 0x32, 0x33 on edges 0 to 2 with ready = 0; reset with write 0x99 on edge 4; write 0xa1, 0xa2 on edges 5 and 6; ready = 1 from edge 5
Output
error_edges = {}, error_kinds = {}, accepted_writes = 5, transfers = 2, reset_cancelled = 3, final_pending = 0, reset_edges = 1

Five writes are accepted in total. Reset cancels the three old ones, and the refused 0x99 never joins the ledger. Only 0xa1 and 0xa2 reach the stream. Nothing is left and no error is raised.

Example 2

The Held Value Survives Reset
Input
The same trace with an adapter that keeps its held value through reset
Output
error_edges = {4, 5}, error_kinds = {0, 1}, accepted_writes = 5, transfers = 3, reset_cancelled = 3, final_pending = 0, reset_edges = 1

The output is not cleared after the reset edge, so edge 4 fails with bit 1. On edge 5 the old 0x31 moves before 0xa1 is written, so it is an extra value and bit 0 is raised. Three transfers happen, but only two were due.

Example 3

A Clear Output Can Still Hide a Stuck Read
Input
Depth 3, read in flight kept through reset: write 0x41, 0x42 on edges 0 and 1; reset with write 0x99 on edge 2; write 0xb1, 0xb2 on edges 3 and 4; ready = 1 from edge 3
Output
error_edges = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, error_kinds = {3, 4}, accepted_writes = 4, transfers = 0, reset_cancelled = 2, final_pending = 2, reset_edges = 1

Reset clears the visible output, but the adapter still thinks a read is in flight. The new values never move. From edge 6 the deadline fails on every edge, and finish() reports two pending values.

Example 4

A Replay After Reset
Input
The first trace with an adapter that replays a cancelled value one edge after reset
Output
error_edges = {6, 8, 10}, error_kinds = {0}, accepted_writes = 5, transfers = 3, reset_cancelled = 3, final_pending = 0, reset_edges = 1

The output is clear after the reset edge, but old 0x31 comes back on the next edge. Its transfer uses up the place of 0xa1, so the later offers are wrong too. Three offers fail with bit 0.

Constraints and Contract

  • Check stale output even while the receiver is not ready.
  • Edges with ready = 0 do not use up the three-edge deadline.
  • Keep the class name, the method names and the argument types.

Hints

Hint 1

Treat a reset edge as a boundary. Nothing written before it may be expected after it.

Hint 2

Keep the stall check apart from the order check and the deadline. Each has its own state.

Hint 3

Look at the reset branch of sample(). It counts the cancelled values, but does it remove them from the ledger?

What the grader checks: Real FIFO and adapter pairs, correct and with six planted faults, drive the auditor. It never reads their internal state. Passing shows that it catches these faults on these traces.

109 checks on Verilator · server. 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 9 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Reset Cancels, Then Fresh Values Flow

Input
Depth 3, correct adapter: write 0x31, 0x32, 0x33 on edges 0 to 2 with ready = 0; reset with write 0x99 on edge 4; write 0xa1, 0xa2 on edges 5 and 6; ready = 1 from edge 5
Expected output
error_edges = {}, error_kinds = {}, accepted_writes = 5, transfers = 2, reset_cancelled = 3, final_pending = 0, reset_edges = 1

Five writes are accepted in total. Reset cancels the three old ones, and the refused 0x99 never joins the ledger. Only 0xa1 and 0xa2 reach the stream. Nothing is left and no error is raised.

Run samples executes all 4 public checks. Check all tests runs 109 checks on the server.

Verilator · server