I am porting some SystemVerilog to SystemC/C++ and am having trouble with a multidimensional associative array. Consider the declaration of this array in SV.
// assume typ_one, typ_two, typ_three are struct or enum types
typ_one mda[typ_two][typ_two][typ_three];
I know with 1-D associative arrays I can use a map, and with 2-D arrays a nested map, and I believe a similar approach can solve the multidimensional array but it gets really messy.
typ_one mda[typ_two];
map< typ_two, typ_one >;
typ_one mda[typ_two][typ_two];
map< typ_two, map< typ_two, typ_one > >;
typ_one mda[typ_two][typ_two][typ_three];
map< typ_two, map< typ_two, map< typ_three, typ_one > > >;
So my questions are,
(1) is the above correct, in the sense that an operation in the form of mda[x][y][z]
will return the same expected value as with the SV code?
(2) is there a better, cleaner way?