Intel® High Level Synthesis Compiler Pro Edition: Reference Manual

ID 683349
Date 6/20/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

2.3. Compiler Interoperability

You can compile your testbench code with GCC or Microsoft Visual Studio, but generating RTL and simulation support for your component always requires the Intel® HLS Compiler.
The following table shows which parts of your design you can compile with each compiler:
  GCC/MSVC i++
Testbench X X
Component (emulation) X X
Component (RTL)   X
Restriction: You cannot use GCC and Microsoft Visual Studio to compile code that uses any Intel® HLS Compiler provided header files other than HLS/hls.h. For some arbitrary precision data types, the Intel® HLS Compiler provides reference headers that can be compiled GCC and Microsoft Visual Studio along with the FPGA-optimized headers. For details, see Arbitrary Precision Math Support.

To see what versions of GCC and Microsoft Visual Studio the Intel® HLS Compiler supports, see " Intel® High Level Synthesis Compiler Prerequisites" in Intel® High Level Synthesis Compiler Getting Started Guide.

To use a native compiler (GCC or Microsoft Visual Studio) to compile your Intel® HLS Compiler code, you must run your native compiler from a terminal session where you initialized the environment for the Intel® HLS Compiler. The initialization script chooses the correct native compiler for you system.

GCC

To compile your Intel® HLS Compiler code with GCC:
  1. Initialize your environment with the Intel® HLS Compiler initialization script:
    <quartus_installdir>/hls/init_hls.sh
  2. Add the path to the Intel® HLS Compiler header files to the g++ command include path with the -l command option.

    The header files are in the quartus_installdir/hls/include directory.

  3. Add the path to the HLS emulation library to the linker search path with the -L command option.

    The emulation library is in the quartus_installdir/hls/host/linux64/lib directory.

  4. Add the hls_emul library to the linker command (that is, specify -lhls_emul as a command option).
  5. Ensure that you specify the -std=c++17 option of the g++ command.
  6. If you want to generate debug symbols, specify the -g option of the g++ command.
  7. If you are using HLS tasks in a system of tasks (ihc::launch and ihc:collect), specify the -pthread option of the g++ command.
  8. If you are using arbitrary precision datatypes, include the reference version in your source code instead of the FPGA-optimized version provided with the Intel® HLS Compiler. You can use the __INTELFPGA_COMPILER__ macro to control which variant is included. For example, if you are using arbitrary precision integers, you can use the following macro code
    #ifdef __INTELFPGA_COMPILER__ 
    #include "HLS/ac_int.h" 
    #else 
    #include "ref/ac_int.h" 
    #endif 
If you implement these steps, your g++ command resembles the following example command:
g++ myFile.cpp -g -I"$(HLS_INSTALL_DIR)/include" 
               -L"$(HLS_INSTALL_DIR)/host/linux64/lib" -lhls_emul 
               -pthread -std=c++17 

Microsoft Visual C++

The following instructions were tested with Microsoft Visual Studio 2017 Professional.

To compile your Intel® HLS Compiler code with Microsoft Visual C++:

  1. Initialize your environment with the Intel® HLS Compiler initialization script:
    <quartus_installdir>/hls/init_hls.bat
  2. Add the Intel® HLS Compiler header files to the compiler command include path with the /l command option.

    The header files are in the quartus_installdir\hls\include directory.

  3. Add the /Zi option to generate debug symbols when compiling.
  4. Add the /wd4068 option to suppress warnings because MSVC does not recognize the Intel® HLS Compiler pragmas.
  5. Add the HLS emulation library to the linker search path with the /libpath command option.

    The emulation library is in the quartus_installdir\hls\host\windows64\lib directory.

  6. Add the hls_emul library to the linker command.
  7. If you are using arbitrary precision datatypes, include the reference version instead of the FPGA-optimized version provided with the Intel® HLS Compiler. You can use the __INTELFPGA_COMPILER__ macro to control which version is included:
    #ifdef __INTELFPGA_COMPILER__ 
    #include "HLS/ac_int.h" 
    #else 
    #include "ref/ac_int.h" 
    #endif 
Your Microsoft Visual C++ compiler command should resemble the following example command:
cl myFile.cpp /I "%HLS_INSTALL_DIR%\include" /nologo /EHsc /wd4068 /MD 
              /std:c++17 /Zi 
              /link "/libpath:%HLS_INSTALL_DIR%\host\windows64\lib" 
              hls_emul.lib