As an introduction to FPGA programming the PYNQ-Z2 provides FPGA overlays. An overlay is a generic FPGA design that provides some specific functionality, in essence a hardware library. An overlay is generally programmed via a software abstraction layer that has a defined API. The PYNQ-Z2 has a base overlay that provides access to its onboard and external peripheral interfaces via Python. The base overlay bitstream is loaded when the PYNQ-Z2 boots up, so its functions are immediately available via Python.
The following diagram shows the structure of the base overlay. The onboard peripherals are controlled by a fixed GPIO controller and the external peripherals are controlled using programmable MicroBlaze IO Processors (IOPs). The base overlay also provides video and audio processing.
The next diagram show the location of the onboard peripherals and the external IO connectors.
Onboard peripherals
- Four green LEDs (LD0-3)
- Two multi-color LEDs (LD4-5)
- Two slide switches (SW0-1)
- Four push-buttons (BTN0-3)
External IO connectors
- Raspberry Pi compatible 40 pin GPIO header
- Arduino Uno compatible GPIO headers
- Two Pmod connectors
The first workshop session demonstrates the use of the base overlay to control the onboard peripherals. The programming is pretty straightforward.
1) import the BaseOverlay, the bitstream file is base.bit
2) import the peripheral classes
3) Instantiate the peripherals
4) control via the peripheral functions (e.g. on/off for LEDs)
Here is a short video showing the onboard peripheral control using the lab Jupyter notebook:
I apologize in advance that the board image is upside down in the video. I need to do some work on my camera mounting and lighting.
I also use the term "function" a lot when I mean code segment. I'll work on these things for the next video.
Top Comments