A3.5.1 Reset in the Middle of a Transfer

MediumFixVerilator · serverReview the topic

Fix a module's default disable iff, and let the one rule that checks reset opt out of it.

Hardware context: A valid/ready channel whose rules share one module-wide reset guard. Fix the default guard, and let the reset check opt out of it.

Two rules watch a valid/ready channel. While a beat waits, valid and data hold. When reset is asserted, valid is low at the next edge.

The module gives every rule one default reset guard. The hold rule never fires, and the reset rule never catches a valid that survives reset. Fix the guard so the hold rule is off only during reset, and the reset rule runs during reset.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
rst_n1stimulus, the same for every design
valid1stimulus, the same for every design
ready1stimulus, the same for every design
data8stimulus, the same for every design
your errors32your checker's error count
Full specification
The rules to fix
module xfer_rules (
  input  logic       clk,
  input  logic       rst_n,     // active-low reset, held across at least one edge
  input  logic       valid, ready,
  input  logic [7:0] data,
  output int         errors
);
  default disable iff (rst_n);
  // While a beat waits, valid and data hold.
  hold:   assert property (@(posedge clk) valid && !ready |=> valid && $stable(data)) else errors++;
  // Reset clears valid at the next edge.
  clears: assert property (@(posedge clk) !rst_n |=> !valid) else errors++;
endmodule

The program shown here gives the sampled value of each signal at each rising edge, with data in hex:

Edge12345678910111213141516
rst_n0111101111100111
valid0011101111000000
ready0001000001000000
data0000a1a1b200c3c3c4c4000000000000

Reset is held across whole edges in both programs. The full check also runs a second program that this page does not show, with another clock, other resets and other beats.

Examples

Example 1

Two Real Bugs
Input
Program: 3 beats, 2 resets
Output
errors = 2

One is a valid that survives a reset; the other is a data change during a stall.

Example 2

A Reset During a Stall Is No Failure
Input
Program: 3 beats, 2 resets
Output
errors = 1

The stall from edge 5 is cut by the reset at edge 6. That attempt is disabled.

Example 3

The Second Reset Is Clean
Input
Program: 3 beats, 2 resets
Output
errors = 1

Reset at edges 12 and 13 with valid low after both: nothing to report.

Constraints and Contract

  • Keep one default disable iff for the module.
  • Keep the two rules and their names; count failures in errors.
  • Do not change the ports.

Hints

Hint 1

A guard disables a rule while its condition is true. When is rst_n true?

Hint 2

Which disable condition does the reset rule get from the default? Can that rule ever check anything?

Hint 3

A rule may name its own disable iff, and the standard gives one way to switch the default off for one rule.

What the grader checks: Two copies of your rules 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. The hold rule must take its guard from the default.

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

Two Real Bugs

Input
Program: 3 beats, 2 resets
Expected output
errors = 2

One is a valid that survives a reset; the other is a data change during a stall.

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

Verilator · server