Optimize MATLAB C/C++ Code For HLS

The design flow steps used to convert C/C++ algorithms to a hardware implementation.

popularity

A common use case for high-level synthesis (HLS) is taking 3rd party generated or legacy C/C++ algorithms and converting the algorithm to a hardware implementation using an HLS compiler. This can present many challenges to the developer since there is little insight or understanding of the underlying code.

In a recently published white paper, we examine how SLX FPGA is used to take a MATLAB Embedded Coder generated C/C++ algorithm, in this case a Kalman filter, and optimize the C/C++ code for HLS. In this example, SLX FPGA provides more than 62x improvement in performance after auto-insertion of HLS pragmas when compared to the solution created by the HLS compiler for the original code, which had no pragmas inserted.

The following design flow steps are explored in detail in the white paper:

Refactor non-synthesizable code for HLS – After generating the algorithm C/C++ code in MATLAB Embedded Coder, SLX FPGA identifies code which is non-synthesizable by HLS compilers and provides automated and guided code refactoring to transform code into HLS synthesizable code.

Parallelism detection – SLX FPGA detects parallelism and guides the developer on how to exploit it in a hardware implementation. SLX FPGA also flags roadblocks for parallelism and helps the user eliminate them to drive additional parallelism.

Hardware optimization – SLX FPGA performs exploration of the appropriate function pipelining and loop unrolling, providing data for the hardware through array partitioning and design space of interfaces available on the target platform.

Pragma insertion – SLX FPGA automatically inserts HLS pragmas that guide the compiler in optimizations. HLS pragmas include various parameters that require tuning. SLX FPGA leverages static and dynamic analysis data and combines it with optimization algorithms to insert tuned and optimized pragmas based on the developer-provided constraints.

For a detailed analysis on how to move your MATLAB Embedded coder generated algorithm to an FPGA using SLX and Vivado HLS, download our white paper, “Facilitating High Level Synthesis from MATLAB generated C/C++.”



Leave a Reply


(Note: This name will be displayed publicly)