As discussed in earlier topics, several important aspects of coding the kernel for FPGA acceleration using C/C++ include the following points:
- Consider using arbitrary precision data types,
ap_int, andap_fixed. - Understand kernel interfaces to determine scalar and memory interfaces. Use
bundleswitch with different names if separate DDR memory banks will be specified in the linking stage. - Use Burst read and write coding style from and to the memory interface.
- Consider exploiting the full width of DDR banks during the data transfer when selecting width of memory data inputs and outputs.
- Get the greatest performance boost using pipelining and dataflow.
- Write perfect or semi-perfect nested loop structure so that the
v++compiler can flatten and apply pipeline effectively. - Unroll loops with a small number of iterations and low operation count inside the loop body.
- Consider understanding the array access pattern and apply
completepartition to specific dimensions or applyblockorcyclicpartitioning instead of acompletepartition of the whole array. - Minimize the array access by using local cache to improve kernel performance.
- Consider inlining the function, specifically inside the pipelined region. Functions inside the dataflow should not be inlined.
- Consider using auto-restarting kernels for data-driven designs with streaming data from the I/O pins (Ethernet, SerDes) of the device, or from another kernel.