Using Array reduction operator on Array of Handles gives the following error ::
typedef enum bit { OFF = 0 , ON = 1 } bulb ;
class Bulbs ;
rand bulb bb ;
endclass
// In another class containing array of Handles :: rand Bulbs b[]
constraint SUMM { b.sum() == 5 ; }
Array reduction methods may only be applied on arrays of integral types if no ‘with’ expression is provided.
If a ‘with’ expression is present, the expression type must be integral .
So I tried the following which works ::
b.sum() with ( int'( item.bb == ON ) ) == 5 ;
So I asked myself why does it work in this case ( Feel free to add more or correct me with [A/B/C] below )
[A] Since with() is used we can use sum() on Array of Handles
Integral types according to LRM 6.11.1 ::
The term integral is used throughout this standard to refer to the data types that can represent a single basic
integer data type, packed array, packed structure, packed union, enum variable, or time variable.
[B] So since item.bb refers to an enum type ( and ON is already enum ) the with expression is successful .
[C] The with() expression has integral types in it thereby qualifying it as an integral expression , am I right here ?
Regards ,
ABD