启动内核前添加 ILA 触发器 - 2023.2 简体中文

Vitis 统一软件平台文档 应用加速开发 (UG1393)

Document ID
UG1393
Release Date
2023-12-13
Version
2023.2 简体中文

通过在代码中使用暂停 (pause) 或等待 (wait) 步骤即可完成主机程序的暂停操作,例如,GitHub 上的 RTL 内核中使用的 wait_for_enter 函数。该函数在 src/host.cpp 代码中定义,如下所示:

void wait_for_enter(const std::string &msg) {
    std::cout << msg << std::endl;
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}

wait_for_enter 函数在 main 函数中按如下方式使用:

....
    std::string binaryFile = xcl::find_binary_file(device_name,"vadd");
	
    cl::Program::Binaries bins = xcl::import_binary_file(binaryFile);
    devices.resize(1);
    cl::Program program(context, devices, bins);
    cl::Kernel krnl_vadd(program,"krnl_vadd_rtl");


     wait_for_enter("\nPress ENTER to continue after setting up ILA trigger...");

    //Allocate Buffer in Global Memory
    std::vector<cl::Memory> inBufVec, outBufVec;
    cl::Buffer buffer_r1(context,CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY, 
            vector_size_bytes, source_input1.data());
    ...

    //Copy input data to device global memory
    q.enqueueMigrateMemObjects(inBufVec,0/* 0 means from host*/);

    //Set the Kernel Arguments
    ...

    //Launch the Kernel
    q.enqueueTask(krnl_vadd);

使用 wait_for_enter 函数即可暂停主机程序,为您提供时间,以便您设置所需的 ILA 触发器,并准备捕获来自内核的数据。完成 Vivado 硬件管理器的设置和配置后,请按 Enter 键以继续运行应用。

  • 对于 C++ 主机代码,创建 cl::Kernel 对象后请添加暂停,如以上示例所示。
  • 对于 C 语言主机代码,请在 clCreateKernel() 函数调用后添加暂停: