The same rule passes a simulation and fails in formal; a bounded run passes and proves nothing. Read each result for what it claims.
Hardware context: An arbiter and a counter checked by simulation and by formal. Read each result for exactly what it claims: a run, a bound or a proof.
A level rule (a 2-bit counter never reaches 3) is run in a directed simulation and in a formal check. A decade-counter rule is run in a bounded formal check.
Write answer(q). Question 3: the simulation's failure count. Questions 4 and 6: 1 for PASS, 0 for FAIL. Question 5: the step SBY reports. Question 7: 1 if the result of question 6 proves the counter rule for every depth, else 0.
Questions 0 to 2 are worked examples on the free-running counter. Questions 3 to 7 are graded only by the full check.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 4 | input of each check |
Full specification
module level (input logic clk, inc, output logic [1:0] lvl = 0);
always @(posedge clk) if (inc) lvl <= lvl + 2'd1;
endmodule
module tb;
logic clk = 0, inc = 0;
always #5 clk = ~clk;
logic [1:0] lvl;
level u_level (.clk, .inc, .lvl);
int fails = 0;
not_full: assert property (@(posedge clk) lvl != 2'd3) else fails++;
// A directed test: two increments, then a check of the level.
initial begin
repeat (2) begin
@(negedge clk) inc = 1;
@(negedge clk) inc = 0;
end
#30 $display("fails=%0d lvl=%0d", fails, lvl);
$finish;
end
endmodule
module top(input clk, input inc, output reg [1:0] lvl = 0);
always @(posedge clk) if (inc) lvl <= lvl + 2'd1; // wraps from 3 to 0
endmodule
module top(input clk, input en, output reg [3:0] cnt = 0);
// A decade counter: 0 to 9, then back to 0.
always @(posedge clk) if (en) cnt <= (cnt == 4'd9) ? 4'd0 : cnt + 4'd1;
endmodule
not_full: assert property (@(posedge clk) lvl != 2'd3);
not_full: assert property (@(posedge clk) lvl != 2'd3);
never12: assert property (@(posedge clk) cnt != 4'd12);
never12: assert property (@(posedge clk) cnt != 4'd12);
never12: assert property (@(posedge clk) cnt != 4'd12);
never12: assert property (@(posedge clk) cnt != 4'd12);
Simulator note: The simulation key was measured on Verilator 5.052, the formal keys with the formal engine v1. SymbiYosys counts the initial state as step 0. It reports a clocked check one step after the state that breaks it; IEEE 1800 has no step numbers. Your answer function is checked by a small bench on Icarus 12.
Examples
Example 1
Free Counter, Prove- Input
answer(0)
- Output
answer = 2
No proof exists; induction alone cannot decide at depth 4 (code 2).
Example 2
Free Counter, Bmc Depth 20- Input
answer(1)
- Output
answer = 0
Twenty steps reach the count of 12: FAIL (code 0).
Example 3
Free Counter, Bmc Depth 10- Input
answer(2)
- Output
answer = 1
Ten steps are too few: a bounded PASS (code 1).
Constraints and Contract
- Return one value per question from answer(q).
- Keep the function header.
Hints
Hint 1
A simulation checks only what its stimulus does. How far did this one fill the counter?
Hint 2
The solver picks inputs freely: how soon can the level reach 3?
Hint 3
A bounded PASS covers its depth only.
What the grader checks: Eight constant answers: three worked examples and five graded questions, measured on Verilator 5.052 and the formal engine v1.
8 checks on Icarus · browser samples / server checks. 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 3 steps and the final capstone