User guide
24-23
SystemVerilog Testbench Constructs
lFA1[1]=1;
lFA1[0]=0;
lDA1=lFA1;
$display("lDA1[1] = %0d", lDA1[1]);
$display("lDA1[0] = %0d", lDA1[0]);
$display("lDA1 size = %0d",lDA1.size);
end
endprogram
VCS displays:
lDA1 size = 0lDA1[1] = 1
lDA1[0] = 0
lDA1 size = 2
When you assign a fixed-size array to a dynamic array, the dynamic
array’s size changes to the size of the fixed-size array. This is also
true when you assign a dynamic array with a specified size to another
dynamic array, for example:
logic lDA1[];
logic lDA2[];
initial
begin
lDA1=new[2];
$display("lDA2 size = %0d",lDA2.size);
lDA1[1]=1;
lDA1[0]=0;
lDA2=lDA1;
$display("lDA2[1] = %0d", lDA2[1]);
$display("lDA2[0] = %0d", lDA2[0]);
$display("lDA2 size = %0d",lDA2.size);
end
endprogram
This code displays the following:
lDA2 size = 0
lDA2[1] = 1