Intel® FPGA SDK for OpenCL™ Pro Edition: Programming Guide

ID 683846
Date 12/19/2022
Public
Document Table of Contents

11.1.7.2. Simulating Your OpenCL* Library

If you want to view the waveforms generated during simulation, you must install and configure Siemens* EDA QuestaSim* software.

Important:

You can also run the emulator and simulator from separate terminal or command prompt sessions.

To run your OpenCL* library through the simulator:

  1. Run the utility command aocl linkflags to find out which libraries are necessary for building a host application. The software lists the libraries for both emulation and regular kernel compilation flows.
  2. Build a host application and link it to the libraries from Step 1.
    Tip: To emulate multiple devices alongside other OpenCL SDKs, link your host application to the Khronos ICD Loader Library before you link it to the host runtime libraries. Link the host application to the ICD Loader Library by modifying the Makefile for the host application. For more information, see Linking Your Host Application to the Khronos ICD Loader Library.
  3. If necessary, move the .aocx file to a location where the host can find easily, preferably the current working directory.
  4. Set the CL_CONTEXT_MPSIM_DEVICE_INTELFPGA environment variable to enable the simulation device:
    • Windows:
      set CL_CONTEXT_MPSIM_DEVICE_INTELFPGA=1
    • Linux:
      env CL_CONTEXT_MPSIM_DEVICE_INTELFPGA=1
    Remember: When the environment variable CL_CONTEXT_MPSIM_DEVICE_INTELFPGA is set, only the simulation devices are available. That is, access to physical boards and the emulation device is disabled.

    You might need to set CL_CONTEXT_COMPILER_MODE_INTELFPGA=3 if the host program cannot find the simulator device.

  5. Run your host program.
    To debug your host code and device, you can run your host code in gdb or Eclipse.

    Running the host program gives you a waveform file, vsim.wif, that you can view in QuestaSim* software as your host code executes. The vsim.wif file is written to the same directory that you run your host program from.

  6. If you change your host or kernel program and you want to test it, only recompile the modified host or kernel program and then rerun simulation.