A7.1.1 Bind the Rules

EasyImplementVerilator · serverReview the topic

Bind a rule module into every read port, and a tighter stall bound into one port only.

Hardware context: Three read ports of one module, one of which needs a tighter stall bound. Bind rules to every instance of a module, and enable a rule for one instance.

Three read ports share one module, port, whose source you may not edit. Every port needs the hold rules. Port 2 also needs the stall bound, with a limit of 2.

Write only bind statements. The standard binds to one instance with bind port: u2 ...; Verilator 5.052 rejects that form. Use its runnable equivalent: bind to the module type, and enable the stall rule where the instance's ID is 2.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
u2 valid1stimulus, the same for every design
u2 ready1stimulus, the same for every design
Full specification
The DUT and the two rule modules (given)
// The read port (the DUT; its source may not be edited). ID numbers the instance.
module port #(parameter int ID = 0) (input logic clk, valid, ready, input logic [7:0] data);
endmodule
// Rule module 1: data holds while a beat is stalled.
module hold_rules (input logic clk, valid, ready, input logic [7:0] data);
  int fails = 0;
  hold: assert property (@(posedge clk) valid && !ready |=> valid && $stable(data)) else fails++;
endmodule
// Rule module 2: a stall lasts at most MAX_STALL edges; checked only while en is high.
module stall_rules #(parameter int MAX_STALL = 4) (input logic clk, en, valid, ready);
  int fails = 0, run = 0;
  always @(posedge clk) run <= (valid && !ready) ? run + 1 : 0;
  bound: assert property (@(posedge clk) en |-> run <= MAX_STALL) else fails++;
endmodule
CodeEffect
Standard (IEEE 1800-2023 23.11)bind port: u2 stall_rules #(.MAX_STALL(2)) s (...);one instance; Verilator 5.052: "Unsupported: Bind with instance list"
Runnable equivalentbind port stall_rules #(.MAX_STALL(2)) s (..., .en(ID == 2), ...);every port gets an instance; only ID 2 checks
PortWhat the program shown here doesExpected
u0 (ID 0)stalled at 15 and 25; data moves at 22one hold failure
u1 (ID 1)stalled for three edges, data steadynothing
u2 (ID 2)stalled for three edges, data steadyone stall-bound failure

The full check also runs a second program, with ports of ID 2 and ID 3. This page does not show it.

Examples

Example 1

One Hold Failure
Input
Program: u0 moves its data during a stall
Output
hold = 1

Only u0 moves its data while stalled.

Example 2

Port 2 Checks the Bound
Input
Program: u2 stalls for three edges
Output
stall = 1

Three stalled edges exceed the limit of 2.

Example 3

The Other Ports Do Not
Input
Program: u1 stalls for three edges
Output
stall = 0

u1 has the same stall, but its ID is 1.

Constraints and Contract

  • Write bind statements only. Name the hold instance h and the stall instance s.
  • Every port gets the hold rules; only ID 2 checks the stall bound, with MAX_STALL = 2.

Hints

Hint 1

The actual expressions of a bind are resolved inside each target instance, so they can read its parameter ID.

Hint 2

Connect each rule port to the target signal of the same meaning.

Hint 3

Override the parameter in the bind: stall_rules #(.MAX_STALL(2)).

What the grader checks: Your binds are compiled with a fixed bench of two programs: the one shown here and a hidden one. Graded: hold failures over all ports, stall failures where they must appear, and none where they must not.

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

Report a problem with this page

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

One Hold Failure

Input
Program: u0 moves its data during a stall
Expected output
hold = 1

Only u0 moves its data while stalled.

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

Verilator · server