Is there a way to conditionally ignore coverpoints?

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