【发布时间】:2015-06-04 18:27:45
【问题描述】:
我正在尝试使用 Verilog 中的参数化宏通过宏名称动态更改实例的主模块,如下所示。
`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
这里的目的是让顶层模块根据 TECH_1 和 TECH_2 宏值具有两个不同的与门。
我的尝试在编译 RTL 时出现语法错误,如下所示:
错误:无效的模块项。
有人可以帮我解决这个问题吗?
【问题讨论】:
-
我更正了示例代码,使其具有输入/输出定义。我仍然在实例化行遇到编译错误。
-
@toolic:这取决于正在使用的软件,例如iverilog 将
_2oi1_1x视为宏,假定为空。 -
@Qiu:那么它不是由 Verilog 2001 LRM 驱动的吗?
-
@Qui:在EDA综合工具中编译吗?
-
更多关于这个问题的讨论在这里问:verificationacademy.com/forums/systemverilog/…
标签: verilog register-transfer-level