Electronic – For-Loop and repeat synthesis

verilog

We all know that the For-loop and Repeat are synthesizable, they get converted to blocks, for example:

for (idx = 0; idx < 4; idx=idx+1) begin
a = a + b[idx];
c = c + 2;     //You can change more than one variable in a for loop
end

In that example, the resulting hardware will be a chain of adders, summing the values from four array indices.

So my question is what if the For loop iterates over a huge number let's say 10000 ? Will it create a 10000 adders ?!

Best Answer

Yes, but synthesis tools have a 'maximum loop' value at which they stop.

You can change the value but the default seems to be set rather high.
If you get a warning it is very likely that you have done something wrong.