UPGRADE YOUR BROWSER
We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!
11-03-2016 09:54 AM
I have that HLS is unrolling and consuming lots of resources and failing timing. The loop has a constant iteration count so it is able to unroll it technically. The loop is below (and is pipelined II=1). Note that this loop is nested in a while loop which does play a role.
uint32 minValue=0xFFFFFF; uint32 minIndex=i; for(uint32 i = 0; i < constant; i++) { if(memory[i] < minValue) { minValue = memory[i]; minIndex=i; } }
What HLS infers is every comparison being chained together and done in one cycle which is ridiculous. It should read the value out of memory, compare it to the next and if its smaller update minValue. It instead reads out every value and does all the calculations at once. This uses a lot of hardware and spectacularly fails timing (it estimates over 200 ns on a Virtex 7). If I simply make the loop count an input variable then it behaves as expected. Unfortunately there doesn't seem to be a way to disable loop unrolling.
11-04-2016 01:40 AM
Hi @jprice,
As mentioned in the UG902, Loops should be rolled by default:
Please make sure you have no directive or pragma that could unroll your loop.
Regards,
Florent
11-05-2016 03:29 AM
That's odd, as @florentw has said HLS does not unroll loops by default. Only if you tell it to unroll loops, or if a higher-level loop has been pipelined. Your while() loop isn't pipelined, is it? With that said, I've seen HLS make invalid "optimizations" before (like specifying an AXI master burst for a non-pipelined loop with an iteration latency of thousands of clock cycles) so it's not impossible that it's completely confused.
Are there messages to say that it's unrolling the loop completely?
If all else fails, try shifting the loop to a separate function and using "#pragma HLS INLINE off" to force proper instantiation. Having that hierachy seems to help HLS when it's getting confused about what can happen when.