A7.6.1 Silence the Passes, Keep the Failures

MediumDebugIcarus · browser samples / server checksReview the topic

Follow $assertfailoff, $assertpassoff, $assertfailon and $assertpasson through a run, and count what the log shows.

Hardware context: A regression log flooded by pass messages of a mostly idle handshake rule. Silence pass messages without losing a single failure report.

A log-cleanup script switches the action blocks of a handshake rule during a run. The rule is checked at every edge; only its action blocks are switched.

Write answer(q). Questions 3 to 7 ask what the pass and fail actions record in the main program.

Questions 0 to 2 are worked examples on a smaller program. Questions 3 to 7 are graded only by the full check.

Signals in the Timeline

SignalWidthRole
question4input of each check
Full specification
The main program, questions 3 to 7
module tb;
  logic clk = 0;
  always #5 clk = ~clk;                         // rising edges at 5, 15, ..., 95
  logic req = 0, ack = 0;
  int passes = 0, fails = 0, passes_50 = 0;
  hs: assert property (@(posedge clk) req |-> ack)
    begin passes++; $display("hs passes at %0t", $time); end
    else begin fails++; $display("hs fails at %0t", $time); end
  initial begin
    #17 $assertfailoff;                         // t=17
    #20 $assertpassoff;                         // t=37
    #13 passes_50 = passes;                     // t=50
    #7  $assertfailon;                          // t=57
    #20 $assertpasson;                          // t=77
  end
  initial begin
    #12 req = 1; ack = 1;                       // edge 15: real pass
    #10 ack = 0;                                // edge 25: fail
    #10 ack = 1;                                // edge 35: real pass
    #10 ack = 0;                                // edge 45: fail
    #10 req = 0;                                // edge 55: vacuous
    #10 req = 1;                                // edge 65: fail
    #10 ack = 1;                                // edge 75: real pass
    #10 ack = 0;                                // edge 85: fail
    #10 ack = 1;                                // edge 95: real pass
    #6  $finish;                                // t=98
  end
endmodule
qReturnProgram
0the value of p printed at 34worked example
1the value of f printed at 34worked example
2the time of the first chk failure printworked example
3the value of fails at the endmain, graded
4the time of the first "hs fails" printmain, graded
5the value of passes at the endmain, graded
6the value of passes_50main, graded
7the time of the last "hs passes" printmain, graded
The worked examples, questions 0 to 2
module tb;
  logic clk = 0;
  always #4 clk = ~clk;                         // rising edges at 4, 12, 20, 28
  logic ok = 1;
  int p = 0, f = 0;
  chk: assert property (@(posedge clk) ok)
    begin p++; end
    else begin f++; $display("chk fails at %0t", $time); end
  initial begin
    #10 $assertpassoff;                         // t=10
    #14 ok = 0;                                 // t=24
    #10 $display("p=%0d f=%0d", p, f);          // t=34
    $finish;
  end
endmodule

Simulator note: The key was measured on Verilator 5.052 and agrees with IEEE 1800-2023 20.11. Your answer function is checked by a small bench on Icarus 12.

Examples

Example 1

Passes Before the Switch
Input
answer(0)
Output
answer = 1

Only the pass at 4 comes before $assertpassoff at 10.

Example 2

Failures Are Untouched
Input
answer(1)
Output
answer = 1

$assertpassoff does not touch the else action. The failure at 28 counts.

Example 3

The Rule Still Checks
Input
answer(2)
Output
answer = 28

ok falls at 24, and the edge at 28 fails.

Constraints and Contract

  • Return one value per question from answer(q).
  • Keep the function header.

Hints

Hint 1

Write the result of each edge first: real pass, vacuous pass or failure. The controls never change these.

Hint 2

Then mark, for each edge, whether pass actions and fail actions are on at that moment.

Hint 3

A vacuous success runs the pass action too, while pass actions are on.

What the grader checks: Eight constant answers: three worked examples and five graded questions, measured on Verilator 5.052.

8 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 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

Passes Before the Switch

Input
answer(0)
Expected output
answer = 1

Only the pass at 4 comes before $assertpassoff at 10.

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

Icarus · browser samples / server checks