Vitis软件图像处理硬核加速例程和官指三坑

在介绍具体例程之前,先介绍几个基本概念:

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

  1. Valid installation of Vitis™ 2019.2 or later version and the corresponding licenses.
  2. Install the xfOpenCV libraries, if you intend to use libraries compiled differently than what is provided in Vitis.
  3. Install the card for which the platform is supported in Vitis 2019.2 or later versions.
  4. Xilinx® Runtime (XRT) must be installed. XRT provides software interface to Xilinx FPGAs.
  5. libOpenCL.so must be installed if not present along with the platform.

将下面的文件拷入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:

  1. Open Vivado® HLS in GUI mode and create a new project
  2. Specify the name of the project. For example - Dilation.
  3. Click Browse to enter a workspace folder used to store your projects.
  4. Click Next.
  5. Under the source files section, add the accel.cpp file which can be found in the examples folder. Also, fill the top function name (here it is dilation_accel).
  6. Click Next.
  7. Under the test bench section add tb.cpp.
  8. Click Next.
  9. Select the clock period to the required value (10ns in example).
  10. Select the suitable part. For example, xczu9eg-ffvb1156-2-i.
  11. Click Finish.
  12. Right click on the created project and select Project Settings.
  13. In the opened tab, select Simulation.
  14. Files added under the Test Bench section will be displayed. Select a file and click Edit CFLAGS.
  15. Enter -I -D__SDSVHLS__ -std=c++0x.
  16. Select Synthesis and repeat the above step for all the displayed files.
  17. Click OK.
  18. Run the C Simulation, select Clean Build and specify the required input arguments.
  19. Click OK.
  20. All the generated output files/images will be present in the solution1->csim->build.
  21. Run C synthesis.
  22. Run co-simulation by specifying the proper input arguments.
  23. The status of co-simulation can be observed on the console.

Ubuntu命令行输入下面的命令,启动HLS:
vivado_hls
Vitis软件图像处理硬核加速例程和官指三坑_第1张图片
输入项目名称和选定例程中的L1中的dilation目录
Vitis软件图像处理硬核加速例程和官指三坑_第2张图片
Vitis软件图像处理硬核加速例程和官指三坑_第3张图片

打开Project Settings
Vitis软件图像处理硬核加速例程和官指三坑_第4张图片

在CFLAGS中指定include目录和参数

Vitis软件图像处理硬核加速例程和官指三坑_第5张图片

确定仿真参数
Vitis软件图像处理硬核加速例程和官指三坑_第6张图片
Vitis软件图像处理硬核加速例程和官指三坑_第7张图片开始逻辑仿真Simulation
Vitis软件图像处理硬核加速例程和官指三坑_第8张图片Vitis软件图像处理硬核加速例程和官指三坑_第9张图片
勾选Clean Build
Vitis软件图像处理硬核加速例程和官指三坑_第10张图片
出现错误:
Vitis软件图像处理硬核加速例程和官指三坑_第11张图片
官方指导文件坑一:找不到头文件xf_dilation_config.h,找到该文件所在目录: Vitis软件图像处理硬核加速例程和官指三坑_第12张图片
在加上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
Vitis软件图像处理硬核加速例程和官指三坑_第13张图片
再次仿真,新错误出现:
Vitis软件图像处理硬核加速例程和官指三坑_第14张图片
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)
Vitis软件图像处理硬核加速例程和官指三坑_第15张图片
官方指导文件坑二:缺少依赖库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所致,加入包括绝对路径的图像文件:
Vitis软件图像处理硬核加速例程和官指三坑_第16张图片
Simulation仿真成功 Vitis软件图像处理硬核加速例程和官指三坑_第17张图片
开始Cosimulation
Vitis软件图像处理硬核加速例程和官指三坑_第18张图片
Cosimulation设置参数:
Vitis软件图像处理硬核加速例程和官指三坑_第19张图片
Cosimulation仿真成功
Vitis软件图像处理硬核加速例程和官指三坑_第20张图片
有告警,未研究
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

原图像:
Vitis软件图像处理硬核加速例程和官指三坑_第21张图片
处理后图像:
Vitis软件图像处理硬核加速例程和官指三坑_第22张图片

你可能感兴趣的:(FPGA,Linux,嵌入式)