A7.1.4 Rules in an Interface

EasyImplementVerilator · serverReview the topic

Put the read-channel rules inside the interface, so every bus instance checks itself.

Hardware context: A read-channel interface used by many blocks. Carry the channel rules inside the interface so every bus instance checks itself.

A read channel is an interface, rd_if, used by many blocks. Rather than binding rules into each block, put them in the interface: every instance of the bus then carries its own checks.

Add two rules, clocked by the interface's clock. Data holds while a beat is stalled, and a stalled beat is not withdrawn. Count the failures in the interface's counters.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
Full specification
The interface (fill in the rules)
interface rd_if (input logic clk);
  logic       valid, ready;
  logic [7:0] data;
  int hold_f = 0, drop_f = 0;
  // Add the two rules, clocked by the interface clock:
  //   hold: while a beat is stalled, data holds at the next edge. Count in hold_f.
  //   keep: a stalled beat is not withdrawn: valid stays high at the next edge. Count in drop_f.
endinterface
BusWhat the program shown here doesExpected
bus0stalled at 15; data moves at 22hold fails once
bus1stalled at 15; valid drops at 22keep fails once

The full check also runs a second program on another bus, which this page does not show.

Examples

Example 1

Data Moved
Input
Program: data moves during a stall
Output
hold = 1

bus0 changes its data while stalled.

Example 2

Beat Withdrawn
Input
Program: a stalled beat withdrawn
Output
drop = 1

bus1 drops valid while stalled.

Example 3

Each Bus Checks Itself
Input
Program: the other rule on each bus
Output
other = 0

Each instance reports only its own bug.

Constraints and Contract

  • Write both rules inside rd_if, as concurrent assertions on its clock.
  • Count failures in hold_f and drop_f. Keep the signals and counters.

Hints

Hint 1

An interface may hold assertions, like a module. Each instance runs its own copy.

Hint 2

Clock the rules with the interface's clock port, clk.

Hint 3

Both rules look one edge after the stall: use |=>.

What the grader checks: Your interface is compiled with a fixed bench of two programs: the one shown here and a hidden one. Graded: the two failure counts of each bus instance.

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 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

Data Moved

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

bus0 changes its data while stalled.

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

Verilator · server