State two "must never happen" rules with not: no error in a window after start, and never two aborts in a row.
Hardware context: A transfer engine with an error flag and an abort line. State patterns that must never happen with not, inside and outside an implication.
Write two concurrent assertions on the rising edge of clk, each with the not operator.
Rule quiet: after start, err is 0 at each of the next three edges. Rule single_abort: abort is never 1 at two edges in a row.
Count each failure of each rule in its own counter.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
start | 1 | stimulus, the same for every design |
err | 1 | stimulus, the same for every design |
abort | 1 | stimulus, the same for every design |
your window_errors | 32 | stimulus, the same for every design |
your pair_errors | 32 | stimulus, the same for every design |
Full specification
module never_rules (
input logic clk,
input logic start, err, abort,
output int window_errors, // rule quiet
output int pair_errors // rule single_abort
);
// quiet: after start, err is 0 at each of the next three edges.
// single_abort: abort is never 1 at two edges in a row.
endmodule
The program shown here gives the sampled value of each signal at each rising edge (at 5, 15, 25, ...):
| Edge | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| start | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| err | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| abort | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
The full check also runs a second program that this page does not show, with another clock and other errors.
Examples
Example 1
Errors Inside the Windows- Input
Program: 2 starts, 3 errors, 4 aborts
- Output
window_errors = 2
The windows after the starts at edges 1 and 6 hold the errors at edges 4 and 8. The error at edge 10 is outside both.
Example 2
Two Aborts in a Row- Input
Program: 2 starts, 3 errors, 4 aborts
- Output
pair_errors = 1
Edges 2 and 3 both have abort. The aborts at 7 and 9 have a gap between them.
Example 3
Both Rules Together- Input
Program: 2 starts, 3 errors, 4 aborts
- Output
total = 3
Three failures in all: two windows and one pair.
Constraints and Contract
- Write each rule as a concurrent assertion that uses
noton the pattern that must never happen. - Count failures in window_errors and pair_errors.
- Do not change the ports.
Hints
Hint 1
Which sequence must never match: "err at some edge one to three edges later"?
Hint 2
##[1:3] !err asks for one quiet edge. Is that the rule?
Hint 3
Keep the not inside the implication: only edges with start have a window to check.
What the grader checks: Two copies of your rules each watch a fixed program: the one shown here and a hidden one with another clock. Graded on each: the two failure counts. The source must use not in both rules.
6 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 4 steps and the final capstone