A9.1.3 Assume in Simulation

EasyFixVerilator · serverReview the topic

A link checker blames the wrong side. Write the bench promise as an assume and the design rule as an assert.

Hardware context: A request link where the bench drives req and the design drives busy. Blame the right side: assume what the bench drives, assert what the design drives.

A link has two rules. The bench promises never to request while the design is busy. The design promises to be busy at the edge after a request.

The checker link_rules has the directives swapped, and one rule checks the wrong cycle. Fix it, so that each failure lands in the right counter and blames the right side.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
busy1stimulus, the same for every design
req1stimulus, the same for every design
Full specification
The ports (keep them)
module link_rules (
  input  logic clk,
  input  logic busy,      // driven by the design
  input  logic req,       // driven by the bench
  output int   bench_bad, // failures of the bench's promise
  output int   dut_bad    // failures of the design's rule
);
  // two rules
endmodule
EdgeWhat the program shown here doesExpected
15, 25a request, then busyno failure
35, 45the bench requests while busy; busy stays highbench_bad fails once
55, 65a request, and the design is not busy at the next edgedut_bad fails once

The full check also runs a second program with another clock. This page does not show it.

Examples

Example 1

The Bench Breaks Its Promise Once
Input
Program: a request while busy at 35
Output
bench_bad = 1

At 35 the bench requests while busy is high.

Example 2

The Design Breaks Its Rule Once
Input
Program: no busy after the request at 55
Output
dut_bad = 1

After the request at 55, busy is still low at 65.

Example 3

The Bench Promise Fails First
Input
Program: up to t=40
Output
bench_bad = 1

The request at 35 comes while busy, before 40.

Constraints and Contract

  • The bench promise is an assume property; the design rule is an assert property.
  • Count failures of the bench promise in bench_bad and of the design rule in dut_bad.
  • Do not change the ports.

Hints

Hint 1

Ask of each rule: who drives the signal it constrains?

Hint 2

In simulation an assume fails like an assert. The directive tells the reader, and a formal tool, whom to blame.

Hint 3

"Busy at the edge after a request" is one cycle later than the request itself.

What the grader checks: Two copies of your checker each watch a fixed program: the one shown here and a hidden one. Graded on each: both failure counts. Source rules check the two directives.

5 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 3 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

The Bench Breaks Its Promise Once

Input
Program: a request while busy at 35
Expected output
bench_bad = 1

At 35 the bench requests while busy is high.

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

Verilator · server