Read a plan of read-channel rules and say, for each planted bug, exactly which rows fail.
Hardware context: A read data channel with a five-row assertion plan, one row a cover. Say exactly which planned rows fail for each planted bug.
A read channel has a plan of five rows. R1 to R4 are assertions. R5 is a cover row: it records a scenario and never fails.
A bench replays one trace, edge by edge. Each graded question changes the trace with one bug. Write answer(q) so it returns a mask of the rows that fail: bit 0 for R1, up to bit 4 for R5.
Questions 0 to 2 are worked examples on a smaller handshake plan. Questions 3 to 7 are the read-channel bugs, graded only by the full check.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 4 | input of each check |
Full specification
int f1 = 0, f2 = 0, f3 = 0, f4 = 0, f5 = 0;
logic pending = 0; // a request is waiting for its beat
always @(posedge clk)
if (arvalid) pending <= 1;
else if (rvalid && rready) pending <= 0;
// R1: an offered beat stays offered until it is taken.
r1_hold: assert property (@(posedge clk) rvalid && !rready |=> rvalid) else f1++;
// R2: rdata does not change while the beat waits.
r2_stable: assert property (@(posedge clk) rvalid && !rready |=> $stable(rdata)) else f2++;
// R3: a request is answered within three edges.
r3_fast: assert property (@(posedge clk) $rose(arvalid) |-> ##[1:3] rvalid) else f3++;
// R4: no beat without a waiting request.
r4_asked: assert property (@(posedge clk) rvalid |-> pending) else f4++;
// R5 (cover row): a stalled beat. Counted by hand; a cover never fails.
always @(posedge clk) if (rvalid && !rready) f5 += 0;
int h1 = 0, h2 = 0, h3 = 0;
// H1: a request stays up until it is acknowledged.
h1_hold: assert property (@(posedge clk) req && !ack |=> req) else h1++;
// H2: no acknowledge without a request.
h2_no_ack: assert property (@(posedge clk) ack |-> req) else h2++;
// H3 (cover row): a request that waits at least one edge. Counted by hand.
always @(posedge clk) if (req && !ack) h3 += 0;
| Worked example | Signal | edge 1 | edge 2 | edge 3 | edge 4 | edge 5 | edge 6 |
|---|---|---|---|---|---|---|---|
| q=0 | req | 0 | 1 | 0 | 0 | 0 | 0 |
| q=0 | ack | 0 | 1 | 0 | 1 | 0 | 0 |
| q=1 | req | 0 | 1 | 0 | 1 | 1 | 0 |
| q=1 | ack | 0 | 0 | 0 | 0 | 1 | 0 |
| q=2 | req | 0 | 1 | 1 | 1 | 0 | 0 |
| q=2 | ack | 0 | 0 | 0 | 1 | 0 | 0 |
The bench writes each value at the falling edge before the rising edge that samples it. Edge k is at time 10k - 5.
| Edge | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| arvalid | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| rvalid | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| rready | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| rdata | 00 | 00 | 00 | a5 | a5 | a5 | 00 | 00 | 00 | 3c | 00 | 00 | 00 |
| q | Change to the trace above | Kind |
|---|---|---|
| 0 | handshake: ack at edge 4 with req low | worked example |
| 1 | handshake: req drops at edge 3 before any ack | worked example |
| 2 | handshake: req waits two edges, then ack | worked example |
| 3 | rdata changes to a6 at edge 5, while the beat still waits | graded |
| 4 | rvalid drops at edge 5 and returns at edge 6, rdata unchanged | graded |
| 5 | the second beat arrives at edge 12 instead of edge 10 | graded |
| 6 | an extra beat at edge 7, taken at once, with no request | graded |
| 7 | at edge 5 rvalid drops and rdata goes to 11; at edge 6 the beat is back | graded |
A changed edge keeps the other signals of the table. The trace has 13 edges, so a check that ends by edge 13 is decided.
Examples
Example 1
An Acknowledge Nobody Asked For- Input
answer(0)
- Output
mask = 2
At edge 4 ack is 1 and req is 0, so H2 fails. H1 never starts there, because req is 0. The answer is bit 1 only: 2.
Example 2
A Request Withdrawn Too Early- Input
answer(1)
- Output
mask = 1
req waits at edge 2 with no ack, then drops at edge 3: H1 fails. The ack at edge 5 has req high, so H2 passes. Answer: bit 0, 1.
Example 3
A Legal Run That Hits the Cover Row- Input
answer(2)
- Output
mask = 0
The request waits at edges 2 and 3 and is answered at 4. Nothing fails. H3 is hit, but a cover row records a scenario, never a bug. Answer: 0.
Constraints and Contract
- Return one mask per question from answer(q).
- Keep the function header.
Hints
Hint 1
Take one row at a time. At which edges does its antecedent match on the changed trace?
Hint 2
A cover row records a scenario. Can it ever be the row that catches a bug?
Hint 3
One bug can break two rows, and a row can stay quiet when a bug only touches its antecedent.
What the grader checks: Eight constant answers: three worked examples and five graded bugs. They are graded against masks measured on Verilator 5.052.
8 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 2 steps and the final capstone