class test;
bit a;
rand bit [3:0]addr;
covergroup cg @ (a);
type_option.strobe=1;//with or without this line the output is same ..so
coverpoint addr; //what is the significance of type_option.strobe=1
endgroup:cg
function new();
cg=new;
endfunction:new
endclass
module sample;
test t1;
bit clk;
always #10 clk = ~ clk;
initial begin
t1 = new();
t1.a=1'b1;#5
t1.a=1'b0;#5
t1.a=1'b1;#5
t1.a=1'b0;#5
t1.a=1'b1;#5
t1.a=1'b0;#5
t1.a=1'b1;#5
t1.a=1'b0;#5;
end
initial begin
repeat(15)
begin
t1.randomize();
$display(t1.addr);
$display($time," COVERAGE: %f%%",t1.cg.get_coverage());
#5;
end
end
initial begin
$dumpfile("dump.vcd");$dumpvars( );
#200 $finish;
end
endmodule
output:
1
0 COVERAGE: 0.000000%
0
5 COVERAGE: 6.250000%
7
10 COVERAGE: 12.500000%
2
15 COVERAGE: 18.750000%
12
20 COVERAGE: 25.000000%
14
25 COVERAGE: 31.250000%
11
30 COVERAGE: 37.500000%
9
35 COVERAGE: 43.750000%
10
40 COVERAGE: 50.000000%
5
45 COVERAGE: 50.000000%
9
50 COVERAGE: 50.000000%
13
55 COVERAGE: 50.000000%
0
60 COVERAGE: 50.000000%
4
65 COVERAGE: 50.000000%
12
70 COVERAGE: 50.000000%