Join two named sequences with ##0, so the second one starts on the edge where the first one ends.
Hardware context: A grant whose cycle is also the first cycle of the work it starts. Join two named phases on their shared cycle with ##0.
After a request, gnt comes at the next edge. The grant edge is also the first edge of the work: busy on that edge and the next, then busy low.
Declare the two phases as the named sequences below. Then write one concurrent assertion that joins them on the grant edge, and count its failures.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
req | 1 | stimulus, the same for every design |
gnt | 1 | stimulus, the same for every design |
busy | 1 | stimulus, the same for every design |
your errors | 32 | your checker's error count |
Full specification
module grant_work (
input logic clk,
input logic req, gnt, busy,
output int errors
);
// Declare the two named sequences of the spec, granted and work.
// grant_then_work: after a request, granted, and work that starts on the grant edge.
endmodule
sequence granted; ##1 gnt; endsequence // gnt one edge after the request
sequence work; busy ##1 busy ##1 !busy; endsequence // two busy edges, then idle
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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| req | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| gnt | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| busy | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
The full check also runs a second program that this page does not show, with another clock and other requests.
Examples
Example 1
Two Bad Requests- Input
Program: 3 requests
- Output
errors = 2
Requests come at edges 2, 6 and 10. Only the first one is granted with its work on the grant edge.
Example 2
The Good Request Comes First- Input
Program: 3 requests
- Output
errors = 0
The request at edge 2 is granted at 3, and busy covers 3 and 4.
Example 3
Both Failures Come Later- Input
Program: 3 requests
- Output
errors = 2
The request at 6 has its busy edges one edge too late. The request at 10 is never granted.
Constraints and Contract
- Declare the named sequences granted and work as given, and join them with ##0 in one concurrent assertion.
- Count failures in errors.
- Do not change the ports.
Hints
Hint 1
On which edge does granted end?
Hint 2
Which delay lets the next sequence start on that same edge?
Hint 3
A missing grant is a failure too. Should gnt be in the antecedent?
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 join granted and work with ##0.
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 6 steps and the final capstone