Home › Practice › Formal Verification › Proof or only a short search? Help the induction
Proof or only a short search? Help the induction
MediumFormalinductionsequential
A formal tool can answer in two ways. A bounded check tries every input for the first N cycles, which finds bugs that show up early. A full proof covers every cycle forever. A proof often needs your help, and this problem shows how.
Concept first. The proof method is induction. Step one: the rule holds at the start. Step two: if the rule holds now, it still holds after one more tick. The catch is in step two. The tool does not start from the real start, it starts from any state where the rule holds, even states the design can never reach. If, from such an unreachable state, one tick breaks your rule, the proof fails, although the design is fine. The cure is a helper assertion that rules out the unreachable states. Example with other numbers: a counter that runs 0 to 5 and has a 3-bit register. "q is never 7" is true, but state 6 (unreachable) steps to 7, so the proof fails. The helper "q is at most 5" fixes it.
Here is a counter that runs 0 to 99 in an 8-bit register. Your first thought is to assert it never shows 255. Try that first, and read what the tool says. Then add the helper.
module dut(input clk, input rst, input en, output reg [7:0] q);
initial q = 8'd0;
always @(posedge clk) begin
if (rst) q <= 8'd0;
else if (en) q <= (q == 8'd99) ? 8'd0 : q + 8'd1;
end
endmodule
- Keep the module name
chkand its ports. - This problem passes only with a full proof. A pass that only covers the first 20 cycles is not enough here.
- The grader also runs two broken counters. Your assertions must catch both.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.