Common Synthesis Errors - 2021.2 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
English (United States)
Release Date
2021.2 English

The following are common use errors when synthesizing math functions. These are often (but not exclusively) caused by converting C functions to C++ to take advantage of synthesis for math functions.

C++ cmath.h

If the C++ cmath.h header file is used, the floating point functions (for example, sinf and cosf) can be used. These result in 32-bit operations in hardware. The cmath.h header file also overloads the standard functions (for example, sin and cos) so they can be used for float and double types.

C math.h

If the C math.h library is used, the single-precision functions (for example, sinf and cosf) are required to synthesize 32-bit floating point operations. All standard function calls (for example, sin and cos) result in doubles and 64-bit double-precision operations being synthesized.


When converting C functions to C++ to take advantage of math.h support, be sure that the new C++ code compiles correctly before synthesizing with Vitis HLS. For example, if sqrtf() is used in the code with math.h, it requires the following code extern added to the C++ code to support it:

#include <math.h>
extern ā€œCā€ float sqrtf(float);

To avoid unnecessary hardware caused by type conversion, follow the warnings on mixing double and float types discussed in Floats and Doubles.