Gating covergroup with a variable

My covergroup/coverpoint is embedded in a class and is to be gated from a dynamic variable populated only on the build phase. But the covergroup is newed in new(). I am looking for a “OVM” way of setting correct gating for ignore_bins.

Code Below uses initial value of covGate(=0) in covergroup

Thanks in advance,
-k

Example Code :

class myCls1;
int covGate;

covergrop covGrp;
coverpoint mySig1 {
bins sig0 = {0};
bins sig1 = {1} iff( covGate == 2);
bins sig2 = {2} iff( covGate == 3); }

endgroup

function new();

covGrp = new();
endfunction

function build();

covGate = 4;
endfunction
endclass

I am not sure why you would want to change a covergroup based on a specific OVM parameter. Functional coverage is typically utilized to give you a summary of coverage across many different simulation runs so that you can determine how well you have tested your design. To allow for merging this information, the covergroups need to stay the same across all the simulations.

Is there a specific reason you want to change covergroup behavior based on the testbench configuration? I think the only approach would be to have several different covergroups defined and utilize the one required by your configuration.

May I revisit this thread. I am facing the same issue, and my reason for doing that is, this component is reusable across different interfaces on different blocks. Now functional coverage should be configurable, in this sense able to be switched on or off because of certain features on a given interface.

Hope that is clear to you, so how would I implement that?