PYNQ-Z2 Dev Board: Python Productivity for Zynq® - Review

Table of contents

RoadTest: PYNQ-Z2 Dev Board: Python Productivity for Zynq®

Author: Attila Tőkés

Creation date:

Evaluation Type: Development Boards & Tools

Did you receive all parts the manufacturer stated would be included in the package?: True

What other parts do you consider comparable to this product?: the Avnet Ultra96 board

What were the biggest problems encountered?: Figuring out the Ethernet based networking setup; WiFi please in the next version.

Detailed Review:

 

Introduction

 

Within the Element14 Road Test program, I got the TUL PYNQ-Z2 board for a review.

image

 

FPGA developent is not exactly easy, and also tends too be a little bit time (and nerve) consuming (Vivado builds can easily take 1+ hour).

 

Because of this engineers with mainly software background were usually reluctant to get into hardware accelerated / FPGA development.

 

Xilinx want's to solve this problem with PYNQ framework, which is supposed to ease the development for programmable logic enabled Zynq SoC-s.

 

The PYNQ Framework achieves this by proving pre-built hardware overlays and software libraries, which allows accelerating different tasks using the programmable logic from the Zynq SoC-s

 

The PYNQ-Z2 from TUL is one of the official demo boards for the PYNQ framework.

 

Note: Although, I have a little bit of experience with FPGA development, especially with Computer Vision applications (see my Stereo Vision and LiDAR Powered Donkey Car project), I thought to not to dig too deep into what this board capable of. The PYNQ-Z2 is a demo board for the PYNQ framework, which supposed to be used for rapid prototyping. For this reason, I decided to focus on what we can achieve with the built-in overlays and libraries, and respectively with pre-built readily available overlays available from the Internet. So, no Vivado builds, SDSoC and things like that.

 

Unboxing and First Impressions


The Road Test kit was a TUL PYNQ-Z2 Basic kit.

 

The content of the kit was as follows:

  • PYNQ-Z2 development board
  • MicroSD card (16GB) with pre-loaded image
  • AC / DC Power adapter (12V / 2.5A)
  • USB Type-A to MicroUSB cable
  • Ethernet cable

 

{gallery} Kit contents

image

PYNQ Z2: Box

image

PYNQ Z2: Box content

image

PYNQ Z2: Board, top side

image

PYNQ Z2: Board, bottom side

image

PYNQ Z2: Accessories, AC / DC Power adapter (12V / 2.5A)

 

image

PYNQ Z2: Accessories, USB-MicroUSB cable

image

PYNQ Z2: Accessories, Ethernet Cable

 

image

PYNQ Z2: Accessories, SD Card with pre-loaded image



The Pynq-Z2 board comes with a nicely built pink PCB. The accessories are also good quality ones.

 

Specs & Price & Comparison with the Ultra96

 

The heart of the PYNQ-Z2 board is a Xilinx Zynq7020 SoC with the following specs:

  • 2 x Cortex-A9 cores running @ 650Mhz
  • programmable logic (Artix-7 FPGA equivalent) with:
    • 13.3K logic slices, each with four 6-input LUT-s and 8 flip-flops
    • 630 KB of fast block RAM
    • 4 clock management tiles
    • 220 DSP slices
    • analog-to-digital converter
  • 1 Gbps Ethernet, USB 2.0, SDIO
  • SPI, UART, CAN, I2C

 

Along this, the PYNQ-Z2 has the following components / features:

  • Memory
    • 512MB DDR3 RAM
    • 16MB Quad_SPI Flash
    • microSD slot

  • Power
    • from microUSB or 7-15V external power source

 

  • Connectivity & Pheriperals
    • 1 Gbps Ethernet
    • USB 2.0
    • HDMI input and output
    • HP+Mic and Line-in
    • 4 push buttons, 2 slide switches, 4 LED-s, 2 RGB LED-s
    • Arduino Shield connector
    • Raspberry Pi connector

 

The board comes at a price of 104 EUR, without accessories.

 

Comparison with the Ultra96

An another popular board supporting Pynq is the Avnet Ultra 96 (V2).

 

Priced much higher, at ~221 EUR, it comes with a more powerful hardware:

  • Xilinx Zynq UltraScale+ MPSoC ZU3EG
    • 154K logic cells, 7.6 MB block RAM, 360 logic cells
  • 4 x Cortex A53 @ 1.5 GHZ + 2 x Cortex R5 real-time cores
  • Linaro 96Boards Consumer Edition (CE) compliance
  • connectivity
    • Wifi 802.11b/g/n + Bluetooth 4.2
    • Mini DisplayPort, USB 3.0
    • 40-pin 96Boards Low-speed expansion header

    • 60-pin 96Boards High speed expansion header

 

At the connectivity side, the Ultra96 uses the 96Boards connectors with 1.8V I/O.

 

This means that working with 3.3V peripherals designed for Arduino / Raspberry Pi requires an mezzanine (extension board). On the other hand the PYNQ-Z2 supports these out of the box.

 

Getting Started

 

Hardware

 

The hardware setup is relatively simple.

 

For the first examples, we need to connect the board to network and power it through USB.

image

 

 

For the some examples the following additional hardware devices may be required:

  • HDMI Monitor
  • Webcam (Logitech C920)
  • HDMI Input source (ex. laptop)
  • Headphone with microphones
  • some PMODs / RPI accessories (I did had used this ones)

 

After the microSD card is inserted, we can power on the board with the switch alongside the power connector.

 

After about ~1 minute, the two RGB LED-s should blink blue a couple of times, indicating the the board booted successfully.

 

If DHCP is available, the PYNQ Z2 should automatically connect to the network.

 

Software

 

A Jupyter notebook server should be accessible from a Web browser on http://pynq:9090/ or http://ip-address:9090/.

 

Note: PYNQ uses Jupyter notebooks for its documentation and examples. These are interactive pages / documents that allows, along other features, running code, plotting graphs, showing images directly in-lined in the page.

 

Note2: I decided to follow the instruction from the documentation, then take a look on the rest. Each page can be covered in ~1-5 minutes. I generally did no modified the code snippets from the pages.

 

The home page looks like this:

image

The Welcome to PYNQ page is the start page for the documentation.

image

Lets start with the getting_started and common folders indicated by this page

 

Getting Started

 

The getting_started folder looks like bellow:

image

 

It contains the following pages:

  1. Jupyter Notebooks
    • this page contains a general description about the Jupyter notebooks and Pynq.

  2. Python Environment
    • python basics, programmable logic basics (memory + aync)

  3. Jupyter Notebooks Advanced Features
    • info about interactive content, plots, shell commands

  4. Base Overlay IOP
    • this an example demonstrating the use of PmodDA4 DAC and the PmodAD2 ADC-s. Unfortunately, I didn't had these so I skipped it.

  5. New Style HDMI input and Pixel Formatting
    • an introduction to the creation of image pipelines
    • for this example the HDMI Input and HDMI Output must be connected
    • the first example shows how we can tie (mirror) the HDMI input to the HDMI output
    • then there are some image processing examples using a Laplace Filter
      image
  6. Welcome to PYNQ Audio
    • a page contains audio processing examples

    • by default, the example uses the Line input, but I used to the HP+MIC with a headphone having a michrophon
      • for this to work the line pAudio.select_microphone() should be changed to pAudio.select_microphone()

    • the following real-time audio processing are demonstrated
      Bypass Audio
      Record Audio
      Playback Audio

    • audio analysis
      Amplitude over time
      Spectogram

 

Common

 

The common folder contains an another set of examples:

image

 

  1. Downloading Overlays
    (overlay_download)
    • example demonstrating how to work with bitstreams
    • download bitstream
    • examine PL: current bitfile_name, timestamp
    • download overhead (~ 200 - 400 ms)

  2. Python Random
    (python_random)
    • different pseudo-ramdom number generators (no HW)

  3. Retrieving shell command output in IPython
    (python_retrieving_shell)
    • example demonstrating how to work with Shell commands

  4. USB Webcam
    (usb_webcam)
    • this page shows us how to work with a USB Webcam using the Python Image Library
    • take an image using a webcam (Logitech C270)
    • convert it to grayscale
    • rotate 45°

  5. Wifi
    (wifi)
    • demonstrates how to connect to a Wifi network
    • I used a Ralink Technology, Corp. MT7601U
      • with this I successfully connects to a Wifi network, but the ping does not works (it may be some driver or configuration problem)

  6. Zynq Clocks
    (zynq_clocks)
    • this example demonstrates how to control the four clocks from the programmable logic
    • retrieve current clock rates
    • set clock rates
    • reset clock rate (by reload the overlay)

 

Base

 

After the common and getting_started folders, I also took a look on the base folder:

image

It contains a set of sub-folders each covering a different set of features:

 

  1. Arduino:
    • analog
    • digital I/O + groove LedBar
    • LCD

  2. Audio
    • this is basically the same notebook as the Getting started guide

  3. Board
    • aync I/O demonstration using the ayncio library
    • buttons an LED demo application

  4. MicroBlaze
    • low level programming of the Microblaze processor used by the base.bit

  5. PMOD
    • examples for different PMOD-s: ADC, Ambient Light Sensor, DAC, Grove Sensors, OLED, PWM, Thermocouple (TC1), Timer, Temperature (TMP2)

  6. Rpi
    • examples demonstrating how to work with Raspberry PI peripherals. The example Touch KeyPad

  7. Trace Analyzer I2C
    • example showing how to use the built-in Trace Analyzer from the Base Overlay

  8. Video
    • Video Pipeline
      • the is a page describing the HDMI video pipelines from the Base overlay
      • there are two HDMI Video pipelines for the Input and Output side, each of which consists in:
        • a HDMI frontend
        • color space converter
        • pixel format converter
        • video DMA
      • using these some basic real-time video manipulation task can be achieved
        • there is an example application showing how to tie the HDMI In an Out, while retaining just a single color (RED) channel from the image:
          image
    • OpenCV:
      Face Detection HDMI / WebCam
      Filter HDMI / WebCam
      • here is an image with the PYNQ-Z2 taken with the C920 webcam and a Canny edge detection applied on it




        image

Computer Vision and Machine Learning Overlays

 

Along the build-in overlays, there are some other overlays that can be downloaded and used with the PynqZ2.

 

Computer Vision


The PYNQ-ComputerVision package from Xilinx, offers overlays for hardware accelerating computer vision applications.

 

These overlays are based on the Xilinx's xfOpenCV library, and they allow accelerating OpenCV components in the Programmable logic.

 

The package comes with pre-built overlays for the PYNQ-Z2. These contains along the HDMI In an Out blocks, cvBlock-s to accelerate different OpenCV functions.

image

 

To install PYNQ-ComputerVision we need to SSH into the Pynq-Z2 and run the following command:

$ sudo pip3 install --upgrade git+https://github.com/Xilinx/PYNQ-ComputerVision.git

 

After this a new pynqOpenCV folder should appear in the Jupyter home page:

image

with the following content:

image

 

Filter 2D

This page demonstrates the use of 2D Filters in OpenCV

 

2D Filters are general purpose building blocks in computer vision, the can be used to implement functionality like:

  • edge detection (Laplacian and Gausian high-pass filters, Sobel filter)
  • blurring (Laplacian and Gausian filters)
  • etc.

 

The page contains the following steps:

  1. Sets up HDMI drivers
  2. Run software-only filter2D on HDMI input and output results to HDMI output
  3. Sets up widget for controlling different the filter kernel
  4. Run hardware accelerated filter2D function

 

Filter 2D + Dilate

 

This page along with the 2D Filters also show the use of Dilate operations.

 

A Dilate operation can be used for:

  • filtering noise
  • isolating or joining elements from an image
  • etc.

 

The functionality from this page is:

  1. Sets up HDMI drivers
  2. Run software only filter2D + dilate pipeline on HDMI input and output results to HDMI output
  3. Run hardware accelerated dilate function
  4. Sets up widget for controlling different filter kernels
  5. Run hardware accelerated filter2D + dilate function

 

Here is a video showing a hardware accelerated 2D filter + dilate applied to the HDMI stream in real-time:

 

Filter 2D + Remap

 

This page along with the 2D Filters also show the use of Remap functionality from OpenCV.

 

The steps from this page are:

  1. Sets up HDMI drivers
  2. Run software only remap on HDMI input and output results on HDMI output
  3. Sets up widget for controlling the position, size, and zoom of the "magnifying glass"
  4. Run hardware accelerated remap function
  5. Run hardware accelerated filter2D + remap function

 

The performance of the software only and hardware accelerated implementations were as follow:

  • software only - ~ 2-10 frames / sec
  • hardware accelerated - ~ 50-60 frames / sec

 

Binary / Quantized Neural Networks

Binary (or Quantized) Neural Networks are Deep Neural Networks, that instead of traditional real-number weights uses binary (or quantized) weights

 

Although, using binary weights may reduce the accuracy of a neural network, it should also makes them more suitable to be implemented on a FPGA-s.

 

FINN, an experimental framework from Xilinx Research Labs, allows implementing binary neural networks on FPGA-s.

 

The framework is also provided as a Pynq overlay: BNN-PYNQ

 

Unfortunately, I didn't had the time yet to try it out, but and did a very good job explaining in their Road Tests:

PYNQ-Z2 Dev Board: Python Productivity for Zynq® - Review

PYNQ-Z2 Dev Board: Python Productivity for Zynq® - Review -

 

As they results show, these networks can have a remarkable performance given that they are run on an embedded system.

 

Conclusion

 

In my opinion, the PYNQ-Z2 is a really fun to use board. It allows building some interesting hardware accelerated applications pretty easy.

 

The documentation, at least the Getting Started part, looks well build and easy to follow. The Common and Base pages could be a little bit better organized.

 

The the hardware side, the Zynq7020 SoC is relatively powerful. It is powerful enough to run basic real-time video processing applications in the PL, but an entry level Zynq UltraScale+ may be better.

 

A built-in WiFi module (costs ~ $3) could be useful. I imagine some people having trouble doing the wired setup, if their router is not located near the desk.

 

I see the PYNQ-Z2 most suitable for real-time video processing (HDMI to HDMI, or USB to HDMI), maybe combined with some artificial intelligence (BNN-s).

 

Cheers,

Attila

Anonymous