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
| Signal | Width | Role |
|---|---|---|
g | 1 | stimulus, the same for every design |
your short | 32 | stimulus, the same for every design |
Full specification
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
| Phase | From | To | Width (MIN = 3, MAX = 10) |
|---|---|---|---|
| high | 5 | 10 | 5 |
| low | 10 | 12 | 2: a glitch |
| high | 12 | 15 | 3: legal |
| low | 15 | 16 | 1: a glitch |
| high | 16 | 18 | 2: a glitch |
| low | 18 | 30 | 12: stuck |
| high | 30 | 34 | 4 |
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