User guide
24-173
SystemVerilog Testbench Constructs
unique_index()
The unique_index()method returns the indexes of all elements with
unique values or 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 int_or_index_type[$] unique_index() [with (expression)];
Example 24-39
array2 = array1.unique_index();
In the example indices of only the unique elements are returned.
Array reduction methods
Array reduction methods are used to evaluate and reduce an array
to a single value. The optional with clause can be used to specify the
elements for reduction. These methods return a reduced single value
as the array element type. If the with clause is specified, they return
the type of the expression in the with clause.
sum()
The sum() method computes the sum of all the array elements for integral
types. The with expression is optional for integral types. When the with
expression is specified for non-integral types they returns the sum of the
member variables specified using the with expression.
Syntax
function expression_or_array_type array_name.sum() [with (expression)]