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 ?!
-
\$\begingroup\$ Please check whether you mean "adders" or "additions" and change your original question if necessary. \$\endgroup\$Huisman– Huisman2019年06月19日 07:04:50 +00:00Commented Jun 19, 2019 at 7:04
1 Answer 1
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.
-
1\$\begingroup\$ +1 Default value for all versions of Vivado, Quartus II, ISE and Synopsis compiler that I've tested is 10000 on clean installs. \$\endgroup\$DonFusili– DonFusili2019年06月19日 09:44:12 +00:00Commented Jun 19, 2019 at 9:44
-
\$\begingroup\$ Thank you @DonFusili. I have never tested this so I could not give an actual number. \$\endgroup\$Oldfart– Oldfart2019年06月19日 10:19:23 +00:00Commented Jun 19, 2019 at 10:19
-
\$\begingroup\$ Side note: While most (all?) FPGA tools will happily synthesize for-loops, ASIC synthesis tools will quite often puke when encountering any kind of loop. \$\endgroup\$Attila Kinali– Attila Kinali2019年06月19日 12:24:58 +00:00Commented Jun 19, 2019 at 12:24
-
1\$\begingroup\$ @AttilaKinali , I don't know where your getting your info about loop support with ASIC; but it is not true. ASIC synthesizers support for-loops (procedural and generate) and SystemVerilog foreach-loops so long as they can be static unrolled (same for FPGA). \$\endgroup\$Greg– Greg2019年06月21日 16:24:23 +00:00Commented Jun 21, 2019 at 16:24
-
\$\begingroup\$ @Greg I had bad experiences with various ASIC synthesizers. FPGA synthesizers seem to be quite a bit more relaxed what they accept and what they can produce proper output for. Though, I have to admit, I have been only using Cadence for the last few years and that does mostly a decent job. \$\endgroup\$Attila Kinali– Attila Kinali2019年06月24日 15:36:23 +00:00Commented Jun 24, 2019 at 15:36