I understand that one has to proceed with caution while dealing with randomizing a dynamic array of objects.
I have the following : I am trying to randomize the blah_cfg ( which is a dynamic array). In the post_randomize() function, I did new the first dimension before iteratively newing the 2nd dimension of the array. But I still get the message that the objects have not been newe’d ( and that they are null). What am I doing wrong ?
class foo_bar_car extends foo_bar_cfg;
`uvm_object_utils(foo_bar_car)
// var : blah_cfg
// This holds the info on all the slots for this node. Its indexed
// by slice and the slot number
rand foo_bar_blah_cfg blah_cfg[][];
// func : new
function new(string name = "foo_bar_car");
super.new(name);
endfunction // new
// func: post_randomize()
function void post_randomize();
blah_cfg = new[10];
foreach (blah_cfg[ii]) begin
blah_cfg[ii] = new[10];
`LUVM_INFO("DBG", $sformatf("Num Dims:%0d", ii));
end
foreach (blah_cfg[ii]) begin
foreach(blah_cfg[ii][jj]) begin
if (blah_cfg[ii][jj] == null) begin
`LUVM_INFO("DBG", $sformatf("X:%0d Y:%0d is NULL", ii, jj));--> For the entire 10x10 array, this message is printed.
end
else begin
`LUVM_INFO("DBG", $sformatf("X:%0d Y:%0d is NOT NULL", ii, jj));
end
end
end
endfunction // post_randomize
endclass // foo_bar_car