Home › Practice › Formal Verification › Cover: can the queue ever fill up?
Cover: can the queue ever fill up?
EasyFormalcoversequential
Asserts say what must never go wrong. They cannot say that anything useful can happen. A design that does nothing at all passes every assert. Cover closes that gap.
Concept first. cover(condition) asks the tool: "show me a run where this condition happens". If it finds one, you get the run, and you know the state is reachable. If it finds none, the state may be unreachable, which often means a bug (or an assume that ruled out too much). Example with other numbers: a traffic light. cover(light == GREEN) shows the light can turn green.
The design counts how many items sit in a small queue (0 to 3). push adds one, pop removes one, and it ignores a push when full and a pop when empty. A queue that can never fill up is a bug, even though it never breaks a rule.
module dut(input clk, input rst, input push, input pop, output reg [2:0] count);
initial count = 3'd0;
always @(posedge clk) begin
if (rst) count <= 3'd0;
else if (push && !pop && count < 3'd3) count <= count + 3'd1;
else if (pop && !push && count > 3'd0) count <= count - 3'd1;
end
endmodule
- Keep the module name
chkand its ports. Write exactly onecover(...)and no assert. - Your cover must be reached on this design. You will see the run the tool found.
- The grader also runs two broken queues. Your cover must be a state that the bugs make unreachable, so pick the state that matters. This check looks at the first 20 cycles only; it is a bounded search, not a proof.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.