User guide

24-28
SystemVerilog Testbench Constructs
$display("the first entry is
\"%s\"",s_index);
do
$display("%s :
%0d",s_index,a[s_index]);
while (a.next(s_index));
end
if(a.last(s_index))
begin
$display("the last entry is
\"%s\"",s_index);
do
$display("%s :
%0d",s_index,a[s_index]);
while (a.prev(s_index));
end
a.delete;
$display("number of entries = %0d",a.num);
end
endprogram
VCS displays the following:
number of entries = 5
string "sa" is in a
the first entry is "bb"
bb : 15
d : 32
e : 45
ec : 29
sa : 8
the last entry is "sa"
sa : 8
ec : 29
e : 45
d : 32
bb : 15
number of entries = 0