A1.3.1 The Rule That Always Passes

EasyFixVerilator · serverReview the topic

Fix a grant rule that never fails because its antecedent can never match.

Hardware context: An arbiter that grants each new request at the next edge. Make the antecedent match the event the rule is about, so the rule really checks.

Rule: a new request (req rising) is granted at the next edge. busy rises one edge after a request, so it is never 1 at the edge where req rises.

The rule below has never failed in any regression, even on traces with missing grants. Fix it so it checks every new request.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
req1stimulus, the same for every design
busy1stimulus, the same for every design
gnt1stimulus, the same for every design
your errors32your checker's error count
Full specification
The rule to fix
module grant_rule (
  input  logic clk,
  input  logic req,      // a request is held high until it is served
  input  logic busy,     // the arbiter's busy flag: it rises one edge after a request
  input  logic gnt,
  output int   errors
);
  // Never fails, in any regression. Make it check the rule.
  granted: assert property (@(posedge clk) $rose(req) && busy |=> gnt) else errors++;
endmodule

The program shown here gives the sampled value of each signal at each rising edge (at 5, 15, 25, ...):

Edge123456789101112
req011001001100
busy001100100110
gnt001000000100

The full check also runs a second program that this page does not show, with another clock and other requests.

Examples

Example 1

One Request Without a Grant
Input
Program: 3 requests
Output
errors = 1

Requests rise at edges 2, 6 and 9. Only the one at 6 has no grant at the next edge.

Example 2

The Failure Comes Early
Input
Program: 3 requests
Output
errors = 1

It is reported at edge 7, at t=65.

Example 3

A Held Request Is Not a New One
Input
Program: 3 requests
Output
errors = 0

req stays high at edge 10, but it did not rise there, so no grant is due at 11.

Constraints and Contract

  • Keep one concurrent assertion that counts failures in errors.
  • Do not change the ports.

Hints

Hint 1

At which edges can $rose(req) && busy be true?

Hint 2

An antecedent that never matches makes every attempt a vacuous success.

Hint 3

A request held for two edges is still one request: which function sees only its first edge?

What the grader checks: Two copies of your rule each watch a fixed program. One is shown here; the other is hidden, with another clock. Graded on each: failures early, later and in total.

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

One Request Without a Grant

Input
Program: 3 requests
Expected output
errors = 1

Requests rise at edges 2, 6 and 9. Only the one at 6 has no grant at the next edge.

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

Verilator · server