User guide
24-36
SystemVerilog Testbench Constructs
endmodule
The $display system task displays the following:
string element number 0 contains "simulation"
string element number 1 contains "verification"
The foreach loop also works with queues and dynamic and
associative arrays. The following is an example with a dynamic
array:
program test;
integer fixed_int_array[3] = {0, 1, 2};
integer dynamic_int_array[];
initial
begin
dynamic_int_array=new[3](fixed_int_array);
foreach (dynamic_int_array[dim1])
$display("dynamic_int_array [%1d]=%0d",
dim1,dynamic_int_array[dim1]);
end
endprogram
The $display system task displays the following:
dynamic_int_array [0]=0
dynamic_int_array [1]=1
dynamic_int_array [2]=2
The following is an example with an associative array:
program test;
bit [2:0] assoc_array1 [*];
initial
begin
assoc_array1[0]=3'b000;
assoc_array1[1]=3'b001;