A1.9.2 Which Planned Rule Catches It?

EasyDebugVerilator · serverReview the topic

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

SignalWidthRole
question4input of each check
Full specification
The read-channel plan (rows R1 to R5)
  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;
The handshake plan of the worked examples (rows H1 to H3)
  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 exampleSignaledge 1edge 2edge 3edge 4edge 5edge 6
q=0req010000
q=0ack010100
q=1req010110
q=1ack000010
q=2req011100
q=2ack000100

The bench writes each value at the falling edge before the rising edge that samples it. Edge k is at time 10k - 5.

Edge12345678910111213
arvalid0100000100000
rvalid0001110001000
rready0000010001000
rdata000000a5a5a50000003c000000
qChange to the trace aboveKind
0handshake: ack at edge 4 with req lowworked example
1handshake: req drops at edge 3 before any ackworked example
2handshake: req waits two edges, then ackworked example
3rdata changes to a6 at edge 5, while the beat still waitsgraded
4rvalid drops at edge 5 and returns at edge 6, rdata unchangedgraded
5the second beat arrives at edge 12 instead of edge 10graded
6an extra beat at edge 7, taken at once, with no requestgraded
7at edge 5 rvalid drops and rdata goes to 11; at edge 6 the beat is backgraded

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

Report a problem with this page

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

An Acknowledge Nobody Asked For

Input
answer(0)
Expected 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.

Run samples executes all 3 public checks. Check all tests runs 8 checks on the server.

Verilator · server