A2.2.1 Exactly Three Busy Cycles

MediumImplementVerilator · serverReview the topic

Write a repetition rule that checks both bounds: busy for exactly three edges after start, then low.

Hardware context: A job engine whose busy flag must last exactly three cycles. Check both bounds of a fixed busy period with one repetition rule.

A job starts when start is 1. From the next edge, busy is high for exactly three edges, and it is low on the edge after them.

Write one concurrent assertion with a consecutive repetition, and count its failures. A job that is too short and a job that is too long are both bugs.

Signals in the Timeline

SignalWidthRole
clk1stimulus, the same for every design
start1stimulus, the same for every design
busy1stimulus, the same for every design
your errors32your checker's error count
Full specification
The ports (keep them)
module busy_three (
  input  logic clk,
  input  logic start,    // starts a job
  input  logic busy,     // high while the job runs
  output int   errors
);
  // three_busy: after start, busy on the next three edges, then low on the edge after them.
endmodule

The program shown here gives the sampled value of each signal at each rising edge (at 5, 15, 25, ...):

Edge123456789101112131415
start010000100001000
busy001110011110110

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

Examples

Example 1

Two Bad Jobs
Input
Program: 3 jobs
Output
errors = 2

Jobs start at edges 2, 7 and 12. Only the first one is busy for exactly three edges.

Example 2

One Failure by t=110
Input
Program: 3 jobs
Output
errors = 1

The job from edge 7 is still busy on its fourth edge.

Example 3

One Failure After t=110
Input
Program: 3 jobs
Output
errors = 1

The job from edge 12 stops after two busy edges.

Constraints and Contract

  • Use busy[*3] in one concurrent assertion.
  • Check the low edge after the three busy edges too.
  • Count failures in errors.
  • Do not change the ports.

Hints

Hint 1

On which edge does the job start: the edge of start, or the next one?

Hint 2

Which part of the rule fails a job that stays busy for four edges?

Hint 3

A range such as [*1:3] at the end of a rule passes at its shortest match.

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 busy[*3].

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

Two Bad Jobs

Input
Program: 3 jobs
Expected output
errors = 2

Jobs start at edges 2, 7 and 12. Only the first one is busy for exactly three edges.

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

Verilator · server