It is not possible within the SystemVerilog language to access an identifier using a dynamic string name. Some program created these 244 unique instance names in your source file. Or maybe it was generated manually. You will have to use a program or script to generate the code here, or create it by hand.
There is no need to re-define the macro in your case. Just define the macro once and pass different values to access different sub modules. I have given proper code in my last example. Just use the same code.
Sorry. Looks like i have understood the requirement wrongly. I didn’t see any other way other than replicating the code for each module instance.
Below is a small example which is doing the same.
module m1;
`define D(x) mod``x``.sig
m2#(4) mod0();
m2#(5) mod1();
initial begin
#5;
for(int j=0;j<2;j++) begin
case(j)
0: $display("Print in case0 %d", `D(0)); // Put a function call instead of $display if some common thing should be done.
1: $display("Print in case1 %d", `D(1));
endcase
end
end
endmodule
module m2;
parameter m1=1;
reg [10:0]sig;
initial begin
sig =m1;
end
endmodule