Ans mismatch

Hi All,
I set the weight to be 0 for addr, why the result show 75 instead of 100?
Thanks!!


class packet;
  randc bit [3:0]addr ;
  randc bit [2:0]data;
 
  covergroup cov (input a, b);
    coverpoint addr{
      option.weight =  a;
      
    }
    coverpoint data {
    	option.weight = b;
    }
  endgroup
  function new();
    cov=new(0,1);
  endfunction
 
endclass
 
module test;
  packet pkt;
  
  initial 
    begin
      pkt=new();
      repeat(8)
        begin
          assert(pkt.randomize());    
          pkt.cov.sample();
        end     
      $display("coverage= %f ",pkt.cov.get_coverage());
    end  
endmodule

In reply to peter:

There are some issues in how coverage is collected for the covergroup type, versus each instance. Your
option.weight
settings only apply to each instance of a coverpoint, since they can be set to different values for the construction of each covergroup instance (some tools produce a warning if you try to set the instance weight without having per_instance set to 1). You can either use
type_option.weight = 0
for the covergroupt type or set
option.per_instance=1
.

Then if you use
option.per_instance=1
, you would see instance coverage go to 100%, but overall coverage would not be 100% unless you used
type_option.merge_instances=1
.

In reply to dave_59:

Hi Dave,

Q1: I am a bit confused about type_option and option. I tried to use type_option.weight = a, it will be error. it is fine when using type_option.weight = 0. When should I use type_option and option?

Q2:
When I used option.per_instance = 1, instance coverage go to 100. But, overage coverage is still not 100. In my simulation, I only created one coverage group. So, why instance coverage is not same as overall coverage?

Thanks a lot!!!