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
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
sop | 1 | stimulus, the same for every design |
hdr | 1 | stimulus, the same for every design |
beat | 1 | stimulus, the same for every design |
last | 1 | stimulus, the same for every design |
your errors | 32 | your checker's error count |
Full specification
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, ...):
| Edge | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| sop | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| hdr | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| beat | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 |
| last | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
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