A2.1.4 Zero Delay, Same Edge

EasyImplementVerilator · serverReview the topic

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

SignalWidthRole
clk1stimulus, the same for every design
req1stimulus, the same for every design
gnt1stimulus, the same for every design
busy1stimulus, the same for every design
your errors32your checker's error count
Full specification
The ports (keep them)
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
The two phases, as named sequences
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, ...):

Edge1234567891011121314
req01000100010000
gnt00100010000000
busy00110001100000

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

Report a problem with this page

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

Two Bad Requests

Input
Program: 3 requests
Expected output
errors = 2

Requests come at edges 2, 6 and 10. Only the first one is granted with its work on the grant edge.

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

Verilator · server