Coverpoint gotcha when sequence and gated

My question relates to coverpoints that track a transition/sequence and what happens when the input to these is not valid (eg during reset). It seems there is no nice way to clear the state of the coverpoint so that when it’s active again it doesn’t continue the previous sequence. The following code illustrates the problem when gating the sequence using an iff statement.

bit reset; int my_int; covergroup cg; coverpoint my_int iff(!reset){ bins seq[] = [1:10]=>[1:10]; // cover any to any when not in reset // GOTCHA: 1=>reset=>2 is counted as 1=>2 } endgroup cg my_cg = new();

// Eg Sequence
my_int = 1;
reset = 1;
cg.sample(); // gated

my_int = 2;
reset = 0;
cg.sample(); // first in sequence

my_int = 3;
reset = 0;
cg.sample(); // seq(2=>3)++

my_int = 4;
reset = 0;
cg.sample(); // seq(3=>4)++

my_int = 5;
reset = 1;
cg.sample(); // gated

my_int = 6;
reset = 0;
cg.sample(); // seq(4=>6)++ GOTCHA

I’ve looked into a workaround which swaps “my_int iff(!reset)” for “reset ? -1 : my_int”. But this is not ideal for my actual design (in my case i have ‘first’ and thus no reset event and would rather not double sample the covergroup so that I can share it with other coverpoints).

Any hints from the community?

Thanks,
-Adam

For this example, the following would work:

covergroup cg;
  coverpoint reset ? 0 : my_int{
    bins seq[] = [1:10]=>[1:10];
  }
endgroup

There may be other solutions depending on what you actually need to do.

In reply to dave_59:

Hi Dave,
Thanks for the response. Yes I came to a similar conclusion at the end of my post that going to an out-of-bounds bin is a way of clearing the sequence.

The trouble I found with this is when I do not have an out-of-bounds bin to use (eg externally defined enum, boolean, etc) how do I reset the sequence?

So what would be the solution to the following sequence?

reset = 0;
my_bit = 0; cg.sample();
my_bit = 1; cg.sample();
my_bit = 1; cg.sample();
reset = 1; cg.sample();
reset = 0;
my_bit = 0; cg.sample(); //start of new sequence

The following would work, however it’s still not a generic solution (requires reset and my_bit to be concatenatable, ie similar type).

covergroup cg;
coverpoint {reset, my_bit} {
bins seq = 0=>1=>1=>0;
}
endgroup

A more generic solution might be this, however this could be quite cumbersome:

cg = cg.new();
reset = 0; //not used in cg
my_bit = 0; cg.sample();
my_bit = 1; cg.sample();
my_bit = 1; cg.sample();
reset = 1;
cg = cg.new();
reset = 0;
my_bit = 0; cg.sample(); //start of new sequence

In the end, I guess without something like cg.new_sequence() or using the current cg.new() every-time a sequence is to be aborted, every solution will heavily depend on the analysis type.

Cheers

In reply to adalyn:

Since a coverpoint expression must be integral, you can always use a concatenation. And if ‘reset’ or what ever you want to pad the base expression with is 0 in the normal case, it will have no effect on the consecutive transition bins you want to cover. Anything more complex you will need to write as a cover sequence directive.

In reply to dave_59:

Thanks for your feedback Dave,
-Adam