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
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 step | Time | Value written to cnt |
|---|---|---|
| declaration | 0 | 5 |
| after @(posedge clk) | 5 | 6 |
| after @(posedge clk) | 15 | 7 |
| after @(posedge clk) | 25 | 9 |
| after @(posedge clk) | 35 | no write |
| after @(posedge clk) | 45 | 8 |
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