User guide
24-29
SystemVerilog Testbench Constructs
Queues
A queue is an ordered collection of variables with the same data type.
The length of the queue changes during simulation. You can read
any variable in the queue, and insert a value anywhere in the queue.
The variables in the queue are its elements. Each element in the
queue has a number: 0 is the number of the first, you can specify the
last element with the $ (dollar sign) symbol. The following are some
examples of queue declarations:
logic logque [$];
This is a queue of elements with the logic data type.
int intque [$] = {1,2,3};
This is a queue of elements with the int data type. These
elements are initialized 1, 2, and 3.
string strque [$] = {"first","second","third","fourth"};
This is a queue of elements with the string data type. These
elements are initialized "first", "second", "third", and
"fourth".
You assign the elements to a variable using the element number, for
example:
string s1, s2, s3, s4;
initial
begin
s1=strque[0];
s2=strque[1];
s3=strque[2];
s4=strque[3];
$display("s1=%s s2=%s s3=%s s4=%s",s1,s2,s3,s4);
.
.
.