I have the following Code
module Coverage_per_instance ;
class A ;
bit a , b ;
covergroup AA ;
`ifdef PI // "Per_Instance"
option.per_instance = 1 ;
aval:coverpoint a ;
bval:coverpoint b ;
AA = new();
A a1 , a2 ;
a1 = new() ;
a2 = new() ;
a1.a = 0 ;
a1.b = 0 ;
a2.a = 1 ;
a2.b = 1 ;
$display("With a1 we Have Coverage %f ",a1.AA.get_coverage);
$display("With a2 we Have Coverage %f ",a2.AA.get_coverage);
[Q1] Irrespective of whether I use +define+PI or Not I still get ::
With a1 we Have Coverage 100.000000
With a2 we Have Coverage 100.000000
which I am unable to understand .
[Q2] I am unable to fully understand how option.per_instance works ?
In the Coverage Report
(a) With No define :: Covergroup AA has 100% Coverage . Coverpoints aval and bval Give a 100% Coverage .
(b) With +define+PI :: I get 2 Instances ( based on +define )
Covergroup AA still has 100% Coverage ( How ?? )
(1) /Coverage_per_instance/A::AA (2) /Coverage_per_instance/A::AA#2
(1) Here aval has 50% Coverage with auto hit , bval has 50% Coverage with auto hit
(2) Here aval has 50% Coverage with auto hit , bval has 50% Coverage with auto hit