Coverpoint turn off and on

Hi All,

Is there any way to turn off and on some specific coverpoints in a covergroup based on some conditions?

In reply to Anudeep J:

If by “turn off” you mean “exclude from the final coverage calculation”, you can set the weight of the coverpoint to 0.

if (condition)
cginstname.cpname.option.weight=0;

In reply to dave_59:

if (condition)
cginstname.cpname.option.weight=0;

This turns off the individual coverpoint (making its goal % = 100 but hit % remains same). This does not increase the cumulative coverage.

How to turn off a coverpoint based on any condition so that it impacts the overall coverage ??

In reply to Ishan:

Incorrect. goal is a separate option.

In reply to dave_59:

In reply to Ishan:
Incorrect. goal is a separate option.

Hi Dave,

Agreed, goal is a separate option.

If by “turn off” you mean “exclude from the final coverage calculation”, you can set the weight of the coverpoint to 0.

if (condition)
cginstname.cpname.option.weight=0;

You mentioned this above, but turning off a coverpoint is not having any impact on the final coverage calculation and is only increasing the individual coverage for that coverpoint.

How to impact the overall/cumulative coverage if I turn off a coverpoint (by making its weight =0)??

In reply to Ishan:

I’m saying setting a coverpoint’s weight to 0 removes it from the overall coverage calculation - as if it were never there in the first place. Assume you had only three coverpoints A,B and C each with one bin in your testbench. If only B gets hit, you would have 33% overall coverage. If I set the weight of A to 0, the overall coverage goes up to 50%. But note that if A and B were both were hit, the overall coverage would be 66%, and setting the weight of A to 0 would go down to 50%. But presumably you are turning off the coverpoint because you want to ignore it because it can’t be hit in any possible testcase,

Maybe you need to explain how you want turning off a coverpoint to impact overall coverage.

In reply to dave_59:

In reply to Ishan:
I’m saying setting a coverpoint’s weight to 0 removes it from the overall coverage calculation - as if it were never there in the first place. Assume you had only three coverpoints A,B and C each with one bin in your testbench. If only B gets hit, you would have 33% overall coverage. If I set the weight of A to 0, the overall coverage goes up to 50%. But note that if A and B were both were hit, the overall coverage would be 66%, and setting the weight of A to 0 would go down to 50%. But presumably you are turning off the coverpoint because you want to ignore it because it can’t be hit in any possible testcase,
Maybe you need to explain how you want turning off a coverpoint to impact overall coverage.

Thanks.
The above example is working for NC Simulator(xcelium) , but is not working for questasim and VCS.

I have 3 coverpoints with 1 bin each (A,B,C) and A is getting hit . So overall coverage = 33 % . Now I set weight of coverpoint B as 0(using option.weight). According to you, the overall coverage should become 50% but it remains 33% in Questasim(version 10.7b) and VCS(version O-2018.9-1).

In reply to Ishan:

This forum is not for discussing tool specific issues, but I find it hard to believe the differences are because of the tool. You will need to show a minimal example.

In reply to dave_59:
I am seeing the same result what Ishan is trying to mention.
Here is the sample code


typedef enum bit [1:0] {A, B, C, D} _e;
class c;
  _e e, f;
  function new();
    cg = new();
    // cg._cp1.option.weight = 0;
    cg.sample();
    $display("The coverage is %0d\n", cg.get_coverage());
  endfunction

  covergroup cg;
    _cp : coverpoint e {
      bins legal[] = {A, B, C, D};
    }
    _cp1 : coverpoint f {
      bins legal[] = {B, C, D};
    }
  endgroup
endclass

I have this line
$display(“The coverage is %0d\n”, cg.get_coverage());
which prints out the coverage. This prints 12 as there is 1 in 7 bins getting hit

Now I tried including the line

// cg._cp1.option.weight = 0;

I am still getting the same result (12). I was expecting 25

In reply to agkiran:
Which bin is supposed to be hit and why? You are not showing enough code for anyone to know.

In reply to agkiran:

OK I updated the code to use

type_option

instead of

option

to update

weight

and now I am seeing a difference.

In reply to dave_59:

Updated the code to add enum definition. The default value A is expected to be hit in legal bin