I want to write an assertion that is only related for coverage purpose.
I am having a 4bit variable. And I want to check that all possible values for that variable are being covered. I am thinking to write it in this way
generate
for(genvar i=0;i<15;i++) begin
cover_var_a : assert property(mem_wr_req == 1 |-> var_a == i);
end
endgenerate
But this piece of code is not working for me. Is there any other way to check coverage of a variable through assertions.
You need to explain what “not working” means. Getting errors? Not getting the expected results? What results are you getting? Is there a sampling clock?
You probably should be using a cover
instead of an assert
directive. Cover directives never fail.
Covergroups are better for collecting coverage of values.
covergroup cg @(posedge clk);
coverpoint: var_a iff (mem_wr_req);
endgroup
cg cg_inst=new;
(if you need to cover more than 64 values, you have a few options. Check the LRM for dealing with that)