User guide
24-172
SystemVerilog Testbench Constructs
Syntax
function array_type[$] array_name.max() [with (expression)];
Example 24-37
value = array1.max();
object = array1.max() with (item.x >5);
object = array1.max() with (item.x * item.y);
The first example, returns a maximum value element of the array.
The second example returns the element that has the maximum value
of the member variable x. The third example returns the element that
has the maximum value of the product of the member values of x and
y.
unique()
The unique()method returns all elements with unique values or elements
whose expression is unique. If the array is empty or if no match is found
with the expression, then an empty queue is returned. The with expression
is optional here.
Syntax
function array_type[$] array_name.unique() [with (expression)];
Example 24-38
array2 = array1.unique();
In the example only unique elements from the array are returned.