A1.2.1 What the Assertion Saw

EasyDebug10 minKey measured on Verilator 5.052Review the topic

A counter is written exactly at each rising edge. Say what one assertion reports at each of six edges.

Hardware context: A step-by-one counter watched by a concurrent assertion. Name the value an assertion samples at each edge, before the edge changes it.

A 4-bit counter cnt must only step up by one. The rule is step_by_one: assert property (@(posedge clk) $changed(cnt) |-> cnt == $past(cnt) + 4'd1);.

The bench declares logic [3:0] cnt = 4'd5;. Then, right after @(posedge clk), it writes the counter at 5, 15, 25 and 45. It writes the values 6, 7, 9 and 8.

Every edge starts an attempt. For each of the six edges, choose what that attempt reports: pass, fail, vacuous success, or still pending.

The Assertion and the Trace

A Counter Written at Each Edge$changed(cnt) |-> cnt == $past(cnt) + 4'd1
A counter written at each edgeAttempts start at edge 1 (t=5), edge 2 (t=15), edge 3 (t=25), edge 4 (t=35), edge 5 (t=45), edge 6 (t=55).edgetime15215325435545655clkcnt56798attemptsattempt @5?attempt @15?attempt @25?attempt @35?attempt @45?attempt @55?
Scroll horizontally ↔
Read the sampled values as text
  • cnt: edge 1 = 5, edge 2 = 6, edge 3 = 7, edge 4 = 9, edge 5 = 9, edge 6 = 8

How to Answer

For each edge, choose the verdict of the attempt that starts at that edge.

  • Answer every listed edge: the verdict of the attempt that starts there.
  • Read the values the assertion samples at each edge (the dots), not the values after the edge.
  • Run grades the first attempt and says whether it is right. Submit grades every attempt and says only whether all are right.
Full specification
Bench stepTimeValue written to cnt
declaration05
after @(posedge clk)56
after @(posedge clk)157
after @(posedge clk)259
after @(posedge clk)35no write
after @(posedge clk)458

The clock rises at 5, 15, 25, 35, 45 and 55. The run ends at 60, so the edge at 55 is the last one.

Simulator note: The key was measured on Verilator 5.052 with one copy of the assertion per edge (tools/sva-threads.mjs, run a12-counter-step).

Hints

Hint 1

A value written at an edge is not part of that edge's sample. The assertion sees it at the next edge.

Hint 2

At the first edge there is no earlier edge. $past then returns the value the variable was declared with.

Hint 3

When $changed(cnt) is false, the implication has nothing to check: that attempt is a vacuous success.

What is checked: The verdict of the attempt at each of the six edges, against the key measured on Verilator 5.052.

More problems on this topic

Report a problem with this page

Your answers 6 attemptsSaved locally

$changed(cnt) |-> cnt == $past(cnt) + 4'd1

AttemptVerdictResult
attempt @5starts at edge 1 (t=5)
attempt @15starts at edge 2 (t=15)
attempt @25starts at edge 3 (t=25)
attempt @35starts at edge 4 (t=35)
attempt @45starts at edge 5 (t=45)
attempt @55starts at edge 6 (t=55)

Edges and times match the trace figure. Your answers stay in this browser until you submit.

Not checked yet

Run checks the first attempt. Submit checks every attempt.

Key measured on Verilator 5.052