Compiler Macros

Predefined macros allow you to guard code with #ifdef and #ifndef preprocessor statements. The macro names begin and end with two underscore characters ‘_’. The __SDSCC__ macro is defined whenever sdscc or sds++ (referred to collectively as sds++) is used to compile source files. It can be used to guard code depending on whether it is compiled by sds++ or another compiler, for example GCC.

When sds++ compiles source files targeted for hardware acceleration using Vivado® HLS, the __SDSVHLS__ macro is defined to be used to guard code depending on whether high-level synthesis is run or not.

The code fragment below illustrates the use of the __SDSCC__ macro to use the sds_alloc() and sds_free() functions when compiling source code with sds++, malloc(), and free() when using other compilers.
#ifdef __SDSCC__
#include <stdlib.h>
#include "sds_lib.h"
#define malloc(x) (sds_alloc(x))
#define free(x) (sds_free(x))
#endif
In the example below, the __SDSVHLS__ macro is used to guard code in a function definition that differs depending on whether it is used by Vivado HLS to generate hardware or used in a software implementation.
#ifdef __SDSVHLS__
void mmult(ap_axiu<32,1,1,1> A[A_NROWS*A_NCOLS],
           ap_axiu<32,1,1,1> B[A_NCOLS*B_NCOLS],
           ap_axiu<32,1,1,1> C[A_NROWS*B_NCOLS])
#else
void mmult(float A[A_NROWS*A_NCOLS],
           float B[A_NCOLS*B_NCOLS],
           float C[A_NROWS*B_NCOLS])
#endif

In addition, the macro, HLS_NO_XIL_FPO_LIB, is defined prior to the include option for Vivado HLS headers and is visible to Vivado HLS, SDSoC™ analysis tools, and target cross-compilers. This macro disables the use of bit-accurate, floating-point simulation models, instead using the faster (although not bit-accurate) implementation from your local system. Bit-accurate simulation models are not provided for Zynq-7000 SoC and Zynq® UltraScale+™ MPSoC Arm® targets.