The data types used in a C/C++ function compiled into an executable impact the accuracy of the result and the memory requirements, and can impact the performance.
- A 32-bit integer int data type can hold more data and therefore provide more precision than an 8-bit char type, but it requires more storage.
- If 64-bit
long longtypes are used on a 32-bit system, the runtime is impacted because it typically requires multiple accesses to read and write those values.
Similarly, when the C/C++ function is to be synthesized to an RTL implementation, the types impact the precision, the area, and the performance of the RTL design. The data types used for variables determine the size of the operators required and therefore the area and performance of the RTL.
Vitis HLS supports the synthesis of all standard C/C++ types, including exact-width integer types.
(unsigned) long long
Nis 8, 16, 32, and 64, as defined in stdint.h)
Exact-width integers types are useful for ensuring designs are portable across all types of system.
The C/C++ standard dictates that type
(unsigned)long is implemented as 64 bits on 64-bit operating systems and
as 32 bits on 32-bit operating systems. Synthesis matches this behavior and produces
different sized operators, and therefore different RTL designs, depending on the type of
operating system on which Vitis HLS is run. On
Windows OS, Microsoft defines type long as 32-bit, regardless of the OS.
- Use data type
(unsigned)int32_tinstead of type
- Use data type
(unsigned)int64_tinstead of type
-m32may be used to specify that the code is compiled for C/C++ simulation and synthesized to the specification of a 32-bit architecture. This ensures the long data type is implemented as a 32-bit value. This option is applied using the
-CFLAGSoption to the
Xilinx highly recommends defining the data types for all variables in a common header file, which can be included in all source files.
- During the course of a typical Vitis HLS project, some of the data types might be refined, for example to reduce their size and allow a more efficient hardware implementation.
- One of the benefits of working at a higher level of abstraction is the ability to quickly create new design implementations. The same files typically are used in later projects but might use different (smaller or larger or more accurate) data types.
Both of these tasks are more easily achieved when the data types can be changed in a single location: the alternative is to edit multiple files.
_TYPES_His defined in your header file, it is likely that such a common name might be defined in other system files, and it might enable or disable some other code causing unforeseen side effects.
std::complex<long double>data type is not supported in Vitis HLS and should not be used.