Check a request at the tick before its grant rises, with $rising_gclk on the global clock.
Hardware context: An arbiter whose grant may rise only after a request, with a requester that drops the request as the grant comes. Read the request at the global tick before the grant rises, not at the tick that sees the rise.
An arbiter raises gnt for a requester. The spec says: a grant may rise only if req was high at the global tick before the rise. The requester may drop req as the grant comes.
Write the checker grant_check. It declares sys as the global clock. Its one rule is clocked by the global clock and uses $rising_gclk. Count the failures in bad.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
sys | 1 | stimulus, the same for every design |
req | 1 | stimulus, the same for every design |
gnt | 1 | stimulus, the same for every design |
your bad | 32 | stimulus, the same for every design |
Full specification
module grant_check (
input logic sys, // the system clock: use it as the global clock
input logic req, // the request
input logic gnt, // the grant
output int bad // failures of the rule
);
// your global clocking and one rule
endmodule
| Time | What the program shown here does | Legal? |
|---|---|---|
| 12 to 23 | req is high at the tick at 15 and drops at 17; gnt rises at 23 | yes: req was high at 15 |
| 62 | gnt rises as req drops, in the same step | yes: req was high at 55 |
| 82 | gnt rises; req has been low since 62 | no |
In this program sys rises at 5, 15, 25 and so on.
The full check also runs a second program that this page does not show. Its clock and its bugs differ.
Examples
Example 1
One Grant Without a Request- Input
Program: three grants, one without a request
- Output
bad = 1
Only the grant at 82 rises with req low at the tick before.
Example 2
The Early Handshake Is Legal- Input
Program: the first grant, after req dropped at 17
- Output
bad = 0
req drops at 17, but it was high at the tick at 15, the tick before gnt rises.
Example 3
The Report Comes One Tick Late- Input
Program: up to the grant at 82
- Output
bad = 1
The attempt at 75 fails; its action runs at the next global tick, 85, before 90.
Constraints and Contract
- Declare the global clocking in the module, on the rising edge of sys.
- Clock the rule by $global_clock, and trigger it with $rising_gclk(gnt).
- Count failures in bad. Do not change the ports.
Hints
Hint 1
A rise "at the next tick" and "req high now" are both read at the same attempt, the tick before the rise.
Hint 2
$rose(gnt) is true at the tick that sees the rise. By then req may already have dropped.
Hint 3
On Verilator 5.052, clock an assertion that uses a future function by $global_clock itself.
What the grader checks: Two copies of your checker each watch a fixed program: the one shown here and a hidden one with another clock. Graded on each: the number of failures, and the number by a set time. The source must use $rising_gclk(gnt) in a concurrent assertion.
5 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