Readmemh, hierarchical path of instance and strings

Hi Dave.
For your first solution is a bit hard to implement it right now but I will.
In the meantime I came up with the following solution

`define OTP_ROM_FILE_PATH “…/src/rcf/”

task load_otp_rom_from_file (input string file_name);

static reg    [7:0] otp_buffer[0:127];
string file = file_name;
string path = `OTP_ROM_FILE_PATH;
string otp_file = {path,file};
string idx;
string full_path_of_otp;    
string otp_path = `STRING(`PRJ_DIG_TOP(0).otp_0.slp_tsmc180g33_128x8_cm4d_ak_0.slp);
 
$readmemh(otp_file, otp_buffer);
 
foreach (otp_buffer[i]) begin
     idx.itoa(i);
     full_path_of_otp = {otp_path,".otp[","idx]"};           
     void'(uvm_hdl_deposit({otp_path,".otp[",idx,"]"}, otp_buffer[i]));          
end
 
`uvm_info(get_type_name(), $sformatf("The OTP ROM was programmed from file..."), UVM_LOW)
 

endtask : load_otp_rom_from_file

and from the reset_phase you just call the task

static reg [7:0] otp[0:127];
$readmemh(`OTP_ROM_FILE(test_otp_differential_read_controller.rcf), otp);

I used the uvm_hdl_deposit to access the rom and I was converting the idx as string
It works.

I will implement your second solution and let you know