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 #ifdef and #ifndef preprocessor statements; the macro names begin and end with two underscore characters ‘_’. For examples, see SDSCC/SDS++ Compiler Commands and Options.
    • The __SDSCC__ macro is defined and passed as a -D option to sub-tools whenever sdscc or sds++ is used to compile source files, and can be used to guard code dependent on whether it is compiled by sdscc/sds++ or by another compiler, for example a GNU host compiler.
    • When sdscc or sds++ compiles source files targeted for hardware acceleration using Vivado HLS, the __SDSVHLS__ macro is defined and passed as a -D option, 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 the sdscc (and sds++) 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 using sdscc. In such cases, compile the source files directly through the GNU toolchain rather than through sdscc, either in your makefiles or by setting the compiler to arm-linux-gnueabihf-g++ by right-clicking on the file (or folder) in the Project Explorer and selecting C/C++ Build > Settings > SDSCC/SDS++ Compiler.