General C/C++ Guidelines

  • Hardware functions can execute concurrently under the control of a master thread. Multiple master threads are supported.
  • A top-level hardware function must be a global function, not a class method, and it cannot be an overloaded function.
  • There is no support for exception handling in hardware functions.
  • It is an error to refer to a global variable within a hardware function or any of its sub-functions when this global variable is also referenced by other functions running in software.
  • Hardware functions support scalar types up to 1024 bits, including double, long long, packed structs, etc.
  • A hardware function must have at least one argument.
  • An output or inout scalar argument to a hardware function can be assigned multiple times, but only the last written value will be read upon function exit.
  • Use predefined macros to guard code with#ifdefand#ifndefpreprocessor statements; the macro names begin and end with two underscore characters ‘_’. For examples, seeSDSCC/SDS++ Compiler Commands and Options.
    • The__SDSCC__macro is defined and passed as a-Doption to sub-tools wheneversdsccorsds++is used to compile source files, and can be used to guard code dependent on whether it is compiled bysdscc/sds++or by another compiler, for example a GNU host compiler.
    • Whensdsccorsds++compiles source files targeted for hardware acceleration using Vivado HLS, the__SDSVHLS__macro is defined and passed as a-Doption, and can be used to guard code dependent on whether high-level synthesis is run or not.
    • In 2017.1 running on the Windows operating system, you will typically have to use these macros to guard code that will be synthesized within SDx with type long long (which should be 64 bits).
    • Vivado HLS employs some 32-bit libraries irrespective of the host machine. Furthermore, the tool does not provide a true cross-compilation.

All object code for the ARM CPUs is generated with the GNU toolchains, but thesdscc(andsds++) compiler, built upon Clang/LLVM frameworks, is generally less forgiving of C/C++ language violations than the GNU compilers. As a result, you might find that some libraries needed for your application cause front-end compiler errors when usingsdscc. In such cases, compile the source files directly through the GNU toolchain rather than throughsdscc, either in your makefiles or by setting the compiler toarm-linux-gnueabihf-g++by right-clicking on the file (or folder) in theProject Explorerand selectingC/C++ Build>Settings>SDSCC/SDS++ Compiler.