I am trying to use parameterized macros in Verilog to dynamically change the master module of instances through macro names as tried below.
`define AND_CELL(tech) ``tech``_2oi1_1x
`define TECH_1 tech1
`define TECH_2 tech2
module top(in1, in2, in3, in4, out_x);
input in1, in2, in3, in4;
output out_x;
wire t1_c, t2_c;
`AND_CELL(`TECH_1) u1(.a(in1), .b(in2), .x(t1_c));
`AND_CELL(`TECH_2) u2(.a(in3), .b(in4), .x(t2_c));
assign out_x = t1_c | t2_c ;
endmodule
module tech1_2oi1_1x(a, b, x);
input a, b;
output x;
assign x = a & b;
endmodule
module tech2_2oi1_1x(a, b, x);
input a, b;
output x;
assign x = a & b;
endmodule
The intent here to have the top module to have two different AND gates based on the TECH_1 and TECH_2 macro values.
My attempt gives syntax error while compiling the RTL, as below:
error: invalid module item.
Can someone help me in fixing this issue?