基于PYNQ-Z2重建BNN工程
基于PYNQ重建BNN工程
环境:ubuntu18.04 vivado2018.3
参考步骤(源自Github的Readme)
Hardware design rebuilt
In order to rebuild the hardware designs, the repo should be cloned in a machine with installation of the Vivado Design Suite (tested with 2018.2).
Following the step-by-step instructions:
- Clone the repository on your linux machine:
git clone https://github.com/Xilinx/BNN-PYNQ.git --recursive
; - Move to
<clone_path>/BNN_PYNQ/bnn/src/network/
- Set the XILINX_BNN_ROOT environment variable to
<clone_path>/BNN_PYNQ/bnn/src/
- Launch the shell script make-hw.sh with passing parameters for target network, target platform and mode, with the command
./make-hw.sh {network} {platform} {mode}
where:- network can be cnvW1A1, cnvW1A2, cnvW2A2 or lfcW1A1, lfcW1A2;
- platform can be pynqZ1-Z2 or ultra96;
- mode can be
h
to launch Vivado HLS synthesis,b
to launch the Vivado project (needs HLS synthesis results),a
to launch both;
- The results will be visible in
clone_path/BNN_PYNQ/bnn/src/network/output/
that is organized as follows:- bitstream: contains the generated bitstream(s);
- hls-syn: contains the Vivado HLS generated RTL and IP (in the subfolder named as the target network and target platform);
- report: contains the Vivado and Vivado HLS reports;
- vivado: contains the Vivado project;
- Copy the generated bitstream, hwh and tcl script on the PYNQ board
pip_installation_path/bnn/bitstreams/
重建过程
1.下载Github上的BNN项目压缩包到自己制定的目录下。(或者在Ubuntu上直接git clone,但Ubuntu无*,经常下到一半断了,所以建议在Windows上下好压缩包拷贝过去)
2.解压压缩包至bnn文件夹下。
unzip -d /home/yourname/bnn BNN_PYNQ.zip
3.切换路径到BNN-PYNQ-master中的network文件夹下
cd /home/yourname/bnn/BNN-PYNQ-master/bnn/src/network/
4.设置临时的环境变量
PATH=$PATH:/opt/Xilinx/Vivado/2018.2/bin XILINX_BNN_ROOT=$XILINX_BNN_ROOT:/home/yourname/bnn/BNN-PYNQ-master/bnn/src/
5.执行shell脚本,生成hls IP。
./make-hw.sh cnvW1A1 pynqZ1-Z2 h
问题:
-
make-hw.sh脚本中仍去git了两个包,ubuntu无*也很容易失败,建议在windows上下好两个包放在指定路径即可。将xilinx-tiny-cnn放在
BNN-PYNQ-master/bnn/src
文件夹下,将finn-hlslib放在BNN-PYNQ-master/bnn/src/library
文件夹下。windows仍下不了的话我把两个包的下载链接放于文章末尾。 -
执行脚本时可以搭建工程,但csim报compiler error:*ERROR: [SIM 211-100] ‘csim_design’ failed: compilation error(s).*打开搭建好的工程发现testbench中部分库文件找不到,报红,但源文件没问题,所以在hls-syn.tcl文件中直接删除csim这一行,直接跑综合,可以解决问题。
6.执行shell脚本,生成vivado工程
./make-hw.sh cnvW1A1 pynqZ1-Z2 b
问题:
将下图路径中所有的TCL文件中的vivado版本号修改,理论上应高于2018.2。
7.重建完成
注意事项:
1.不要在Windows下重建工程。
2.打开新终端时需重新执行步骤4,设置临时变量。
3.重建vivado工程时,由于ps7为只读,部分参数设置不了,导致bit流最终仍存在一定问题,若想烧写出正确的bit流请自行对照tcl文件修改ps7核的参数。
重建项目下载链接
finn-hlslib
xilinx-tiny-cnn
cnvW1A1_output
cnvW1A2_output
cnvW2A2_output
lfcW1A1_output
lfcW1A2_output
本文地址:https://blog.csdn.net/qq_42334072/article/details/107966278
上一篇: JSON学习系列之一:结构介绍
下一篇: 嵌入式Linux学习记录之串口