A3.4.1 Mode-Dependent Response

MediumImplementVerilator · serverReview the topic

Write one case property for a latency that depends on a mode, and one if-else property for writes and reads.

Hardware context: A transfer engine with latency modes and a bus with writes and reads. Pick the property to check from a mode with case and from the transfer kind with if-else.

Write two concurrent assertions on the rising edge of clk. Rule by_mode is a case property on mode: when v is 1, done comes 1, 2 or 3 edges later for mode 0, 1 or 2.

Mode 3 is not checked. Rule by_kind is an if-else property: when req is 1, a write gets ack after one edge and a read gets rdy after two.

Count each failure of each rule in its own counter.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
v1stimulus, the same for every design
mode2stimulus, the same for every design
done1stimulus, the same for every design
req1stimulus, the same for every design
wr1stimulus, the same for every design
ack1stimulus, the same for every design
rdy1stimulus, the same for every design
your mode_errors32stimulus, the same for every design
your kind_errors32stimulus, the same for every design
Full specification
The ports (keep them)
module mode_rules (
  input  logic       clk,
  input  logic       v,              // a transfer starts
  input  logic [1:0] mode,           // its latency mode
  input  logic       done,           // the transfer's completion
  input  logic       req, wr,        // a request, and whether it is a write
  input  logic       ack, rdy,       // write acknowledge, read data ready
  output int         mode_errors,    // rule by_mode
  output int         kind_errors     // rule by_kind
);
  // by_mode: when v is 1, done comes 1, 2 or 3 edges later for mode 0, 1 or 2. Mode 3 is not checked.
  // by_kind: when req is 1, a write (wr = 1) gets ack after one edge, a read gets rdy after two.
endmodule

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

Edge123456789101112
v101001010000
mode001002030000
done010010000000
req101001100000
wr100001000000
ack010000000000
rdy000000001000

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

Examples

Example 1

Mode 2 Answered Too Late
Input
Program: modes 0, 1, 2, 3; 2 writes, 2 reads
Output
mode_errors = 1

Modes 0 and 1 are answered in time. Mode 2 at edge 6 never sees done at edge 9. Mode 3 is not checked.

Example 2

A Read and a Write Unanswered
Input
Program: modes 0, 1, 2, 3; 2 writes, 2 reads
Output
kind_errors = 2

The read at edge 3 has no rdy at edge 5. The write at edge 6 has no ack at edge 7.

Example 3

Three Failures in All
Input
Program: modes 0, 1, 2, 3; 2 writes, 2 reads
Output
total = 3

One from by_mode and two from by_kind.

Constraints and Contract

  • Write by_mode with a case property and by_kind with an if-else property.
  • Count failures in mode_errors and kind_errors.
  • Do not change the ports.

Hints

Hint 1

Each case item is a whole property, such as ##2 done.

Hint 2

Mode 3 is not checked. What should its item, or the default, say?

Hint 3

Without an else, reads are never checked.

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: the two failure counts. The source must use a case property and an if-else property.

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

Mode 2 Answered Too Late

Input
Program: modes 0, 1, 2, 3; 2 writes, 2 reads
Expected output
mode_errors = 1

Modes 0 and 1 are answered in time. Mode 2 at edge 6 never sees done at edge 9. Mode 3 is not checked.

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

Verilator · server