Is there a way to conditionally ignore coverpoints?

Hi
i work on an IP which has different dut configurations. based on what configuration the run is, some coverpoints do not apply. so i want to know if there is a way to conditionally ignore certain coverpoints for the dut configurations that for sure wont hit the coverpoints.
i can add ignore_bins for the variables in the coverpoints for these configurations, but ignoring entire coverpoint would make it simpler and lesser code
thanks in advance
Shruti

In reply to shruti308:

Having faced a similar issue in the past , my suggestion would be to move it to a
separate covergroup and then to instantiate it based on configuration .

I am not certain if there’s a way to do this specifically for coverpoints
( maybe via option.weight = 0 )

can i use condition around the option.weight statement? like

if (cfg==“X”) {
option.weight = 0;
} // for non-X cfgs, weight will be non-zero

In reply to shruti308:
I think we can do with “iff” expression.find the below snippet


bit [3:0]a,b;
reg valid;
covergroup coverage;
BIN :coverpoint a iff (valid) //covers a if valid is high.
BIN1: coverpoint b iff(!valid)//covers b if valid is low.
endgroup.

Anyone,correct me if i was wrong.

In reply to Bandaru sateesh:

In reply to shruti308:
I think we can do with “iff” expression.find the below snippet


bit [3:0]a,b;
reg valid;
covergroup coverage;
BIN :coverpoint a iff (valid) //covers a if valid is high.
BIN1: coverpoint b iff(!valid)//covers b if valid is low.
endgroup.

Anyone,correct me if i was wrong.

That is not correct the iff clause only affects the sampling conditions of the coverpoint.
I think maybe setting the weight of the coverpoint might work as mentioned in previous posts

  covergroup my_cov (ref int weight_data_cp);
    coverpoint addr;
    coverpoint data {
    	option.weight = weight_data_cp;
    }
  endgroup
// when creating the covergroup
    int weight_data_cp;
    weight_data_cp = 0;
    my_cov = new(weight_data_cp);

HTH,
-R

In reply to rgarcia07:

You can also set the weight after constructing the covergroup.

  covergroup my_cov
    coverpoint addr;
    cp_data: coverpoint data;
  endgroup

my_cov cg;
cg = new
if (cfg=="X")
  cg.cp_data.option.weight = 0;

In reply to rgarcia07:

i tried the option.weight = weight_data_cp; option. i still see the coverpoint showing up in my database and hit only 50% (value of 0 being hit, value of 1 not hit) i want to automate the flow so that i dont have to go look at why the coverpoint was hit only 50% times in future for my IP. it will be good to see the coverpoint disabled if cfg==X (similar to ignore bin which doesnt contribute to the coverage %) and my coverage numbers be unaffected by it.

In reply to shruti308:

In reply to rgarcia07:
i tried the option.weight = weight_data_cp; option. i still see the coverpoint showing up in my database and hit only 50% (value of 0 being hit, value of 1 not hit) i want to automate the flow so that i dont have to go look at why the coverpoint was hit only 50% times in future for my IP. it will be good to see the coverpoint disabled if cfg==X (similar to ignore bin which doesnt contribute to the coverage %) and my coverage numbers be unaffected by it.

I’m not sure if this something related to your tool but in this small example you can see the coverage hits 100% even when data is not fully covered

class packet;
  randc bit [2:0]addr;
  randc bit [3:0]data;

  covergroup my_cov (ref int weight_data_cp);
    coverpoint addr;
    coverpoint data {
    	option.weight = weight_data_cp;
    }
  endgroup
  function new();
    int weight_data_cp;
    weight_data_cp = 0;
    my_cov=new(weight_data_cp);
  endfunction
  
endclass

module test;
  packet pkt;

  
  initial 
    begin
      pkt=new();
      repeat(8)
        begin
          assert(pkt.randomize());    
          pkt.my_cov.sample();
          $display("|pkt.addr = %0h | pkt.data = %0h|", pkt.addr, pkt.data);
        end     
      $display("coverage= %0.2f%% ",pkt.my_cov.get_coverage());
    end  
endmodule

Output on eda playground

# KERNEL: ASDB file was created in location /home/runner/dataset.asdb
# KERNEL: |pkt.addr = 6 | pkt.data = 1|
# KERNEL: |pkt.addr = 1 | pkt.data = 6|
# KERNEL: |pkt.addr = 7 | pkt.data = b|
# KERNEL: |pkt.addr = 0 | pkt.data = 0|
# KERNEL: |pkt.addr = 3 | pkt.data = 7|
# KERNEL: |pkt.addr = 2 | pkt.data = 2|
# KERNEL: |pkt.addr = 4 | pkt.data = e|
# KERNEL: |pkt.addr = 5 | pkt.data = 9|
# KERNEL: coverage= 100.00% 

I need to check in some other simulators and its GUI, I think the option.weight affects the coverage value computation, you still see the cp not being covered but the overall coverage computation does not take it into account since it weight is zero.

Check the LRM section 19.11 Coverage computation

In reply to dave_59:

Hi Dave ,

I tried using option.weight for the coverpoint but bins for variableb are Still uncovered . ( EDALINK )

Total Coverage is 50% . ( On 2 simulators that I tried )

However instead of option.weight = 0 ; if I use option.at_least = 0 ; .

Now I observe Total Coverage is 100% . ( On 1 simulator )

LRM Section 19.11.1 ::
" Consequently, a bin is not considered covered unless its hit count equals or exceeds the maximum of all the at_least values of all instances "

LRM Table 19-1 ::
" Minimum number of hits for each bin. A bin with a hit count that is less than number is not considered covered. "

Via option.at_least = 0 simulator2 still show coverage as 50% .

[Q1] I wanted to know how does the LRM define coverage calculation using above 2 ( at_least and weight ) scenarios

( Simulator2 throws Warning message :: Invalid value 0 specified for attribute option.at_least )

[Q2] If at_least ( int type ) is 0 , is it considered covered based on LRM?