User guide
24-31
SystemVerilog Testbench Constructs
Queue Methods
There are the following built-in methods for queues:
size
Returns the size of a queue.
program prog;
int intque [$] = {1,2,3};
initial
begin
for (int i = 0; i < intque.size; i++)
$display(intque[i]);
end
endprogram
insert
Inserts new elements into the queue. This method takes two
arguments: the first is the number of the element, the second is
the new value.
program prog;
string strque [$] = {"first","second","third","forth"};
initial
begin
for (int i = 0; i < strque.size; i++)
$write(strque[i]," ");
$display(" ");
strque.insert(1,"next");
strque.insert(2,"somewhere");
for (int i = 0; i < strque.size; i++)
$write(strque[i]," ");
$display(" ");
end
endprogram