Hardware Emulation and Hardware Flows - 2025.2 English - UG1079

AI Engine Kernel and Graph Programming Guide (UG1079)

Document ID
UG1079
Release Date
2025-11-26
Version
2025.2 English

You can use input_gmio and output_gmio not only with the AI Engine simulator. They also work in hardware emulation and full hardware flows. To enable in hardware emulation and hardware flows, add the following code to graph.cpp.

#if !defined(__AIESIM__) && !defined(__X86SIM__)
    #include "adf/adf_api/XRTConfig.h"
    #include "experimental/xrt_kernel.h"
    // Create XRT device handle for ADF API
    
    char* xclbinFilename = argv[1];
    auto dhdl = xrtDeviceOpen(0);//device index=0
    xrtDeviceLoadXclbinFile(dhdl,xclbinFilename);
    xuid_t uuid;
    xrtDeviceGetXclbinUUID(dhdl, uuid);
       
    adf::registerXRT(dhdl, uuid);
#endif

Using the guard macro __AIESIM__ and __X86SIM__, the same version of graph.cpp can work for the AI Engine simulator, x86simulator, hardware emulation, and hardware flows. Place the preceding code before calling the graph or the GMIO ADF APIs. At the end of the program, close the device using the xrtDeviceClose() API.

#if !defined(__AIESIM__) && !defined(__X86SIM__)
    xrtDeviceClose(dhdl);
#endif

To compile the code for hardware flow, see Programming the PS Host Application in AI Engine Tools and Flows User Guide (UG1076).