User guide
24-38
SystemVerilog Testbench Constructs
List of Aggregate Methods
The following code is an example of the aggregate method, sum() in
an inline constraint block:
program test;
class myclass;
rand int b[2:0];
int a[3:0] = {2,4,6,8};
function void post_randomize();
if((b[0] == 28) && (b[2] == 28))
$display("test Passed");
else
$display("test Failed");
endfunction
endclass
myclass mc = new;
initial begin
int i;
i = mc.randomize() with { foreach (b [j]) b[j] ==
a.sum(temp) with (a[temp.index] + 2);};
Table 24-1
Method Description
sum() Performs addition and returns sum of array elements
product() Performs multiplication, and returns product of array
elements
and() Performs bitwise AND operation, and returns bit-wise AND
of array elements.
or() Performs bitwise OR operation, and returns bit-wise OR of
array elements
xor() Performs logical XOR operation, and returns logical XOR
of all array elements.