Using `define macro to create another string in loop

I have a define

define M2Line_MEM_0 SOC_top.u_ddi_top.u_core.u_sram_wrapper.GAIN_SRAM_GEN_BLK[0].u_sram_1472x32.M31G123 define M2Line_MEM_1 SOC_top.u_ddi_top.u_core.u_sram_wrapper.GAIN_SRAM_GEN_BLK[1].u_sram_1472x32.M31G123
define M2Line_MEM_2 SOC_top.u_ddi_top.u_core.u_sram_wrapper.GAIN_SRAM_GEN_BLK[2].u_sram_1472x32.M31G123 define M2Line_MEM_3 SOC_top.u_ddi_top.u_core.u_sram_wrapper.GAIN_SRAM_GEN_BLK[3].u_sram_1472x32.M31G123

I would like to pass the above defines to a memory class handle as an argument ,as
my_mem_class m2line_mem[4] ;
define STRNG(x) 'x`"
string PATH

PATH=STRNG(M2Line_MEM_0);
m2line_mem[0]=new($sformatf(“%s”,PATH);
PATH=STRNG(M2Line_MEM_1);
m2line_mem[1]=new($sformatf(“%s”,PATH);
PATH=STRNG(M2Line_MEM_2);
m2line_mem[2]=new($sformatf(“%s”,PATH);
PATH=STRNG(M2Line_MEM_3);
m2line_mem[3]=new($sformatf(“%s”,PATH);

As you can see,the above code work is repetitive,and I would like to use for loop,but due to `defines ,i am not able to use loop,please kindly assist…

For exampe,I am looking to use like below

for(int i=0;i<4;i++)
begin
PATH=STRNG($sformatf("M2Line_MEM_%d",i));
m2line_mem[i]=new($sformatf(“%s”,PATH);
end

In reply to RKCH:

This cannot be done since the macros are simply text substitution during compile time. They do not really exist during simulation time (they have already been replaced with “hard coded text”).

Maybe you should consider not using macros, and use strings of paths paired with uvm_hdl_* methods:
https://verificationacademy.com/verification-methodology-reference/uvm/docs_1.2/html/files/dpi/uvm_hdl-svh.html

Here is an example:

package paths;

string string_ar[4] = 
{
  "SOC_top.u_ddi_top.u_core.u_sram_wrapper.GAIN_SRAM_GEN_BLK[0].u_sram_1472x32.M31G123",
  "SOC_top.u_ddi_top.u_core.u_sram_wrapper.GAIN_SRAM_GEN_BLK[1].u_sram_1472x32.M31G123",
  "SOC_top.u_ddi_top.u_core.u_sram_wrapper.GAIN_SRAM_GEN_BLK[2].u_sram_1472x32.M31G123",
  "SOC_top.u_ddi_top.u_core.u_sram_wrapper.GAIN_SRAM_GEN_BLK[3].u_sram_1472x32.M31G123"
};
endpackage

for(int i=0;i<4;i++)
begin
	m2line_mem[i]=new($sformatf("%s",paths::string_ar[i]));
end

And you can also use this in your code:

uvm_hdl_read(paths::string_ar[2]);

I haven’t compiled my example code, but I think that it works.