F9.3.1 Shrink the Timer for the Bench

MediumFix20 minSymbiYosys · serverReview the topic

Problem

Description

The watchdog limit is 50,000 cycles, so no bounded proof reaches a bark. Finish the change that lets the bench shrink the timer.

A watchdog limit of 50,000 cycles is half way to being a parameter. Finish the timer module so that a bench can shrink it. Two small copies must warn and bark on the exact cycle, and the default limit must stay 50,000.

Pinned interface
PortDirectionBits
clkinput1
rstinput1
kickinput1
bark_aoutput1
warn_aoutput1
bark_boutput1
warn_boutput1
bark_coutput1
warn_coutput1
quietoutput4
limit_coutput16
count_coutput16
Full specification

The timer barks when 50,000 cycles pass without a kick. It warns two cycles before that. Someone started to make the limit a parameter and stopped half way.

The bench below instantiates the timer three times. The limits are 6, 9 and the shipped default. Finish the tmr module so that every use of the limit follows the parameter. Submit the tmr module only. The judge owns top.

The judge proves, on the two small copies, the exact cycle of the warning and of the bark. It also checks that the default limit is still 50,000.

No bounded run reaches 50,000 cycles. So for the default copy, the judge runs a one-step induction over every value of count_o. The copy must warn from 49,998 and bark from 50,000. Keep count_o equal to the counter.

CopyWarn fromBark from
a: LIMIT 64 quiet cycles6 quiet cycles
b: LIMIT 97 quiet cycles9 quiet cycles
c: default49,998 quiet cycles50,000 quiet cycles
The bench top. The judge owns it and adds it to your tmr module.
module top(input clk, input rst, input kick, output bark_a, output warn_a, output bark_b, output warn_b, output bark_c, output warn_c, output reg [3:0] quiet=0, output [15:0] limit_c, output [15:0] count_c);
// The bench shrinks two copies of the timer. The third copy keeps the shipped limit.
wire [15:0] la, lb, ca, cb;
tmr #(.LIMIT(6)) a(.clk(clk), .rst(rst), .kick(kick), .bark(bark_a), .warn(warn_a), .limit_o(la), .count_o(ca));
tmr #(.LIMIT(9)) b(.clk(clk), .rst(rst), .kick(kick), .bark(bark_b), .warn(warn_b), .limit_o(lb), .count_o(cb));
tmr c(.clk(clk), .rst(rst), .kick(kick), .bark(bark_c), .warn(warn_c), .limit_o(limit_c), .count_o(count_c));
always @(posedge clk)                      // cycles since the last kick or reset, up to 15
  quiet <= rst || kick ? 4'd0 : quiet == 4'd15 ? 4'd15 : quiet + 4'd1;
endmodule

Execution ruleMeaning
InterfaceUse the pinned port names, directions and bit widths shown above. Observed state and tracker outputs are not environment inputs.
SamplingOne positive edge of clk; binary values. Non-overlapping implication observes the next sample. Reset and initialization follow the source and contract above.
SubmissionSubmit RTL using the starter’s format. The checks apply to this stated model and scope.
How this is gradedThe reference obligations, independent reachability checks and fault checks must all succeed. An unresolved proof or resource limit is inconclusive and is never a rated miss.

Measured Counterexample

FAIL · bmc · depth 12 · smtbmc yices · 2741 ms

This measured failing run uses the published interface. Follow the sampled violation back to the preceding inputs and state. The worked solution below explains the required behaviour and the failure mechanisms.

Recorded solver trace
012345clkfreerstfreekickbark_awarn_abark_bwarn_bbark_cwarn_cquiet4'b00004'b00014'b00104'b00114'b01004'b0101limit_c16'b1100001101010000count_c16'b000000000000000016'b000000000000000116'b000000000000001016'b000000000000001116'b000000000000010016'b0000000000000101sampled violation
Scroll horizontally ↔

Samples from the measured run. Free input lanes are shaded; the terminal VCD record is omitted.

Sample 4: quiet=4, warn_a=0, bark_a=0. Previous sample: quiet=3, warn_a=0. After four quiet cycles the copy with a limit of 6 must warn. This version warns one cycle late, so its threshold is not the limit minus two. The small copy shows in a few steps what the shipped copy would hide for 50,000 cycles.

Examples

A Constant That Follows the Limit

A threshold written as a number that was computed from the limit by hand.
The same threshold written as an expression of the parameter.

A bench can only shrink what the parameter reaches. A number that was derived by hand stays at its old value.

Requirements

  • Use the published ports and widths. The checker and the DUT variants are owned by the judge.
  • Do not add assumptions unless the statement explicitly asks for one. A passing assertion without a reachable trigger is insufficient.

Hints

Hint 1

Search the module for every number that was derived from 50,000.

Hint 2

Check both small copies in your head: when does each one warn?

Hint 3

Use the "Seven habits" list of F9.3: one parameter, and nothing derived from it by hand.

Single clock, binary values, synchronous reset. The judge checks the pinned interface, reachability and the declared proof or bound. UNKNOWN, resource limits and timeouts remain inconclusive.

INCONCLUSIVE never counts as acceptance or a rated miss. Run previews the same checks that Submit uses.

More problems on this topic

Report a problem with this page

Worked solution

Opening the solution ends an unsolved rated attempt. Solving it first costs nothing.

Your Design

SymbiYosys · server

Recent Submissions