fixed/dynamic array can not directly assigned to queue.
module top;
//example of queue
bit [31:0] src[5] = '{1,2,3,4,5};
int j = 2;
int q1[$] = {1,2,3,4};
int q2[$] = {7,8};
int q3[$];
initial begin
foreach(src[i]) begin
q3.push_back(src[i]);
$display(q3[i]);
end
end
endmodule
The
q3 = src; statement is outside the procedural initial block
You did not declare q3 as a queue. It needs to be declared as a queue with matching element types of unpacked array to make the assignment statement work.
module top;
//example of queue
bit [31:0] src[5] = '{1,2,3,4,5};
int j = 2;
int q1[$] = {1,2,3,4};
int q2[$] = {7,8};
bit [31:0] q3[$];
q3 = src;
initial begin
q3 = src;
foreach(q3[i])
$display(q3[i]);
end
endmodule