User guide

24-171
SystemVerilog Testbench Constructs
In the first example, the index of the last element which is greater
than 5 is returned. In the second example, the index of the last
element has its member variable x equal to 5 is returned.
min()
The min() method returns a queue with the minimum value element for
the integral types. For non-integral types the method returns a queue with
the element whose with expression evaluates to a minimum. If the array
is empty, a warning message is issued and a type dependent default value is
returned. The with expression is optional here.
Syntax
function array_type[$] array_name.min() [with (expression)];
Example 24-36
value = array1.min(); // Array1 is of type integer or reg
object = array1.min() with (item.x >5);
object = array1.min() with (item.x * item.y);
The first example, returns a minimum value element of the array. The
second example returns the element that has the minimum value of
the member variable x. The third example returns the element that
has the minimum value of the product of the member values of x and
y.
max()
The max() method returns a queue with the maximum value element for
the integral types. For non-integral types the method returns a queue with
the element whose with expression evaluates to a maximum. If the array
is empty a warning message is issued and a type dependent default value is
returned. The with expression is optional here.