Working with multi-dimensional associative arrays

In reply to shailesh2490:

No, ARY[“A19”][0] should return a value of type int. Actually, int is equivalent to bit signed [31:0], which is packed array of 32 bits. An assignment pattern for this would have to be a list of 32 bits. You probably want to be using a concatenation the results in being 32-bits wide instead.

  int  ARY[string][int] = 
'{
  "A19" : '{0:{8'd0,8'd1,8'd2,8'd3} , 1:{8'd4,8'd5,8'd6,8'd7}},
  "A33" : '{30:{8'd1,8'd6,8'd5,8'd7} , 31:{8'd8,8'd9,8'd10,8'd11}}
};

You should never use the wildcard [*] index for an associative array. It is not type-safe and it limits you in terms of other SV constructs it can be used with (foreach loops, find methods).

1 Like