How to handle memories when loops are unrolled?

Hey everyone! I’m diving into loop unrolling in HLS and running into some head-scratchers around memory handling.

How to handle memories when loops are unrolled?

Any best practices, gotchas, or examples would be hugely appreciated!

Thanks in advance :raised_hands:

Hi Taylor,

When loops are unrolled, it is important to make sure that the corresponding memory accesses are available. When complete unrolling is done, then all indices of memory should be available at the same clock cycle. This is only possible when they are registers. When partial unrolling is done, based on memory accesses, the memory blocks need to be split into cyclic (interleave) or contiguous blocks (Block_size) based on the access pattern of data.

You can always remove pipelining and look at the number of memory reads/writes you will need in the schedule. Memories can be handled in a step by step process. No pipelining &unrolling->Partial unrolling-> Full unrolling-> Full unrolling + pipelining. This will give a good idea on how to handle memories.

A simple convolution is a good example to start by unrolling the inner loop and then progressing to the outer loops to understand how memory accesses work and how memory splitting should be performed while loop unrolling.