In the top level of a module, I have the following block:
genvar i;
generate
for (i = 0; i < DEPTH; i++) begin
fifo_element #(WIDTH) element (.clk(clk),
.d_in(e_qd[i]),
.d_in_strobe(e_in_strobe[i]),
.q(e_qd[i+1]),
.q_ready(e_qready[i]),
.in_strobe_chain(e_in_strobe[i+1]),
.q_out_strobe(e_out_strobe[i+1]),
.out_strobe_chain(e_out_strobe[i]),
.prev_used(i == 0 ? 1'b0 : e_used [i-1]),
.next_used(i == DEPTH-1 ? 1'b1 : e_used [i+1]),
.used(e_used[i]));
end // for (i = 0; i < DEPTH; i++)
endgenerate
When I attempt to compile this with icarus verilog (v10.1, using the -g2009
command line option) I get the following errors:
fifo.v:84: syntax error
fifo.v:96: error: invalid module item.
fifo.v:97: syntax error
These errors correspond to the line containing for
, the last line of the element
instantiation, and the line containing the end
that corresponds to the begin
of the for
block. If I delete the apparently-unnecessary begin
and end
markers the third error goes away but the other two remain.
What's wrong with my code? Or is this a problem with Icarus Verilog? (A little research suggests that while earlier versions didn't support generate
blocks at all, they've been supported for some time now, so what I'm trying to do here should work)
Best Answer
Maybe you need i = i +1 instead of i++. Other than that, I don't see anything obviously wrong.