基于PYNQ重建BNN工程

Github链接

环境: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:

  1. Clone the repository on your linux machine:
    git clone https://github.com/Xilinx/BNN-PYNQ.git --recursive;
  2. Move to <clone_path>/BNN_PYNQ/bnn/src/network/
  3. Set the XILINX_BNN_ROOT environment variable to <clone_path>/BNN_PYNQ/bnn/src/
  4. 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;
  5. 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;
  6. 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上下好压缩包拷贝过去)

压缩包下载.png

2.解压压缩包至bnn文件夹下。

unzip -d /home/yourname/bnn BNN_PYNQ.zip

解压压缩包到子文件夹bnn中.png

3.切换路径到BNN-PYNQ-master中的network文件夹下

cd /home/yourname/bnn/BNN-PYNQ-master/bnn/src/network/

切换路径.png

4.设置临时的环境变量

PATH=$PATH:/opt/Xilinx/Vivado/2018.2/bin XILINX_BNN_ROOT=$XILINX_BNN_ROOT:/home/yourname/bnn/BNN-PYNQ-master/bnn/src/

设置临时环境变量.png

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仍下不了的话我把两个包的下载链接放于文章末尾。

    git失败导致重建失败.png

  • 执行脚本时可以搭建工程,但csim报compiler error:*ERROR: [SIM 211-100] ‘csim_design’ failed: compilation error(s).*打开搭建好的工程发现testbench中部分库文件找不到,报红,但源文件没问题,所以在hls-syn.tcl文件中直接删除csim这一行,直接跑综合,可以解决问题

    删tcl.png

6.执行shell脚本,生成vivado工程

./make-hw.sh cnvW1A1 pynqZ1-Z2 b

问题:

将下图路径中所有的TCL文件中的vivado版本号修改,理论上应高于2018.2。

路径.png

vivado版本.png

7.重建完成

重建成功.png

注意事项:

1.不要在Windows下重建工程。

2.打开新终端时需重新执行步骤4,设置临时变量。

3.重建vivado工程时,由于ps7为只读,部分参数设置不了,导致bit流最终仍存在一定问题,若想烧写出正确的bit流请自行对照tcl文件修改ps7核的参数。

只读.png

重建项目下载链接

finn-hlslib
xilinx-tiny-cnn
cnvW1A1_output
cnvW1A2_output
cnvW2A2_output
lfcW1A1_output
lfcW1A2_output

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐