Versal - 基础5(裸机开发 AIE-ML+Vitis2024.2界面aie report介绍)
本文以官方 A to Z Bare-metal Flow 为基准,在 VD100 硬件平台上实现的例子。包含如下内容:申请 AIE License创建 Vivado 可扩展平台(XSA)创建 Vitis 平台(XPFM)创建 AIE 应用创建 HLS 应用系统集成:VPP 链接 pl_app、aie_app创建 ps_app 应用系统集成:打包生成 sd_card.img在 VD100 硬件平台上
目录
1. 简介
本文以官方 A to Z Bare-metal Flow 为基准,在 VD100 硬件平台上实现的例子。

博文包含如下内容:
- 申请 AIE License
- 创建 Vivado 可扩展平台(XSA)
- 创建 Vitis 平台(XPFM)
- 创建 AIE 应用
- 创建 HLS 应用
- 系统集成:VPP 链接 pl_app、aie_app
- 创建 ps_app 应用
- 系统集成:打包生成 sd_card.img
- 在 VD100 硬件平台上运行
- Vitis2024.2界面介绍
- aie Build report
- aie Run report
2. 申请 License
2.1 申请网址
2.2 填写 Host

2.3 导入 License

导入成功后:

PS,如果没有此 License,构建 AIE 应用时将失败:
AIEMLbuild feature license not found !
make[2]: *** [CMakeFiles/simple_aie_application_libadf.a.dir/build.make:80: libadf.a] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/simple_aie_application_libadf.a.dir/all] Error 2
make[1]: Leaving directory '..../vd100_a2z/simple_aie_application/build/hw'
make: *** [Makefile:91: all] Error 2
[ERROR] simple_aie_application build failed.
3. 示例
3.1 vivado_platform
3.1.1 由模板创建

- Versal Extensible Embedded Platform:基于官方开发板构建示例工程
- Versal Extensible Embedded Platform (Part based):基于 Versal 芯片构建示例工程
点击 Next 选择工程路径和芯片型号。
3.1.2 模板参数

3.1.3 修改BD参数
- 修改参考时钟名称为:ddr_cref
- 修改参考时钟频率为:200 MHz
- 修改 DDR 接口名称为:DDR4

3.1.4 配置CIPS和MC
1)按照《Versal - 基础1(PL点灯+构建CIPS+VD100+查找资料和文档)》博文中,“3.2 CIPS system” 章节,进行 CIPS 和 AXI NoC 的配置:
2)如上述引用博文,同样参考进行 xdc 配置。
3)Validate Design,并忽略警告:

3.1.5 导出PFM
1)生成 PDI 后,选择导出 PFM:

2)平台类型:Hardware and hardware emulation

3)查看生成后的 PFM:
ll vd100_wrapper.xsa
---
-rw-rw-r-- 1 dd dd 28130725 2月 3 18:02 vd100_wrapper.xsa
3.2 vitis_platform
3.2.1 创建组件
1)打开 Vitis IDE,并选择一个工作区
2)File → New Component → Platform 或者 Create Platform Component:

3.2.2 导入XSA并配置
1)导入 XSA 文件。
2)选择操作系统和处理器:
- 操作系统:aie_runtime
- 处理器:ai_engine

3)点击完成,即可创建平台组件。
3.2.3 构建平台组件
完成上一步操作后,单击下面的 Build 即可构建对应的组件。

构建完毕后,可以在 Output 中查看生成的文件(xpfm)
3.3 aie_app
- 输出内容由 aiecompiler 工具执行
- 输出内容包含 Work 目录和 libadf.a 文件。
- libadf.a 文件包含编译的编译的 AI 引擎配置、Graph 和 Kernel.elf 文件。
3.3.1 从示例中创建
- Create AI Engine Component from Template
- Name: simple_aie_application

注意描述:
A simple 2-kernel graph with window based data communication. Note: This template works only for AIE Emulation and SW(x86) Emulation.
模板仅适用于 AI 引擎仿真和软件(x86)模拟。但后续也可硬件上实现它。
选择平台后,完成示例工程创建:

3.3.2 工程结构
创建成功后的 aie 工程结构:
- src 包含 kernels 和 graph
- data 包含模拟输入( input.txt )和输出参考( golden.txt )的数据

3.3.3 代码解读
1)Graph 代码
打开文件 project.h 查看图表。
simpleGraph 有一个输入和一个输出,并实现了具有相同功能的两个内核。第一个内核的输出为第二个内核提供数据。
first = kernel::create(simple);
second = kernel::create(simple);
adf::connect(in.out[0], first.in[0]);
connect(first.out[0], second.in[0]);
connect(second.out[0], out.in[0]);

2)kernel 代码
打开文件 kernels/kernels.cc,查看内核实现的功能:
- 对复数 (a + bi) 进行简单的线性变换:c2=(a+b)+j(a−b)
void simple(adf::input_buffer<cint16> & in, adf::output_buffer<cint16> & out) {
cint16 c1, c2;
cint16* inItr = in.data();
cint16* outItr = out.data();
for (unsigned i=0; i<NUM_SAMPLES; i++) {
c1 = *inItr++;
c2.real = c1.real+c1.imag;
c2.imag = c1.real-c1.imag;
*outItr++ = c2;
}
}
其中:
- c1 和 c2,分别存储输入数据和计算结果。
- inItr 和 outItr 分别是指向 输入缓冲区 和 输出缓冲区 的指针,用于遍历数据。
- adf 代表 Adaptive Data Flow (ADF),它是 AIE 编程模型的一部分。
3.3.4 Build AIE
1)选择 simple_aie_application 组件,然后在 AIE SIMULATOR / HARDWARE 下点击 Build,完成后会有一个标志,如下图:

2)构建完毕
Compilation Complete
(WARNING:0, CRITICAL-WARNING:0, ERROR:0)
INFO: [v++ 60-791] Total elapsed time: 0h 0m 49s
make[2]: Leaving directory '/home/dd/Documents/vivado_prj/vitis_2024_prj/a2z/simple/build/hw'
[100%] Built target simple_libadf.a
make[1]: Leaving directory '/home/dd/Documents/vivado_prj/vitis_2024_prj/a2z/simple/build/hw'
/opt/Xilinx/Vitis/2024.2/tps/lnx64/cmake-3.24.2/bin/cmake -E cmake_progress_start /home/dd/Documents/vivado_prj/vitis_2024_prj/a2z/simple/build/hw/CMakeFiles 0
Build Finished successfully
--------------------------------------------------------------------------------
[2/9/2025, 6:30:52 PM]: Build for simple::hw with id 'xxx' ended.
3)输出内容

3.3.5 Run Simulation
1)选择 Run 启动仿真,需要首先创建 configuration:


2)创建 configuration,保持默认即可,然后单击 Run:

3)仿真完毕:


3.4 hls_comp
1)目的:在 DDR 和 AXI4-Stream 接口之间架起桥梁,用于从 DDR 输入和输出数据。
- 内核 mm2s 从内存读取数据并将其输入到 AI 引擎数组。
- 内核 s2mm 从 AI 引擎数组接收输出数据并将其写入内存。
2)添加 HLS Component:File - New Component - HLS
- Name:mm2s
- Configuration File:默认(新建)
- 按照下图添加 mm2s 文件,并设置顶层函数:

3)平台选择:

4)流程和输出格式
- flow_target:Vitis Kernel Flow Target
- package.output.format:Generate a Vitis XO

5)重复上述步骤,创建另一个名为 s2mm 的 HLS 组件:

3.5 vpp_link
目的:告知 Vitis 链接器如何将所有内容连接在一起。
3.5.1 System project
1)File > New Component > System Project
- System Project Name:simple_aie_application_system_project
- 平台:继续沿用之前步骤创建的平台
2)Embedded Component Paths 保持空白,因为此页面用于运行 Linux 的系统。

3.5.2 修改主函数

主函数在 project.cpp 中不需要被用于硬件运行,因此需要添加一个开关( #if defined(...) ),以便主函数不会被考虑在硬件构建中。
#if defined(__AIESIM__) || defined(__X86SIM__) || defined(__ADF_FRONTEND__)
int main(void)
{
mygraph.init();
mygraph.run(4);
mygraph.end();
return 0;
}
#endif
3.5.3 添加成员组件
1)在下图 Components 中,单击 Add Existing Component:
- 点击 HLS 并选择 mm2s 和 s2mm 组件
- 点击 AI Engine 并选择 simple_aie_application 组件



2)在 binary_container_1-link.cfg 中,将视图更改为源代码编辑器,并在[connectivity]下添加以下行:
```
stream_connect=mm2s_1.s:ai_engine_0.mygraph_in
stream_connect=ai_engine_0.mygraph_out:s2mm_1.s
```


3)启用 Export hardware (XSA)

3.5.4 构建Bin容器
1)在 Flow Navigator 中,选择 simple_aie_application_system_project。
- 然后在 HARDWARE > LINK - binary_container_1 下点击 Build Binary Container。
- 当提示构建 HLS 组件(mm2s 和 s2mm)时,点击确定。

mm2s 和 s2mm 未被构建过,默认自动勾选了。

2)Build Binary Container 完毕:

Log 有如下输出:
make[1]: Leaving directory '<workspace>/simple_aie_application_system_project/build/hw'
Build Finished successfully
--------------------------------------------------------------------------------
[2/5/2025, 12:10:24 AM]: Build for simple_aie_application_system_project::binary_container_1::hw with id 'xxxxxx' ended.
3)可以根据上述 Log 内容,打开构建的 Vivado 项目:
<workspace>/simple_aie_application_system_project/build/hw/hw_link/binary_container_1/binary_container_1/vivado/vpl/prj/prj.xpr

其中新增了 VitisRegion,由 Vitis 生成。

展开,进一步查看该 Group:

3.6 New vitis_pfm
1)File → New Component → Platform
- Component Name:AIE_A-to-Z_pfm_vd10
- 选择使用上一步骤生成的 XSA,地址如下:
simple_aie_application_system_project/build/hw/hw_link/binary_container_1.xsa

2)操作系统和处理器(保持默认)

3)新建的平台如下:

与之前创建的平台对比:

3.7 ps_app
3.7.1 创建app组件
1)File → New Component → Application
- Component Name:A-to-Z_app
2)平台选择:

3)导入源文件:
- aie_control.cpp,在之前创建的 simple_application 子项目中:
simple_application/build/hw/Work/ps/c_rts/aie_control.cpp
- main.cpp,在 Git 仓库中。

也可先跳过导入,后续在工程目录中导入:

4)main 函数解释
系统启用 AI Engine graph 的两种方法:
在 PDI 中启动,AI Engine graph 将在启动时启动并永远运行。
在 PS Application 中启动,使用 <graph>.init() 和 <graph>.run() API。(本例采用)
printf("Starting AIE Graph\n");
printf("Graph Initialization\n");
mygraph.init();
printf("Done \n");
printf("- \n");
printf("Running Graph for 4 iterations\n");
mygraph.run(4);
3.7.2 编译配置
1)在 A-to-Z_app Component 下,打开 Settings > UserConfig.cmake > Directories > Include Paths (-I),添加以下目录:
<workspace>/simple_aie_application/src
$ENV{XILINX_VITIS}/aietools/include

2)同样在 A-to-Z_app Component 下,打开 Settings > UserConfig.cmake > Libraries
- 在 Libraries (-l) 下添加:adf_api
- 在 Library search path (-L) 下添加:$ENV{XILINX_VITIS}/aietools/lib/aarchnone64.o

3.7.3 链接配置
目的:增加 AIE 库的堆(heap)大小。
Vitis Explorer > A-to-z_app > Sources > src > lscript.ld
修改 Heap size:0x100000 (1MB)。

3.7.4 Build app

构建完毕:
text data bss dec hex filename
1955653 18700 1082221 3056574 2ea3be A-to-Z_app.elf
Build Finished successfully
3.8 hw_package
1)找到 package.cfg 配置文件

2)在 Gneral > Baremetal Elf 中填写对应的 ELF 文件:
<...>/A-to-Z_app/build/A-to-Z_app.elf, a72-0

3)在 AI Engine 中:
- 勾选 Do not enable cores
- 不勾选 Enable debug

4)构建 simple_aie_application_system_project:
在 HARDWARE 中执行 Build All

3.9 Run on VD100
3.9.1 烧写
1)在 Windows 中,使用 Rufus 工具烧写:

2)在 Ubuntu 中,使用 usb-creator-gtk 工具烧写:


3)烧写后:

3.9.1 连接与配置
1)VD100 先不通电,与 Windows PC 通过USB A-Mini 线缆连接,
- MobaXterm Baudrate:115200
![]()
2)BOOT MODE:SD2.0

3)上电即运行。
3.9.3 运行结果
[0.020]****************************************
[0.063]Xilinx Versal Platform Loader and Manager
[0.107]Release 2024.1 Feb 16 2025 - 05:48:17
[0.152]Platform Version: v2.0 PMC: v2.0, PS: v2.0
[0.205]BOOTMODE: 0x5, MULTIBOOT: 0xF0000000
[0.249]****************************************
[0.505]Non Secure Boot
[4.254]PLM Initialization Time
[4.290]***********Boot PDI Load: Started***********
[4.340]Loading PDI from SD1
[4.374]Monolithic/Master Device
[281.179]276.828 ms: PDI initialization time
[281.230]+++Loading Image#: 0x1, Name: lpd, Id: 0x04210002
[281.293]---Loading Partition#: 0x1, Id: 0xC
[338.051] 56.698 ms for Partition#: 0x1, Size: 9040 Bytes
[342.850]---Loading Partition#: 0x2, Id: 0xB
[382.846] 36.183 ms for Partition#: 0x2, Size: 63984 Bytes
[385.323]+++Loading Image#: 0x2, Name: pl_cfi, Id: 0x18700000
[390.292]---Loading Partition#: 0x3, Id: 0x3
[626.846] 232.739 ms for Partition#: 0x3, Size: 385424 Bytes
[629.251]---Loading Partition#: 0x4, Id: 0x5
[913.037] 279.974 ms for Partition#: 0x4, Size: 440544 Bytes
[915.457]+++Loading Image#: 0x3, Name: aie2_subsys, Id: 0x0421C028
[921.067]---Loading Partition#: 0x5, Id: 0x7
[926.174] 1.295 ms for Partition#: 0x5, Size: 1616 Bytes
[929.685]+++Loading Image#: 0x4, Name: fpd, Id: 0x0420C003
[934.633]---Loading Partition#: 0x6, Id: 0x8
[941.664] 3.220 ms for Partition#: 0x6, Size: 4320 Bytes
[944.092]+++Loading Image#: 0x5, Name: aie_image, Id: 0x1C000000
[949.198]---Loading Partition#: 0x7, Id: 0x0
[964.701] 11.689 ms for Partition#: 0x7, Size: 18528 Bytes
[966.956]+++Loading Image#: 0x6, Name: default_subsys, Id: 0x1C000000
[972.813]---Loading Partition#: 0x8, Id: 0x0
[2070.038] 1093.410 ms for Partition#: 0x8, Size: 1944128 Bytes
[2072.756]***********Boot PDI LoaI: Dializing AIE driver...
I]i47.253 mg:ADF API...
2079.728]TNFO: Resource group Avail is created.
XAIEFAL: INFO: Resource group Static is created.
XAIEFAL: INFO: Resource group Generic is created.
Starting AI Engine A to Z Application
------------------------------------
Beginning test
-
Initializing input data in memory
Done
-
Initializing output memory space
Done
-
System Configuration
Configuring MM2S IP
Done
-
Configuring S2MM IP
Done
-
Done
-
Starting AIE Graph
Graph Initialization
Initializing graph mygraph...
Done
-
Running Graph for 4 iterations
Set 4 iterations for the core(s) of graph mygraph
Enabling core(s) of graph mygraph
Checking output, check #1
Done
-
Checking Output Data:
Successfully ran AI Engine A to Z Application with no error
4. Vitis2024.2 AIE Reports
4.1 组件设置
4.1.1 打开方式
1)通过JSON 文件,可以直接打开。
2)在 Flow 视图中,选择对应的 Component,然后单击旁边的 Settings 按钮。

4.1.2 设置内容
- Platform Information
- Top-level File
- Config File
- Run & Debug Settings

4.2 Build Reports
4.2.1 Overview
- Summary
- Graph
- Array
- Log
- Mapping Analysis
- DMA Analysis
- Lock Allocation
- Kernel Guidance
- AI Engine Compilation

4.2.2 Summary
Summary 视图显示编译运行时间、使用的编译器版本、目标平台、创建的内核以及用于编译的确切命令行。
1)AI Engine Build Summary
2)AI Engine Resource Utilization
Tiles used for Kernels/Buffers/Nets: 2 of 34 (5.88 %)
Tiles used for AI Engine Kernels: 1 of 34 (2.94 %)
Tiles used for Buffers: 2 of 34 (5.88 %)
Memory Tiles used for Shared Buffers: 0 of 17 (0.00 %)
Tiles used for Stream Interconnect: 4 of 52 (7.69 %)
Interface Channels used for ADF Input/Output: 2 ( PLIO: 2 )
Interface Channels used for Trace data: 0
3)Command Line
4.2.3 Graph
提供了 Graph 的概览以及 Graph 的逻辑设计方式。
可以查看整个 ADF Graph 的所有 PLIO 端口、内核、缓冲区和网络连接。

4.2.4 Array
提供了 AI Engine 的逻辑设备视图,内核的布局,以及它们如何相互连接以及与 shim 的连接方式。

包含 34 个 AIE-ML,17 个 Memory Tile。
表格底部显示以下内容:
- Kernel - 图中的内核。
- PL - 显示图与 PLIO 之间的连接。
- Buffer - 显示用于图输入/输出的所有缓冲区以及内核的缓冲区。
- Port - 显示每个内核和 ADF Graph 的端口。
- Net - 显示所有网络,包括命名和生成的,在 ADF 图中映射的网络。
- Tile - 显示映射 Tile 的数据(内核、缓冲区)及其网格位置。
4.2.5 Mapping Analysis
提供了由 aiecompiler 生成的详细映射信息,用于将 Graph 映射到 AI 引擎。
Mapping Analysis Report
Acronym List
* CR(x,y) - Core <column, row>
* MG(x,y):b - MemoryGroup <column, row> : Bank
* MT(x,y):b - MemoryTile <column, row> : Bank
===============================================
Block Mapping Report:
===============================================
Block:Function Name CR(x,y)/IO(x) Schedule Utilization Variable Name Graph Name
------------------- ------------- -------- ----------- ------------- ----------
i0:PLIO IO(8) in mygraph
i1:PLIO IO(8) out mygraph
i2:simple CR(8,0) 0 0.100 first mygraph
i3:simple CR(8,0) 1 0.100 second mygraph
===============================================
Port Mapping Report:
===============================================
PortName Dir PrtType BufType Buffer Name MG(x,y):b Addr Size Variable Name Graph Name
-------- --- ------- ------- ----------- --------- ------- ---- ------------- ----------
i0_po0 out stream mem buf0 MG(8,1):3 0x0c000 128 in.out[0] mygraph
i0_po0 out stream mem buf0d MG(8,1):0 0x00000 128 in.out[0] mygraph
i1_pi0 in stream mem buf2 MG(8,1):3 0x0ff80 128 out.in[0] mygraph
i1_pi0 in stream mem buf2d MG(8,1):0 0x00080 128 out.in[0] mygraph
i2_pi0 in buffer mem buf0 MG(8,1):3 0x0c000 128 first.in[0] mygraph
i2_pi0 in buffer mem buf0d MG(8,1):0 0x00000 128 first.in[0] mygraph
i2_po0 out buffer mem buf1 MG(7,0):1 0x04000 128 first.out[0] mygraph
i3_pi0 in buffer mem buf1 MG(7,0):1 0x04000 128 second.in[0] mygraph
i3_po0 out buffer mem buf2 MG(8,1):3 0x0ff80 128 second.out[0] mygraph
i3_po0 out buffer mem buf2d MG(8,1):0 0x00080 128 second.out[0] mygraph
===============================================
Memory Bank Report:
===============================================
MG(x,y):b Buffer Name Addr Size Accessing Block CR(x,y)/IO(x)
--------- ----------- ------- ---- --------------- -------------
MG(7,0):0 sysmem3 0x00000 1156 main CR(8,0)
MG(7,0):1 buf1 0x04000 128 i2:simple CR(8,0)
MG(7,0):1 buf1 0x04000 128 i3:simple CR(8,0)
MG(8,1):0 buf0d 0x00000 128 i2:simple CR(8,0)
MG(8,1):0 buf0d 0x00000 128 i0 IO(8)
MG(8,1):0 buf2d 0x00080 128 i1 IO(8)
MG(8,1):0 buf2d 0x00080 128 i3:simple CR(8,0)
MG(8,1):3 buf0 0x0c000 128 i2:simple CR(8,0)
MG(8,1):3 buf0 0x0c000 128 i0 IO(8)
MG(8,1):3 buf2 0x0ff80 128 i1 IO(8)
MG(8,1):3 buf2 0x0ff80 128 i3:simple CR(8,0)
4.2.6 DMA Analysis
这是一个文本报告,展示了 Graph 中 DMA 访问的总结。
DMA Analysis Report
DMA Report: S2MM
portinst: i2_pi0 idx[0] datatype:buff<cint16> mem in bw_utlization = 1 (variable name: first.in[0])
MG(8,1) : channel=0, startBD=0, lockID=0, name=buf0
MG(8,1) : channel=0, startBD=1, lockID=0, name=buf0d
DMA Report: MM2S
portinst: i3_po0 idx[1] datatype:buff<cint16> mem out bw_utlization = 1 (variable name: second.out[0])
MG(8,1) : channel=0, startBD=2, lockID=2, name=buf2
MG(8,1) : channel=0, startBD=3, lockID=2, name=buf2d
4.2.7 Lock Allocation
显示了每个缓冲区的锁以及它在 ADF Graph 中的映射位置。
Lock Report
portinst: i2_pi0 idx[0] datatype:buff<cint16> mem in bw_utlization = 1 (variable name: first.in[0]):
Lock 0 MG(8,1) bankId 3 offset 0x0 size 128 name buf0
Lock 0 MG(8,1) bankId 0 offset 0x0 size 128 name buf0d
portinst: i3_po0 idx[1] datatype:buff<cint16> mem out bw_utlization = 1 (variable name: second.out[0]):
Lock 2 MG(8,1) bankId 3 offset 0x3f80 size 128 name buf2
Lock 2 MG(8,1) bankId 0 offset 0x80 size 128 name buf2d
4.2.8 Kernel Guidance
提供消息列表(INFO、警告、严重警告)并为内核开发提供优化和最佳实践指导。
默认情况下,INFO 消息被隐藏。

4.2.9 AI Engine Compilation
显示了单个 Tile 编译的单独日志和命令行选项。以下图显示了 Tile [8,0]中的内核示例。

4.3 Run Reports
4.3.1 Overview
- Summary
- Graph
- Array
- Log
- Simulator Output
- Trace
- Performance Metrics
- Profile

4.3.2 Summary
Summary 视图提供了正在运行的 aiesimulator 的概览。如图所示,它提供了状态、使用的版本、时间、使用的平台以及执行时使用的命令行信息。

4.3.3 Graph
和 "4.2.3 Graph" 中的 Graph 一致。
4.3.4 Array
和 "4.2.4 Array" 中的 Graph 一致。
4.3.5 Simulator Output

4.3.6 Trace
1)需要选择在 Run & Debug 设置中,启用 Trace 功能:

2)输出内容如下:

4.3.7 Performance Metrics

4.3.8 Profile
Simulation 过程中收集的详细信息,包括周期数、总执行指令数、程序内存以及内核编程 Tile 中的每个函数的特定信息。
1)需要选择在 Run & Debug 设置中,启用 Profile 功能:

2)输出内容如下:
- Total Function Time
- Total Function + Descendants Time
- Number of Calls
- Min/Avg/Max Function Time
- Min/Avg/Max Function + Descendants Time
- Profile Details

5. 总结
Xilinx 软件更新较快,在不同版本上 GUI 都是有差异的,可能出现莫名的警告或者错误提示。
创建 ps_app 时候有异常现象(include结构下空白),可以先通过示例工程创建 hello_world 进行测试,然后创建空白app组件。
Binary Container,就是一个二进制容器,负责把不同的组件进行打包。
更多推荐





所有评论(0)