A1.2.3 Hold While Stalled

EasyImplementVerilator · serverReview the topic

Write a hold rule with $stable that applies only to locked beats: a locked beat keeps its data while it waits.

Hardware context: A valid/ready channel whose waiting beats may be replaced unless locked. State the hold rule of a locked waiting beat with $stable.

A beat is offered when valid is 1 and taken at an edge where ready is also 1. A source may replace a waiting beat, unless the beat is locked.

A beat is locked when lock is 1 at an edge where it waits. Such a beat must keep its data at the next edge, even if lock drops there.

Write one concurrent assertion on the rising edge of clk that checks this with $stable, and count its failures.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
valid1stimulus, the same for every design
ready1stimulus, the same for every design
lock1stimulus, the same for every design
data8stimulus, the same for every design
your errors32your checker's error count
Full specification
The ports (keep them)
module hold_rule (
  input  logic       clk,
  input  logic       valid, ready,
  input  logic       lock,     // 1: this beat may not be replaced while it waits
  input  logic [7:0] data,
  output int         errors
);
  // held: a locked beat keeps its data while it waits; an unlocked one may be replaced.
endmodule

The program shown here gives the sampled value of each signal at each rising edge, with data in hex:

Edge123456789101112
valid011101110110
ready000100010010
lock011100000100
data00a1a1a200b1b2b300c1c200

The full check also runs a second program that this page does not show, with another clock and other beats.

Examples

Example 1

Two Locked Beats That Move
Input
Program: 3 beats
Output
errors = 2

Beats wait at edges 2, 3, 6, 7 and 10. Only the locked ones must hold.

Example 2

The First Failure
Input
Program: 3 beats
Output
errors = 1

The locked beat a1 becomes a2 at edge 4, at t=35.

Example 3

The Second Failure
Input
Program: 3 beats
Output
errors = 1

The beat locked at edge 10 changes at 11, where lock is already 0.

Constraints and Contract

  • Use $stable(data) in one concurrent assertion.
  • Count failures in errors.
  • Do not change the ports.

Hints

Hint 1

Which edges start a check? A beat must wait, and it must be locked.

Hint 2

At which edge is lock read: the waiting edge, or the next one?

Hint 3

An unlocked beat that is replaced while it waits is legal. Does your rule stay quiet there?

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 use $stable(data) and read lock.

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

Two Locked Beats That Move

Input
Program: 3 beats
Expected output
errors = 2

Beats wait at edges 2, 3, 6, 7 and 10. Only the locked ones must hold.

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

Verilator · server