A6.4.1 Check the Next Value Now

MediumImplementVerilator · serverReview the topic

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

SignalWidthRole
sys1stimulus, the same for every design
req1stimulus, the same for every design
gnt1stimulus, the same for every design
your bad32stimulus, the same for every design
Full specification
The ports (keep them)
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
TimeWhat the program shown here doesLegal?
12 to 23req is high at the tick at 15 and drops at 17; gnt rises at 23yes: req was high at 15
62gnt rises as req drops, in the same stepyes: req was high at 55
82gnt rises; req has been low since 62no

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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

One Grant Without a Request

Input
Program: three grants, one without a request
Expected output
bad = 1

Only the grant at 82 rises with req low at the tick before.

Run samples executes all 3 public checks. Check all tests runs 5 checks on the server.

Verilator · server