Coverpoint BASICS

Hi ,

I was trying to understand the basics of Coverpoint expression ::


  bit [3:0]  a[4] ;  

   covergroup cg_exp ;

      //Coverpoint1
      a_auto : coverpoint a ;  

      // Coverpoint2
      a_sum : coverpoint ( a.sum()  with  ( 32'( item ) )  )   //  Valid  ??
      {
         bins  less_than_50      =  a_sum  with ( item < 50 )  ;
         bins   equal_to_50      =  a_sum  with ( item == 50 ) ;
         bins  greater_than_50   =  a_sum  with ( item > 50 )  ;
      }

   endgroup


LRM 2017 , Section 19.5 Defining coverage points :: " A coverage point specifies an integral expression that is to be covered."

So coverpoint ’ a_auto ’ would be Illegal .

Array Reduction method reduces an unpacked array to a single value .

[Q1] So coverpoint ’ a_sum ’ would be Legal , right ? ( I Observe Compilation Issue on some Simulators )

[Q2] Any possible alternative for coverpoint ’ a_sum ’ ?

In reply to hisingh:

An integral expression is one whose resulting type has ab integral value. There are no restrictions on the types of the operands in a coverpoint expression.

One tool on EDAPlayground has a “with” syntax bug, nothing to do with non-integral operands.

An integral expression is one whose resulting type has a integral value. There are no restrictions on the types of the operands in a coverpoint expression.

A similar discussion I had previously :: understanding-reduction-operator-sum-class-handles

In reply to dave_59:

Dave ,

I missed out on the working of with_covergroup_expression previously .


//  On  adding  the  following  ::  (  Assuming  coverpoint  a_auto  doesn't  exist )

  cg_exp  cg1 = new() ;

   initial  begin

     #1 ;  cg1.sample() ;
    
     #1 ;  a = '{ 15 , 10 , 15 , 10 }  ; cg1.sample() ;
    
     #1 ;  a = '{ 15 , 15 , 15 , 15 }  ; cg1.sample() ;

   end 


When I instantiate the covergroup I observe 3 bins are created although the a.sum() is 0 when cg1 is instantiated .

During instantiation , only ’ with( item < 50 ) ’ is True whereas other 2 with_covergroup_expression return false.

[Q] So why is that 3 bins are still created instead of ONLY bin ’ less_than_50 ’ ?

Doesn’t ’ item ’ / label ’ a_sum ’ refer to the reduced sum for array ?

In reply to hisingh:

The bins created by a coverpoint_expression are based on the resulting expression type, not its current value at construction. In this case a_sum is a unsigned 32-bit packed array.

In reply to dave_59:

Thanks Dave ,

A final question to conclude the thread .

As the coverage point specfies an intergal expression ,


 bit [ 3:0 ] a [3] ;
 bit [ 3:0 ] b [3] ;

 covergroup  cg_exp2 ;
  
   cp : coverpoint ( a == b ) 
   {
      bins  True   =  { 1'b1 } ;
      bins  False  =  { 1'b0 } ;
   }

 endgroup

**As result of coverpoint expression is 1’b0 / 1’b1 i.e integral expression ,

Can I say the above code is Legal ?**