Reputation: 202
Assuming I have two associative arrays, is there a way to use something like a concatenation operator to merge them? I tried this, and it doesn't work:
module tb;
initial begin
int a[int] = '{1:1, 2:2};
int b[int] = '{3:3, 4:4};
$display("a = ", a);
$display("b = ", b);
b = {a,b};
$display("b = ", b);
end
endmodule
I know I can iterate over it and assign, but I'm essentially looking for a one-liner if it's doable. I couldn't find anything in the LRM.
Upvotes: 2
Views: 762
Reputation: 42698
No, the LRM specifically excludes associative arrays from array concatenation (section 10.10).
A target of any other type (including associative array) shall be illegal.
It's also illegal to use any kind of casting. You'll have to use a foreach
loop.
Upvotes: 3