A1.1.1 Spec Sentences to Rules

EasyImplementVerilator · serverReview the topic

Turn three sentences of a write-response spec into three concurrent assertions, one per sentence.

Hardware context: An AXI-style write response channel: write end, valid, ready and response code. Turn each spec sentence into one concurrent assertion.

A write slave ends each write with wdone, then offers a response with bvalid and bresp. The master takes it with bready.

Write one concurrent assertion per spec sentence, clocked on the rising edge of clk. Count each failure of each rule in its own counter.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
wdone1stimulus, the same for every design
bvalid1stimulus, the same for every design
bready1stimulus, the same for every design
bresp2stimulus, the same for every design
your resp_errors32stimulus, the same for every design
your code_errors32stimulus, the same for every design
your gap_errors32stimulus, the same for every design
Full specification
The ports and the three sentences (keep the ports)
module bresp_spec (
  input  logic       clk,
  input  logic       wdone,          // 1 at the edge where the last write beat is taken
  input  logic       bvalid, bready,
  input  logic [1:0] bresp,
  output int         resp_errors,    // sentence 1
  output int         code_errors,    // sentence 2
  output int         gap_errors      // sentence 3
);
  // 1. The write response is offered one edge after the write ends.
  // 2. This slave has no exclusive access: an offered response never carries EXOKAY (bresp = 1).
  // 3. Once a response is taken, bvalid is low at the next edge.
endmodule

The program shown here gives the sampled value of each signal at each rising edge:

Edge123456789101112
wdone010001001000
bvalid001100110010
bready010100100010
bresp000010100020

Between offers, bresp may hold any value: only an offered response is checked. The full check also runs a second program that this page does not show, with another clock and other bugs.

Examples

Example 1

A Missing Response
Input
Program: 3 writes, 3 bugs
Output
resp_errors = 1

Writes end at edges 2, 6 and 9. Only the one at 9 has nothing offered at the next edge.

Example 2

A Forbidden Response Code
Input
Program: 3 writes, 3 bugs
Output
code_errors = 1

bresp is 1 at edges 5 and 7. Only edge 7 offers a response.

Example 3

A Response Offered Twice
Input
Program: 3 writes, 3 bugs
Output
gap_errors = 1

Responses are taken at edges 4, 7 and 11. Only one of them is still offered at the next edge.

Constraints and Contract

  • One concurrent assertion per sentence, each counting its own failures.
  • Do not change the ports.

Hints

Hint 1

For each sentence, ask: which edge starts a check, and is the result due at that edge or at the next one?

Hint 2

Sentence 2 is only about offered responses. What should an attempt do at an edge where nothing is offered?

Hint 3

A response is taken at an edge where bvalid and bready are both 1.

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 three failure counts.

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

A Missing Response

Input
Program: 3 writes, 3 bugs
Expected output
resp_errors = 1

Writes end at edges 2, 6 and 9. Only the one at 9 has nothing offered at the next edge.

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

Verilator · server