In reply to John Verif:
When you use generate to create multiple instances of a module, it is not an array that you can dynamically index; you must use a constant, and you can use another generate block to do that.
genvar k;
for(k=0;k<4;k++) begin
initial
fill_mem ();
task fill_mem ();
for (int i=0;i<256;i++)begin
dut.ram[k].ram_i.mem[i] = 255-i;
end
endtask : fill_mem
end