A3.3.1 Never This Pattern

MediumImplementVerilator · serverReview the topic

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

SignalWidthRole
clk1stimulus, the same for every design
start1stimulus, the same for every design
err1stimulus, the same for every design
abort1stimulus, the same for every design
your window_errors32stimulus, the same for every design
your pair_errors32stimulus, the same for every design
Full specification
The ports (keep them)
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, ...):

Edge123456789101112
start100001000000
err000100010100
abort011000101000

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 not on 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

Report a problem with this page

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

Errors Inside the Windows

Input
Program: 2 starts, 3 errors, 4 aborts
Expected 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.

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

Verilator · server