User guide

24-34
SystemVerilog Testbench Constructs
$display("s1 after pop contains %s ",s1);
$write("the elements of strque are ");
for (int i =0; i<strque.size; i++)
$write(strque[i]," ");
end
endprogram
The system tasks display the following:
the elements of strque are first second third
s1 before pop contains
s1 after pop contains third
the elements of strque are first second
push_front and push_back
Add elements to the front and back of the queue.
int intque [$] = {1,2,3};
initial
begin
for( int i = 0; i < intque.size; i++)
$write(intque[i]," ");
intque.push_front(0);
intque.push_back(4);
$write(" \n");
for( int i = 0; i < intque.size; i++)
$write(intque[i]," ");
end
The system tasks display the following:
123
01234
The foreach Loop
A foreach loop iterates through an array. Its argument is any kind
of array and the loop variables designate the indexes of the array.
The following is an elementary example of the use of this construct: