User guide

24-174
SystemVerilog Testbench Constructs
Example 24-40
value = Qint.sum(); // Calculates sum of all elements
value = QPacket.sum() with (item.pkt_size); // Computes sum of
// member pkt_size for all elements of queue SQPacket.
In the first example the sum of all the elements of the queue Qint is
calculated. The second example computes sum of member variable
pkt_size for all elements of queue QPacket is calculated.
product()
The product() method computes the product 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
product of the member variables specified using the with expression.
Syntax
function expression_or_array_type array_name.product()
[with (expression)];
Example 24-41
value = Qint.product(); // Calculates product of all elements
value = QPacket.product() with (item.pkt_size);// Computes
// product of member pkt_size for all elements of queue QPacket.
In the first example the product of all the elements of the queue Qint
is calculated. The second example computes product of member
variable pkt_size for all elements of queue QPacket is calculated.