在generate
块中,我有多个if
语句。如果我在第一个if语句中声明了一个wire,我就不能在其他if
语句中使用它。
看看我模块的以下简化示例:
module my_module
#(parameter integer NUM_X_PORTS = 1,
parameter integer NUM_Y_PORTS = 1)
(
// port declarations
);
generate
if (NUM_X_PORTS > 0) begin
wire [NUM_X_PORTS-1:0] x1;
// logic filled in here
end
if (NUM_Y_PORTS > 0) begin
wire [NUM_Y_PORTS-1:0] y1;
// logic filled in here
end
if ((NUM_X_PORTS > 0) && (NUM_Y_PORTS > 0)) begin
for (i=0; i<NUM_Y_PORTS; i=i+1) begin
assign z[i] = y1[i] & |x1; // I can't use x1 and y1 here
end
endgenerate
但是它们在之前生成的if语句中已经被声明了——问题出在哪里呢?