A6.8.1 Measure the Glitch

MediumImplementVerilator · serverReview the topic

Flag every high or low phase shorter than a minimum or longer than a maximum, with assertions clocked by the line itself.

Hardware context: A clock-enable line driven by another block, with a minimum high and low time. Measure every phase between two changes and flag the ones shorter than the minimum.

A clock-enable line g comes from another block. Every high phase and every low phase must last at least MIN time units, and at most MAX. A shorter phase is a glitch; a longer one means the line is stuck.

Write the checker glitch_check. Its assertions are clocked by every change of g. Each stores $time in a local variable and compares at the next change. Count the failures in short and stuck.

Signals in the Timeline

SignalWidthRole
g1stimulus, the same for every design
your short32stimulus, the same for every design
Full specification
The ports (keep them)
module glitch_check #(parameter time MIN = 3, parameter time MAX = 100) (
  input  logic g,        // the watched line
  output int   short,    // phases, high or low, shorter than MIN
  output int   stuck     // phases longer than MAX
);
  // your properties and assertions
endmodule
PhaseFromToWidth (MIN = 3, MAX = 10)
high5105
low10122: a glitch
high12153: legal
low15161: a glitch
high16182: a glitch
low183012: stuck
high30344

The full check also runs a second program with MIN = 4, MAX = 8 and other widths. This page does not show it.

Examples

Example 1

Three Glitches
Input
Program: MIN = 3, phases 5, 2, 3, 1, 2, 12, 4
Output
short = 3

The phases of 2, 1 and 2 are shorter than 3. The phase of exactly 3 is legal.

Example 2

Only the First One by 14
Input
Program: MIN = 3, up to t=14
Output
short = 1

By t=14 only the low phase from 10 to 12 has ended short.

Example 3

The Exact Minimum Passes
Input
Program: MIN = 3, up to t=17
Output
short = 2

By 17 the phase of 3 (12 to 15) passed and the phase of 1 (15 to 16) failed.

Constraints and Contract

  • Clock the assertion by every change of g, and capture $time in a local variable.
  • A phase of exactly MIN, or exactly MAX, is legal. Use the parameters, not numbers.
  • Count failures in short and stuck. Do not change the ports.

Hints

Hint 1

A local variable is declared inside a property: property p; time t0; ... endproperty.

Hint 2

Assign it in a match item at the start of the attempt: (1'b1, t0 = $time).

Hint 3

|=> on the clock @(g) waits for the next change of g, rising or falling.

What the grader checks: Two copies of your checker each watch a fixed program: the one shown here (MIN = 3, MAX = 10) and a hidden one. Graded on each: the short phases, the stuck phases, and the short ones by a set time. The source must contain a concurrent assertion.

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

Three Glitches

Input
Program: MIN = 3, phases 5, 2, 3, 1, 2, 12, 4
Expected output
short = 3

The phases of 2, 1 and 2 are shorter than 3. The phase of exactly 3 is legal.

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

Verilator · server