Randomizing 2 D dyanamic array

In reply to duggi bhavya:

Hi duggi bhavya,

If you want to randomize only data_width and depth for dynamic array. The content of array doesn’t matter for you, then you can use following code:


class abc;

bit logic_data;
rand int depth_size;
rand int width_size;

function void post_randomize();
logic_data = new[depth_size];
foreach(logic_data[i])
logic_data[i] = new[width_size];
endfunction
endclass

module tb_top;
abc a;
initial begin
a = new();
a.randomize() with {depth_size inside {[1:10]}; width_size inside {[16:32]};};
foreach(a.logic_data[i,j])
$display(“i:%0d j:%0d logic_data: %0d”,i,j,a.logic_data[i][j]);
end
endmodule


Kindly clarify your exact requirement.

Thanks
Mitesh Patel