Write a hold rule with $stable that applies only to locked beats: a locked beat keeps its data while it waits.
Hardware context: A valid/ready channel whose waiting beats may be replaced unless locked. State the hold rule of a locked waiting beat with $stable.
A beat is offered when valid is 1 and taken at an edge where ready is also 1. A source may replace a waiting beat, unless the beat is locked.
A beat is locked when lock is 1 at an edge where it waits. Such a beat must keep its data at the next edge, even if lock drops there.
Write one concurrent assertion on the rising edge of clk that checks this with $stable, and count its failures.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
valid | 1 | stimulus, the same for every design |
ready | 1 | stimulus, the same for every design |
lock | 1 | stimulus, the same for every design |
data | 8 | stimulus, the same for every design |
your errors | 32 | your checker's error count |
Full specification
module hold_rule (
input logic clk,
input logic valid, ready,
input logic lock, // 1: this beat may not be replaced while it waits
input logic [7:0] data,
output int errors
);
// held: a locked beat keeps its data while it waits; an unlocked one may be replaced.
endmodule
The program shown here gives the sampled value of each signal at each rising edge, with data in hex:
| Edge | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| valid | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 0 |
| ready | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 |
| lock | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| data | 00 | a1 | a1 | a2 | 00 | b1 | b2 | b3 | 00 | c1 | c2 | 00 |
The full check also runs a second program that this page does not show, with another clock and other beats.
Examples
Example 1
Two Locked Beats That Move- Input
Program: 3 beats
- Output
errors = 2
Beats wait at edges 2, 3, 6, 7 and 10. Only the locked ones must hold.
Example 2
The First Failure- Input
Program: 3 beats
- Output
errors = 1
The locked beat a1 becomes a2 at edge 4, at t=35.
Example 3
The Second Failure- Input
Program: 3 beats
- Output
errors = 1
The beat locked at edge 10 changes at 11, where lock is already 0.
Constraints and Contract
- Use $stable(data) in one concurrent assertion.
- Count failures in errors.
- Do not change the ports.
Hints
Hint 1
Which edges start a check? A beat must wait, and it must be locked.
Hint 2
At which edge is lock read: the waiting edge, or the next one?
Hint 3
An unlocked beat that is replaced while it waits is legal. Does your rule stay quiet there?
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 $stable(data) and read lock.
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