PYNQ, Python Productivity for Zynq, makes it very easy for designers of embedded system to use XILINX Zynq devices without having to master complex design tools to design programmable logic circuits.

PL as Hardware Libraries

Programmable logic circuits are presented as hardware libraries called overlays similar to software libraries. The developer can access the overlay that best matches their application through an application programming interface (API). Although creating a new overlay requires engineers with expertise in designing programmable logic circuits but once created, like software libraries, they are configurable and can be re-used as often as possible in many different applications.

In a typical FPGA implementation, developers need to manage the sequence and security for loading bitstreams. With the Zynq SoC, an integrated processor performs a conventional microcontroller’s tasks, including managing the PL fabric and other on-chip peripherals. As a result, the FPGA loading process more closely resembles that of a conventional microcontroller’s boot process than a traditional FPGA bitstream initialization.

Even with simplified PL loading processing, developers have in the past been left to deal with the complex FPGA development process needed to generate the required bitstreams. For developers hoping to leverage FPGA performance, the conventional FGPA development process has remained a significant barrier to implementation. Xilinx effectively removed that barrier with its PYNQ environment.

In PYNQ, PL bitstreams are encapsulated in pre-built libraries called overlays, which serve a similar role as software libraries in the development process and execution environment. During the boot load process, bitstreams associated with the required overlays configure the PL fabric. However, this process remains transparent to developers who take advantage of the overlay’s functionality through the Python application programming interface (API) associated with each overlay. During development, engineers can combine software libraries and overlays as needed, working through their respective APIs to implement the application. During execution the processor system executes software library code as usual, while the PL fabric implements the functionality provided in the overlay. The result is the kind of accelerated performance that continues to drive interest in FPGA-based designs for increasingly demanding applications.

Python for Programming

PYNQ uses Python, is a “productivity-level” language, for programming both the embedded processors and the overlays. To date, C or C++ are the most common, embedded programming languages. In contrast, Python raises the level of programming abstraction and programmer productivity. These are not mutually-exclusive choices, however. PYNQ uses CPython which is written in C, and integrates thousands of C libraries and can be extended with optimized code written in C. Wherever practical, the more productive Python environment should be used, and whenever efficiency dictates, lower-level C code can be used.

As the name suggests, PYNQ takes advantage of the development productivity gains associated with the Python programming language. Developers are likely to find software libraries needed for support services or specialized algorithms in repositories of open source Python modules. At the same time, developers can implement critical functions in C language because PYNQ uses the common C language implementation of the Python interpreter. This implementation provides easy access to thousands of existing C libraries and simplifies use of developer provided C language libraries. Although experienced developers can extend PYNQ with specialized hardware overlays and C language software libraries, PYNQ’s strength lies in its ability to provide a high productivity development environment for any developer able to build a Python program.

Web based Development Environment

PYNQ is an open-source project that builds on another open source project, the Jupyter notebook. This goal is achieved by adopting a web-based architecture, which is also browser agnostic. We incorporate the open-source Jupyter notebook infrastructure to run an Interactive Python (IPython) kernel and a web server directly on the ARM processor of the Zynq device. Jupyter notebooks provide an effective environment for interactively exploring algorithms and prototyping complex applications in Python.

Summary

Some of the benefits of using PYNQ are –

  • Exposing PL circuits as Hardware Libraries (API) called Overlays
  • Enabling programming in a high-level productivity language (Python in this case)
  • Providing a web-based development environment served from embedded processors
  • Integrating Jupyter Notebook framework

Case Study: Our experience using HLS for Image Processing Application

In our real-time experience with one of the clients in the high-speed sorting OEM industry, the customer wanted to enhance the image processing algorithms. In order to develop the image processing algorithm, the output of the line scan sensor had to be captured and displayed. We used PYNQ to capture and display the output basis which we developed the image processing algorithms in OpenCV. These algorithms were developed and tested using C++ before using HLS in Vivado toolchain to convert into HDL for porting into the FPGA processor. Click here to read the case study in detail.

#Blog Series – Using FPGA High Speed Image Processing

#Blog Series – Using HLS to implement Image Processing