Within a generate block, I have multiple if statements. When I declare a wire in the first if statement - I can't use it in other if statements
See the following stripped down example of my module:
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
The error message from both VCS and nLint is that indentifiers x1 and y1 have not been declared.
But they have been declared within previous generated if statements - what is the problem here?