在介绍具体例程之前,先介绍几个基本概念:
AXI4-Stream interface: Specify on input arguments or output arguments only, not on input/output arguments.
AXI4-Lite interface: Specify on any type of argument except streams.
AXI4 master interface: Specify on arrays and pointers (and references in C++) only.
SDSVHLS macro:
guard code in a function definition that differs depending on whether it is used by Vivado HLS to generate hardware or used in a software implementation.
C++0x:
C++11之前被称为C++0x,因为原本计划在2010年发布,所以之前一些编译器使用C++11的编译参数是:-std=c++0x,后面使用:-std=c++11。
下载例程源程序:
Vitis_Libraries/vision/L1 at master · Xilinx/Vitis_Libraries https://github.com/Xilinx/Vitis_Libraries/tree/master/vision/L1
Prerequisites
将下面的文件拷入Ubuntu系统
Vitis_Libraries/vision at master · Xilinx/Vitis_Libraries https://github.com/Xilinx/Vitis_Libraries/tree/master/vision
GUI Mode
Use the following steps to operate the HLS Standalone Mode using GUI:
Ubuntu命令行输入下面的命令,启动HLS:
vivado_hls
输入项目名称和选定例程中的L1中的dilation目录
在CFLAGS中指定include目录和参数
确定仿真参数
开始逻辑仿真Simulation
勾选Clean Build
出现错误:
官方指导文件坑一:找不到头文件xf_dilation_config.h,找到该文件所在目录:
在加上xf_dilation_config.h所在目录:
-I/home/john/Vitis/vision/L1/include -I/home/john/Vitis/vision/L1/examples/dilation/build -D__SDSVHL__ -std=c++0x
再次仿真,新错误出现:
libopencv_highgui.so: undefined reference to
INFO: [SIM 2] *************** CSIM start ***************
INFO: [SIM 4] CSIM will launch GCC as the compiler.
Compiling …/…/…/…/xf_dilation_tb.cpp in debug mode
Compiling …/…/…/…/xf_dilation_accel.cpp in debug mode
Generating csim.exe
Makefile.rules:401: recipe for target ‘csim.exe’ failed
/home/john/Vitis/Vivado/2019.2/tps/lnx64/binutils-2.26/bin/ld: warning: libjpeg.so.62, needed by /home/john/Vitis/Vivado/2019.2/lnx64/tools/opencv/opencv_gcc/libopencv_highgui.so, not found (try using -rpath or -rpath-link)
/home/john/Vitis/Vivado/2019.2/tps/lnx64/binutils-2.26/bin/ld: warning: libpng12.so.0, needed by /home/john/Vitis/Vivado/2019.2/lnx64/tools/opencv/opencv_gcc/libopencv_highgui.so, not found (try using -rpath or -rpath-link)
官方指导文件坑二:缺少依赖库libjpeg62
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200311171747737.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTA4Nzk3NDU=,size_16,color_FFFFFF,t_70sudo apt-get install libjpeg62
再次运行仿真:
Makefile.rules:401: recipe for target ‘csim.exe’ failed
/home/john/Vitis/Vivado/2019.2/tps/lnx64/binutils-2.26/bin/ld: warning: libpng12.so.0, needed by /home/john/Vitis/Vivado/2019.2/lnx64/tools/opencv/opencv_gcc/libopencv_highgui.so, not found (try using -rpath or -rpath-link)
/home/john/Vitis/Vivado/2019.2/lnx64/tools/opencv/opencv_gcc/libopencv_highgui.so: undefined reference to `png_read_info@PNG12_0’
官方指导文件坑三:缺少库文件libpng12.so.0
查询相似安装库:
john@john-virtual-machine:~/Vitis/vision/L1/examples/dilation/build$ apt-cache search libpng
libpng-dev - PNG library - development (version 1.6)
libpng-tools - PNG library - tools (version 1.6)
libpng16-16 - PNG library - runtime (version 1.6)
fp-units-gfx - Free Pascal - graphics-library units dependency package
fp-units-gfx-3.0.4 - Free Pascal - graphics-library units
libpng+±dev - C++ interface to the PNG (Portable Network Graphics) library
以上库均安装失败,本机查找文件libpng12.so.0,找到后拷贝到用户库目录:
john@john-virtual-machine:~/vmware-tools-distrib/lib/lib64/libpng12.so.0$ sudo find / -name libjpeg.so.62
/home/john/petalinux2019.2/sysroots/aarch64-xilinx-linux/usr/lib/libjpeg.so.62
/home/john/Vitis/DocNav/lib/libjpeg.so.62
/usr/lib/x86_64-linux-gnu/libjpeg.so.62
john@john-virtual-machine:~/vmware-tools-distrib/lib/lib64/libpng12.so.0$ sudo cp libpng12.so.0 /usr/lib/x86_64-linux-gnu/
再次仿真:
INFO: [SIM 211-2] *************** CSIM start ***************
INFO: [SIM 211-4] CSIM will launch GCC as the compiler.
Compiling …/…/…/…/xf_dilation_tb.cpp in debug mode
Compiling …/…/…/…/xf_dilation_accel.cpp in debug mode
Generating csim.exe
Invalid Number of Arguments!
Usage:
错误是由未设置Arguments所致,加入包括绝对路径的图像文件:
Simulation仿真成功
开始Cosimulation
Cosimulation设置参数:
Cosimulation仿真成功
有告警,未研究
Since the only kind of statements allowed in a canonical dataflow region are variable declarations and function calls, the compiler may not be able to correctly handle the region: /home/john/Vitis/vision/L1/include/common/xf_utility.hpp:301:2
两次处理的图片目录如下:
john@john-virtual-machine:~/Vitis/vision/L1/examples/dilation$ find ./ -name *.jpg
./Dilation/solution1/sim/wrapc/out_ocv.jpg
./Dilation/solution1/sim/wrapc_pc/out_ocv.jpg
./Dilation/solution1/csim/build/out_ocv.jpg