Using Vivado Design Suite HLS Libraries

This section describes how to use Vivado HLS libraries with the SDSoC environment.

Vivado® High-Level Synthesis (HLS) libraries are provided as source code with the Vivado HLS installation in the SDSoC environment. Consequently, you can use these libraries as you would any other source code that you plan to cross-compile for programmable logic using Vivado HLS. In particular, you must ensure that the source code conforms to the rules described inHardware Function Argument Types, which might require you to provide a C/C++ wrapper function to ensure the functions export a software interface to your application.

The synthesizeable FIR example template for all basic platforms in the SDSoC IDE provides an example that uses an HLS library. You can find several additional code examples that employ HLS libraries in thesamples/hls_libdirectory. For example,samples/hls_lib/hls_mathcontains an example to implement and use a square root function.

The file my_sqrt.hcontains:
#ifndef _MY_SQRT_H_ #define _MY_SQRT_H_ #ifdef __SDSVHLS__ #include "hls_math.h" #else // The hls_math.h file includes hdl_fpo.h which contains actual code and // will cause linker error in the ARM compiler, hence we add the function // prototypes here static float sqrtf(float x); #endif void my_sqrt(float x, float *ret); #endif // _SQRT_H_
The file my_sqrt.cppcontains:
#include "my_sqrt.h" void my_sqrt(float x, float *ret) { *ret = sqrtf(x); }
The makefile has the commands to compile these files:
sds++ -c -hw my_sqrt –sds-pf zc702 my_sqrt.cpp sds++ -c my_sqrt_test.cpp sds++ my_sqrt.o my_sqrt_test.o -o my_sqrt_test.elf