Write one read rule in which a flush cancels the waiting read and an error fails it, both at the clock edge.
Hardware context: A read port with a flush and an error line. Cancel or fail a waiting read with the synchronous abort operators.
A read (rd) is answered by rvalid 1 to 3 edges later. While the read waits, a flush cancels it: no failure. An err while it waits fails it at the edge where err is seen.
Write one concurrent assertion with sync_accept_on and sync_reject_on, and count its failures. An err or a flush while no read waits is legal.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
rd | 1 | stimulus, the same for every design |
rvalid | 1 | stimulus, the same for every design |
flush | 1 | stimulus, the same for every design |
err | 1 | stimulus, the same for every design |
your errors | 32 | your checker's error count |
Full specification
module read_abort (
input logic clk,
input logic rd, // a read request
input logic rvalid, // the read data
input logic flush, // cancels the waiting read
input logic err, // fails the waiting read
output int errors
);
// answered: after rd, rvalid within 1 to 3 edges. While the read waits, flush cancels it (no failure)
// and err fails it at the edge where err is seen.
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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| rd | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| rvalid | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| flush | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| err | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
The full check also runs a second program that this page does not show, with another clock and other reads.
Examples
Example 1
Two Bad Reads- Input
Program: 4 reads
- Output
errors = 2
Reads start at edges 2, 5, 8 and 12. One is failed by an error, one is never answered.
Example 2
The Error Comes First- Input
Program: 4 reads
- Output
errors = 1
The read from edge 5 sees err at 6.
Example 3
The Late Failure- Input
Program: 4 reads
- Output
errors = 1
The read from edge 12 has no rvalid in its window.
Constraints and Contract
- Use sync_accept_on (flush) and sync_reject_on (err) in one concurrent assertion.
- Count failures in errors.
- Do not change the ports.
Hints
Hint 1
Where must the aborts go, so that a flush or an err with no read waiting changes nothing?
Hint 2
Which abort gives a pass, and which a failure?
Hint 3
Would disable iff (err) fail the read, or only switch the check off?
What the grader checks: Two copies of your rule each watch a fixed program. One is shown here; the other is hidden, with another clock. Graded on each: failures early, later and in total. The rule must use both sync_ aborts.
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