In reply to desperadorocks:
The below code seems working.
class config_;
rand bit [7:0]my_pts[$];
endclass: config_
class aac;
config_ cfg;
bit[7:0] agt_pts[string][$] = '{"alu0":'{0:'h11}, "cpu0":'{0:'h11, 1:'h22}};
function void perform_opr;
cfg = new();
assert(cfg.randomize with {
cfg.my_pts.size() == agt_pts["cpu0"].size();
//foreach(agt_pts["cpu0"][z])
foreach(cfg.my_pts[z]) cfg.my_pts[z] == agt_pts["cpu0"][z];
}) else $display("Randomization failed");
foreach(cfg.my_pts[ii]) $display("my_pts[%0d] : %0h",ii,cfg.my_pts[ii]);
endfunction: perform_opr
endclass: aac
module assoc_array_cycling;
aac aac_inst;
initial begin
aac_inst = new();
aac_inst.perform_opr();
end
endmodule: assoc_array_cycling
Output:
ncsim> run
my_pts[0] : 11
my_pts[1] : 22