1. allocation
define and limit 对于某些function/operation/core instantiation 的次数
Place inside the the body of the function, loop or region where it will apply
#pragma HLS allocation instances=<list> limit=<value> <type>
<list>: 想要limit的对象的name
根据<type>:function可以是任意没有被inlined的函数
operation是Vivado HLS自带的operator;比如 add ashr sub mul
core 自带,三类functional/floating point/storage; 比如AddSub DSP48 FIFO
<value>: limit instance 的数量
<type>: [function; operation; core]
2. array_map
为了减少BRAM资源,将几个小arrays合成一个大array( RAM or FIFO)
basic BRAM unit in FPGA is 18k; 18x1000/32bit = 500
如果small array没有完全使用18k, 最好map small arrays into a single larger array
完成功能时还是用小array的名字写代码
Place within the boundaries of the function where the array variable defined
#pragma HLS array_map variable=<name> instance=<instance> <mode> offset=<int>
<name>: 是小array的名字
<instance>: 是新建大array的名字
<mode>: [horizontal] 默认模式; 串联原来的小array,合成后more elements ; start at elememt 0; bit-width取小arrays
的bit-width中的最大值
[vertical] 每个小array对应位置的元素连成一整个word,合成后longer words 也就是larger bit-width; start
at bit 0; 大array中元素数量是maximun of the orinigal small arrays
offset: 只针对horizontal mode; 若没指定会自动生成; 小array的第一个element对应新的大array中第<int>个元素,之
后的index就是<int+1>,<int+2>... of the new target
Example:
int8 array1[10]
int12 array2[5]
#pragma HLS ARRAY_MAP variable=array1 instance=array3 horizontal
#pragma HLS ARRAY_MAP variable=array2 instance=array3 horizontal
没有specify offset,所以array3[0] = array1[0]; array3[10] = array2[0]; array3 的bit-width是int12
3. array_partition
把一个large memory 变成 small memories or registers
增加read/write port的数量
可能会improve the throughput
需要更多的memory instances or registers
Place where the array is defined
#pragma HLS array_partition variable=<name> <type> factor=<int> dim=<int>
<type>: [complete] default; 完全分割成individual elements; 对于一维数组,意味着分成独立的registers
[block] 连续分割成N个block
[cyclic] 循环放入每个array; 比如factor=2, 意味着 element0 分配到first array, e1 second array, e3 first array
factor : 指定新产生的smaller array的数量; complete 不需要指定
dim : 非零数指定数组被分割的维度; dim是0意味所有维度都被分割
Example:
AB[13]
#pragma HLS array_partition variable=AB block factor=4
分割成3 3 3 4, 最后一个array是AB[9:12]
#pragma HLS array_partition variable=AB block factor=2 dim=2
分割dimension two of the two-dimensional array, AB[6][4] into two new arrays of dimension [6][2]: