Is it possible to allocate the bins dynamically

Hi There,

I have a rand variable called instruction this variable can get values like ADD, MUL, OR, and SUB in constraints, it is based on the distribution but sometimes they override the constraint distribution probability to zero for some of the values.

rand int instruction;
constraint inst {instruction dist { ADD := 5, MUL := 8, SUB := 12, OR := 7 };} // this is actual constraint

//some times they modified to this type also
constraint inst {instruction dist { ADD := 0, MUL := 8, SUB := 12, OR := 7};}

In the coverage file coverage for this instruction is hardcoded.

coverpoint instruction {
bins a = {ADD}; //whenever add dist makes to zero in testcase creation we don't get add at that time we don't get 100 percent coverage
//is there any possibility to disable the bin when add instruction probability is zero
bins m = {MUL};
bins s = {SUB};
bins o = {OR};
}

Whenever some of the instruction value probability is zero, I am not getting 100 percent coverage. Is there any possibility of allocating the bins on the fly?

You probably do not want to do this. It’s OK if one particular test does not hit a bin, another test will cover it. Coverage from multiple tests are merged together for the total coverage.

Bins get constructed when constructing a covergroup–you can’t change it dynamically. However, you can dynamically change the weight of a coverpoint to 0, effectively removing the coverpoint.