Passing multiple variable to a single coverpoint

Hi There,

I have the following 4 variables.

int I;
int J;
int K;
int L;

I want a coverpoint with the following pseudo code/intent.

cov_cp : coverpoint I,J,K,L {
                       bins aa = ( (I>10) && (L<20) ); 
                       bins bb = ( (I<10) && (L>15) );
                       bins cc = ( (K>10) && (L<20) );
                       bins dd = ( (J>10) && (K<20) );
                     }

So, is it possible to pass all I, J, K, L to the coverpoint and how do I define the required bins.

Thanks,
Sunil.

In reply to KumarSunilB:

    covergroup cg;
        CP_I : coverpoint I {
            bins lessthan_10[] = {[0:9]};
            bins greaterthan_10[] = {[10:100]};
        }
        CP_L : coverpoint L {
            bins lessthan_20[] = {[0:19]};
            bins greaterthan_15[] = {[15:100]};
        }
        cross CP_I,CP_L {
                         bins aa = binsof(CP_I.greaterthan_10) && binsof(CP_L.lessthan_20);
                         }
     endgroup

You can write something like this.

In reply to yourcheers:

I am still trying to understand your solution!

Isn’t it when we do a cross the bins come as a pair/set ?

To better ask what I wanted to ask in my original post here is what is intended
The I>10, L<20 etc etc are just some examples for any kind of expression.

I have the following 2 cover points.


cov_p_a : coverpoint (inst.a > 1) { bins hit = {1'b1}; }
cov_p_b : coverpoint (inst.b > 1) { bins hit = {1'b1}; }

What I want is a single coverpoint which has the above 2 bins.

something like below


cov_p_ab : coverpoint ???? {
                                bins aa = cov_p_a;
                                bins bb = cov_p_b;
                           }

Is this what you want?



module top;
  covergroup cg (int v,k,r);
 option.per_instance = 0;
 type_option.merge_instances = 1;
 option.get_inst_coverage = 1; 
    coverpoint v { bins val[] = {k>8 && r > 18};}
 endgroup
 int a, b;
  int k,r;
                  cg cva = new(a,k,r);
                  cg cvb = new(b,k,r);
 initial begin
   #1; k= 10;
   #1; r = 20;
   #1; a = 0; cva.sample();
   #1; b = 1; cvb.sample();
 #1; $display("cva=%.2f cvb=%.2f",
 cva.get_inst_coverage(), cvb.get_inst_coverage());
 end
endmodule


In reply to KumarSunilB:

Can you explain why you think you want to have one coverpoint with two bins instead of two coverpoints with one bin?

In reply to dave_59:

In reply to KumarSunilB:
Can you explain why you think you want to have one coverpoint with two bins instead of two coverpoints with one bin?

Good question :-)

Actually I have a total of 8 variables in a class

4 for source
4 for destination

I wanted 4 bins for source variables, each bin is a unique function of all the src variables.
I wanted 4 bins for destination variables, each bin is a unique function of all the destination variables.

I wanted to cover the cross of the 4 source and 4 destination bins

Here is the intent below

cov_src : coverpoint ???? {
                                bins s_1 = f1(src_1, src_2, src_3, src_4);
                                bins s_2 = f2(src_1, src_2, src_3, src_4);
                                bins s_3 = f3(src_1, src_2, src_3, src_4);
                                bins s_4 = f4(src_1, src_2, src_3, src_4);
                           }

cov_dst : coverpoint ???? {
                                bins d_1 = g1(dst_1, dst_2, dst_3, dst_4);
                                bins d_2 = g2(dst_1, dst_2, dst_3, dst_4);
                                bins d_3 = g3(dst_1, dst_2, dst_3, dst_4);
                                bins d_4 = g4(dst_1, dst_2, dst_3, dst_4);
                           }


cov_src_dst_cov : cross cov_src, cov_dst;


In reply to KumarSunilB:

I am afraid that doesn’t help much. Can you generate sampling stimulus that shows what it would take to get 100% coverage?

In reply to dave_59:

In reply to KumarSunilB:
I am afraid that doesn’t help much. Can you generate sampling stimulus that shows what it would take to get 100% coverage?

Hi Dave,

Ok here it is.

class AA;
bit[15:0] src[4];
bit[15:0] dst[4];
endclass

I wanted the following stimulus.

src[3] > 1
src[2] > 1 && src[3] == 1
src[1] > 1 && src[2] == 1 && src[3] == 1
src[0] > 1 && src[1] == 1 && src[2] == 1 && src[3] == 1

dst[3] > 1
dst[2] > 1 && dst[3] == 1
dst[1] > 1 && dst[2] == 1 && dst[3] == 1
dst[0] > 1 && dst[1] == 1 && dst[2] == 1 && dst[3] == 1

Wanted the cross between the above 4 src and 4 dst combinations.

Currently I am defining each src and each dst scenario as single coverpoint.

And generating the cross by manually typing the 16 crosses.

I wanted something which will make

the 4 src scenario as single coverpoint with 4 bins and

the 4 dst scenario as single coverpoint with 4 bins and

to use just 1 cross.

In reply to KumarSunilB:

In reply to dave_59:
Hi Dave,
Ok here it is.

class AA;
bit[15:0] src[4];
bit[15:0] dst[4];
endclass

I wanted the following stimulus.

src[3] > 1
src[2] > 1 && src[3] == 1
src[1] > 1 && src[2] == 1 && src[3] == 1
src[0] > 1 && src[1] == 1 && src[2] == 1 && src[3] == 1

dst[3] > 1
dst[2] > 1 && dst[3] == 1
dst[1] > 1 && dst[2] == 1 && dst[3] == 1
dst[0] > 1 && dst[1] == 1 && dst[2] == 1 && dst[3] == 1

Wanted the cross between the above 4 src and 4 dst combinations.
Currently I am defining each src and each dst scenario as single coverpoint.
And generating the cross by manually typing the 16 crosses.
I wanted something which will make
the 4 src scenario as single coverpoint with 4 bins and
the 4 dst scenario as single coverpoint with 4 bins and
to use just 1 cross.

I am planning to add new variable, each bit in that variable will be assigned the above expression and create 1 hot bins and do a cross.