User guide

24-22
SystemVerilog Testbench Constructs
The size() Method
The size method returns the current size of a dynamic array. You
can use this method with the new[] built-in function, for example:
bitDA3 = new[bitDA1.size] (bitDA1);
The delete() Method
The delete method sets a dynamic array’s size to 0 (zero). It clears
out the dynamic array.
bitDA1 = new[3];
$display("bitDA1 after sizing, now size =
%0d",bitDA1.size);
bitDA1.delete;
$display("bitDA1 after sizing, now size =
%0d",bitDA1.size);
VCS displays from this code:
bitDA1 after sizing, now size = 3
bitDA1 after sizing, now size = 0
Assignments to and from Dynamic Arrays
You can assign a dynamic array to and from a fixed-size array, queue,
or another dynamic array, provided they are of equivalent data types,
for example:
logic lFA1[2];
logic lDA1[];
initial
begin
$display("lDA1 size = %0d",lDA1.size);