Write two window rules with bounded always: valid through the two edges after start, and busy low through a later window.
Hardware context: A transfer engine with a start pulse, a valid window and a quiet period after done. Check every edge of a fixed window with a bounded always.
Write two concurrent assertions on the rising edge of clk, each with a bounded always.
Rule held: valid is 1 at each of the two edges after start. Rule quiet: busy is 0 at each edge from the second to the fourth after done. The first edge after done is not checked.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
start | 1 | stimulus, the same for every design |
valid | 1 | stimulus, the same for every design |
done | 1 | stimulus, the same for every design |
busy | 1 | stimulus, the same for every design |
your valid_errors | 32 | stimulus, the same for every design |
your busy_errors | 32 | stimulus, the same for every design |
Full specification
module window_rules (
input logic clk,
input logic start, valid, // valid must hold at the two edges after start
input logic done, busy, // busy must stay low from the second to the fourth edge after done
output int valid_errors, // rule held
output int busy_errors // rule quiet
);
// held: valid is 1 at each of the two edges after start.
// quiet: busy is 0 at each edge from the second to the fourth after done.
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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| start | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| valid | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| done | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| busy | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 |
The full check also runs a second program that this page does not show, with another clock and other windows.
Examples
Example 1
A Window Cut Short- Input
Program: 2 starts, 1 done
- Output
valid_errors = 1
The start at edge 1 is followed by valid twice. The start at edge 5 is not: valid drops at edge 7.
Example 2
The First Edge After Done Is Free- Input
Program: 2 starts, 1 done
- Output
busy_errors = 1
busy at edge 9 is allowed. busy at edge 11 is inside the window.
Example 3
Two Failures in All- Input
Program: 2 starts, 1 done
- Output
total = 2
One from each rule.
Constraints and Contract
- Use a bounded always in each rule.
- Count failures in valid_errors and busy_errors.
- Do not change the ports.
Hints
Hint 1
always [m:n] p needs p at every edge of the window, counted from the attempt's edge.
Hint 2
A ranged delay ##[1:2] is satisfied by one edge. Is that the rule?
Hint 3
For quiet, the window starts two edges after done.
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. Each rule must use a bounded always.
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 4 steps and the final capstone