# Icarus verilog syntax error in a generate block

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]),
.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)

• This is it. Apparently the ++ operator is only supported in procedural code (i.e. testbenches) and not in anything that is part of synthesis. Sep 7 '18 at 8:23
• That's the -g command line option: I've tried -g2001, -g2005, and -g2009, all of which should support it. AIUI, the 2005 variant is the default. Sep 7 '18 at 4:17