How to combine coverpoints

Hi, I have a simple question but can’t seem to find a straightforward answer from looking at other related questions. I have several coverpoints defined with their own bins and I just want to know how to create a new coverpoint that is the equivalent of a combined version of all the other coverpoints. I have listed an example below:

cp_1 : coverpoint (opcode)
{
   bins cp_1_opcode_1 = {some_value};
   bins cp_1_opcode_2 = {some_value};
   bins cp_1_opcode_3 = {some_value};
}

cp_2 : coverpoint (opcode)
{
   bins cp_2_opcode_1 = {some_value};
   bins cp_2_opcode_2 = {some_value};
   bins cp_2_opcode_3 = {some_value};
}

cp_3 : coverpoint (opcode)
{
   bins cp_3_opcode_1 = {some_value};
   bins cp_3_opcode_2 = {some_value};
   bins cp_3_opcode_3 = {some_value};
}

cp_total : what should I put here?

cp_total_equivalent : coverpoint (opcode)
{
   bins cp_1_opcode_1 = {some_value};
   bins cp_1_opcode_2 = {some_value};
   bins cp_1_opcode_3 = {some_value};
   bins cp_2_opcode_1 = {some_value};
   bins cp_2_opcode_2 = {some_value};
   bins cp_2_opcode_3 = {some_value};
   bins cp_3_opcode_1 = {some_value};
   bins cp_3_opcode_2 = {some_value};
   bins cp_3_opcode_3 = {some_value};
}

I want to be able to cross the total as well as separate coverpoints with other coverpoints with minimum code, e.g.,

cp_cross_example_1 : cross cp_1, some_other_cp_1;
cp_cross_example_2 : cross cp_total, some_other_cp_2;

In reply to atashinchi:

You can use a combination of ‘bin set’ expressions and ‘bin with’ expressions

  int set1[] = {1,2,3};
  int set2[] = {4,5,6};
  int set3[] = {7,8,9};
  int opcode;
  
  covergroup cg;
    cp_1 : coverpoint opcode {  
      bins cp_1_opcode[] = set1;
    }
    cp_2 : coverpoint opcode {
      bins cp_2_opcode[] = set2;
    }
    cp_3 : coverpoint opcode {
      bins cp_2_opcode[] = set2;
    }
    cp_total : coverpoint opcode {
      bins cp_total_opcode[] = cp_total with (item inside {set1,set2,set3});
    }
  endgroup

See sections 19.5.1.1 Coverpoint bin with covergroup expressions and 19.5.1.2 Coverpoint bin set covergroup expressions

In reply to dave_59:

Hi Dave ,

Is the coverpoint label restricted to be used within the following 2 cases only ? :

  1. The same coverpoint ( Eg : cover_point_identifier with ( with_covergroup_expression ) )
  2. cross bin ( via binsof( cp_label ) … )

I tried using it within a different coverpoint of same covergroup , however I observe a compilation error .


  enum  { SUB , ADD , MUL , DIV , POWER_OF }  opcode ;
          
   covergroup  cg ;
     
   cp_1 : coverpoint (opcode)
{
   bins substract = { SUB };
   bins addition  = { ADD };   
}
 
cp_2 : coverpoint (opcode)
{
  bins multiply = { MUL };
  bins divide   = { DIV };  
}
 
cp_3 : coverpoint (opcode)
{
  bins powerof = { POWER_OF };
}
 
cp_total_equivalent : coverpoint (opcode)
{
  bins  sub   = cp_1  with  (  item  inside  { SUB }  );
  bins  add   = cp_1  with  (  item  inside  { ADD }  );
  bins  mul   = cp_2  with  (  item  inside  { MUL }  );
  bins  div   = cp_2  with  (  item  inside  { DIV }  );
  bins  power = cp_3  with  (  item  inside  { POWER_OF }  );
}   
   endgroup

Within coverpoint cp_total_equivalent if I replace labels cp_1 , cp_2 and cp_3 with cp_total_equivalent , it works