In reply to anuragre:
module containing_dpi #(int Inst)();
import "DPI-C" context function void C_code(int Inst);
initial C_code(Inst);
endmodule
module top;
containting_dpi #(1) ();
containting_dpi #(2) ();
endmodule
void C_code(int Inst) {
switch (Inst) {
case 1: C_impementation1(); break;
case 2: C_impementation2(); break;
}
}
You could also use pass a sting with the scope name so you don’t have to provide a unique parameter override
module containing_dpi();
import "DPI-C" context function void C_code(string Instname);
initial C_code($sformatf("%m"));
endmodule
module top;
containting_dpi ();
containting_dpi ();
endmodule
void C_code(char *Inst) {
// I'll leave this for you to figure out to build a function pointer table keyed on string names.
}
}
And it’s also possible to not pass anything and have your C code use the DPI C utility routine svGetScope()