For an Unpacked Array ::
max() returns the element with the maximum value or whose expression evaluates to a maximum
I understand that max() returns an Unpacked Array so I used Bit-Casting to use max() within a Constraint ::
class MAX ;
rand bit [3:0] b[10] ;
constraint MAX_ELEMENT { b.sum() with ( int'( item == int'( b.max() ) ) ) == 1 ; } // Throws Compilation Error !!
endclass
[1] I understand that Constraint blocks ONLY except Integral expressions , but shouldn’t the bit-stream cast work ??
[2] Since min() and max() methods return a Single Element , I was of the Opinion that I can use them in Constraints whereas ALL the Other Array Locator
Methods would be Illegal ( Since they return a Queue !! )
Any Thoughts ??