Write one checking task with an immediate assume, a cover and an assert, each in the right place.
Hardware context: A transfer checker task called once per bus transfer, with a mode, a length and a response. State bench promises with assume, design rules with assert, and count a scenario with cover.
A bench calls check_beat(mode, len, resp) once per transfer. Write the task, using an immediate check of the right kind for each rule.
The bench promises never to send mode 3: that is an assumption. The design must answer with resp == len: that is an assertion. A zero-length transfer has no response, so the task returns before the response check.
Count every zero-length transfer with a cover. The simulators used here never run the statement of an immediate cover, so also count it yourself with if (len == 0) zero_hits++;.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 4 | input of each check |
Full specification
// Counters the grader reads.
int env_errors = 0; // broken promises of the bench (assume)
int dut_errors = 0; // broken rules of the design (assert)
int zero_hits = 0; // zero-length transfers seen (cover, counted by hand)
// Called once per transfer.
task automatic check_beat(input logic [1:0] mode, input logic [7:0] len, input logic [7:0] resp);
// 1. The bench promises never to send mode 3.
// 2. Count a zero-length transfer: write the cover, and the counter beside it.
// 3. A zero-length transfer has no response: return here for it.
// 4. The design must echo the length: resp == len.
endtask
| Counter | Goes up when |
|---|---|
| env_errors | the bench breaks its promise (the assume fails) |
| dut_errors | the design breaks its rule (the assert fails) |
| zero_hits | a transfer has len == 0 |
Simulator note: Standard behaviour: an immediate cover runs its statement each time its expression is true. Verilator 5.052 and Icarus 12 never run it (measured 2026-11-12), so the grader reads zero_hits instead.
The full check also runs a second batch of calls that this page does not show, with other counts.
Examples
Example 1
Mode 3 Is the Bench's Fault- Input
6 calls: 1 with mode 3
- Output
env_errors = 1
Call 3 breaks the promise. It counts in env_errors, not dut_errors.
Example 2
A Wrong Length Is the Design's Fault- Input
6 calls: 1 with resp != len
- Output
dut_errors = 1
Call 4 answers 7 for a length of 8. The zero-length calls are never checked, so they add nothing.
Example 3
Both Zero-Length Calls Are Covered- Input
6 calls: 2 with len 0
- Output
zero_hits = 2
Calls 2 and 5 have len 0, so zero_hits is 2.
Constraints and Contract
- Use an immediate assume for the mode rule and an immediate assert for the length rule.
- Write the cover and the zero_hits counter before the return.
- Keep the counter names and the task header.
Hints
Hint 1
Who breaks the rule "mode is never 3": the bench or the design? That decides between assume and assert.
Hint 2
A return ends the task. Anything after it does not run for a zero-length transfer.
Hint 3
The cover's condition is the scenario you want to see happen, not its opposite.
What the grader checks: Two batches of calls of your task: the six shown here and a hidden batch with other counts. Graded: the three counters after each batch. The source must use assume for the mode rule, assert for the length rule, and a cover before the return.
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 3 steps and the final capstone