Three burst rules miss bugs because of a text macro. Replace the macros with let declarations.
Hardware context: A burst checker whose limit and error-pulse rules were written with text macros. Name each condition once, so negation and defaults behave as the spec says.
A bus checker has three rules. A long burst must be flagged with err at the next edge. A short burst must not be. An err pulse lasts one cycle.
The rules use two text macros, and one rule never fires. Replace both macros with let declarations. too_long gets a default limit of 8, so the rules call it with one argument.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
valid | 1 | stimulus, the same for every design |
err | 1 | stimulus, the same for every design |
len | 4 | stimulus, the same for every design |
Full specification
module burst_rules (
input logic clk,
input logic valid, // a burst is on the bus
input logic err, // the slave's error flag
input logic [3:0] len, // the burst length
output int unflagged, // long bursts with no err at the next edge
output int false_flag, // short bursts with err at the next edge
output int long_err // err pulses longer than one cycle
);
// two let declarations and three rules
endmodule
| Edge | What the program shown here does | Expected |
|---|---|---|
| 25 | a long burst (10), flagged at 35 | no failure |
| 35, 45 | err stays high for two cycles after a short burst | false_flag and long_err fail at 45 |
| 55 | a long burst (12), not flagged at 65 | unflagged fails at 65 |
| 75 | a burst of exactly 8: short | no failure |
The full check also runs a second program, with another clock and other lengths. This page does not show it.
Examples
Example 1
One Long Burst Without Err- Input
Program: bursts of 4, 10, 3, 5, 12, 6, 8
- Output
unflagged = 1
The burst of 12 at 55 is not flagged at 65.
Example 2
One Short Burst Flagged- Input
Program: bursts of 4, 10, 3, 5, 12, 6, 8
- Output
false_flag = 1
err is still high at 45, after the short burst at 35.
Example 3
One Long Pulse- Input
Program: err high from 32 to 52
- Output
long_err = 1
err rises at 35 and stays high at 45.
Constraints and Contract
- Declare let too_long(l, max = 4'd8) and let err_rose(s) in the module. Use no text macro in the rules.
- Call too_long with one argument, so the default limit applies.
- Keep the three rule labels and their counters. Do not change the ports.
Hints
Hint 1
A macro is pasted as text. What does ! apply to in !len > 4'd8?
Hint 2
A let is expanded in parentheses, so !too_long(len) negates the whole comparison.
Hint 3
$rose in a let takes the clock of the assertion that uses it. In a function it would have no clock.
What the grader checks: Two copies of your checker each watch a fixed program: the one shown here and a hidden one with another clock. Graded on each: the three failure counts. The source must use the two let declarations in the three rules.
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 2 steps and the final capstone