A3.7.1 The Scenario Must Happen

MediumFixVerilator · serverReview the topic

Fix a packet rule that lets packets without a header pass: the header must be there, then the beats.

Hardware context: A packet link whose start of packet must carry a header, then beats until the last. Make a scenario an obligation with followed-by instead of a vacuous implication.

At every packet start (sop), the header flag hdr must be 1. From the next edge, beat must stay 1 until the edge where last is 1.

The checker below passes packets that arrive without a header. Fix it so that a missing header fails, and keep the beat check.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
sop1stimulus, the same for every design
hdr1stimulus, the same for every design
beat1stimulus, the same for every design
last1stimulus, the same for every design
your errors32your checker's error count
Full specification
The checker to fix
module packet_check (
  input  logic clk,
  input  logic sop,     // start of a packet
  input  logic hdr,     // the header flag: must be 1 at sop
  input  logic beat,    // a data beat
  input  logic last,    // the last beat
  output int   errors
);
  // Passes packets that arrive without a header.
  packet: assert property (@(posedge clk) sop && hdr |=> (beat until_with last)) else errors++;
endmodule

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

Edge12345678910111213141516
sop1000010001000000
hdr1000000001000000
beat0111001100101100
last0001000100000100

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

Examples

Example 1

Two Bad Packets
Input
Program: 3 packet starts
Output
errors = 2

The packet at edge 6 has no header, and the packet at edge 10 drops a beat at edge 12.

Example 2

The Missing Header Counts
Input
Program: 3 packet starts
Output
errors = 1

By t=85 only the packet without a header has failed. The old rule reports nothing there.

Example 3

The Beat Check Stays
Input
Program: 3 packet starts
Output
errors = 1

The gap at edge 12 still fails, as it did before the fix.

Constraints and Contract

  • Keep one concurrent assertion that counts failures in errors.
  • Make the header an obligation with followed-by.
  • Do not change the ports.

Hints

Hint 1

In sop && hdr |=> ..., what happens when hdr is 0 at a packet start?

Hint 2

Which operator fails when its left side does not match?

Hint 3

The beats start one edge after the header: overlapped or non-overlapped?

What the grader checks: Two copies of your checker each watch a fixed program. One is shown here; the other is hidden, with another clock. Graded on each: the failure count, early and in total. The source must use followed-by.

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

Two Bad Packets

Input
Program: 3 packet starts
Expected output
errors = 2

The packet at edge 6 has no header, and the packet at edge 10 drops a beat at edge 12.

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

Verilator · server