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();
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).
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?
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.
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.