Build five read-channel rules from typed and untyped named pieces, one sequence that inherits its clock and one with its own.
Hardware context: A read channel checked by rules built from named sequences and a property with arguments. Write each piece once with the right argument kinds and build the rules from it.
Write five named pieces and five rules for a read channel. The specification names each piece, its arguments and the clock each rule uses.
Four rules are clocked on the rising edge of clk. Rule fall is the sequence on_fall alone: it brings its own falling-edge clock.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
arvalid | 1 | stimulus, the same for every design |
arready | 1 | stimulus, the same for every design |
rvalid | 1 | stimulus, the same for every design |
rready | 1 | stimulus, the same for every design |
rlast | 1 | stimulus, the same for every design |
rdata | 8 | stimulus, the same for every design |
dq_en | 1 | stimulus, the same for every design |
dqs | 1 | stimulus, the same for every design |
your fall_errors | 32 | stimulus, the same for every design |
Full specification
module read_rules (
input logic clk,
input logic arvalid, arready, // request channel
input logic rvalid, rready, rlast, // data channel
input logic [7:0] rdata,
input logic dq_en, dqs, // a strobe checked on the falling edge
output int hold_errors, // rule held
output int data_errors, // rule data
output int late_errors, // rule quick
output int gap_errors, // rule gap
output int fall_errors // rule fall
);
// property within4(trig, resp): resp at one of the 4 edges after trig (untyped formals).
// sequence waits(logic v, logic r): v is 1 and r is 0.
// sequence same(logic [7:0] d): d equals its previous sample in all 8 bits.
// sequence last_taken: rvalid, rready and rlast are all 1 (no clock of its own).
// sequence on_fall: at each falling edge of clk, dq_en is 0 or dqs is 1 (its own clock).
// held: waits(rvalid, rready) |=> rvalid on the rising edge
// data: waits(rvalid, rready) |=> same(rdata) on the rising edge
// quick: within4(arvalid && arready, rvalid) on the rising edge
// gap: last_taken |=> !rvalid on the rising edge
// fall: the sequence on_fall alone, with no clock in the assert
endmodule
| Piece | Kind | Meaning |
|---|---|---|
| within4(trig, resp) | property, untyped formals | resp is 1 at one of the 4 edges after trig |
| waits(logic v, logic r) | sequence, typed formals | v is 1 and r is 0 |
| same(logic [7:0] d) | sequence, an 8-bit typed formal | all 8 bits of d equal their previous sample |
| last_taken | sequence, no clock of its own | rvalid, rready and rlast are all 1 |
| on_fall | sequence with its own clock, @(negedge clk) | dq_en is 0, or dqs is 1 |
Simulator note: On Verilator 5.052, declare the property with untyped formals before the typed sequences, or start its list with the keyword untyped. Otherwise it rejects the property (lesson A2.3).
The program shown here gives the sampled value of each signal at each rising edge, with rdata in hex. The strobe changes between edges: dq_en is 1 from t=12 to 48, and dqs is 1 during 12-18, 22-33 and 38-42.
| Edge | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| arvalid | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
| arready | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| rvalid | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| rready | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| rlast | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| rdata | 00 | 00 | 00 | a5 | a4 | b0 | b1 | b2 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
The full check also runs a second program that this page does not show, with another clock and other bugs.
Examples
Example 1
A Waiting Beat Dropped- Input
Program 1
- Output
hold_errors = 1
At edge 4 the beat waits. It is gone at edge 5, so held fails once.
Example 2
Data That Moved While Waiting- Input
Program 1
- Output
data_errors = 1
The waiting beat a5 is a4 at the next edge. The change is in bit 0 here.
Example 3
A Request with No Answer- Input
Program 1
- Output
late_errors = 1
The request at edge 2 is answered at edge 4. The one at edge 10 sees no rvalid by edge 14. At edge 13 arready is 0, so that is not a request.
Example 4
A Beat Right After the Last One- Input
Program 1
- Output
gap_errors = 1
The last beat is taken at edge 6, and rvalid is still 1 at edge 7. The beat at edge 8 follows a beat that was not the last: legal.
Example 5
The Strobe at the Falling Edges- Input
Program 1
- Output
fall_errors = 1
Falling edges at 10, 20, 30, 40 and 50. Only the one at 20 sees dq_en without dqs.
Constraints and Contract
- Declare the five pieces with the names, argument types and clocks of the table, and build the rules from them.
- Count failures in the five counters.
- Do not change the ports.
Hints
Hint 1
A typed formal casts its actual: logic [7:0] d keeps all 8 bits of rdata, logic d would keep only bit 0.
Hint 2
within4 checks the four edges after trig, not the trigger edge itself.
Hint 3
A sequence that starts with its own clocking event, used as the whole property, brings that clock.
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 and other bugs. Graded on each: the five failure counts. The source must build each rule from its named piece.
10 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