By default, an overlay (bitstream) called base is downloaded into the PL at boot time. The base overlay can be considered like a reference design for a board. New overlays can be installed or copied to the board and can be loaded into the PL as the system is running.
An overlay usually includes:
The PYNQ Overlay
class can be used to load an overlay. An overlay is instantiated by specifying the name of the bitstream file. Instantiating the Overlay also downloads the bitstream by default and parses the Tcl file.
from pynq import Overlay
overlay = Overlay("base.bit")
For the base overlay, we can use the existing BaseOverlay
class; this class exposes the IPs available
on the bitstream as attributes of this class.
In [1]:
from pynq.overlays.base import BaseOverlay
base_overlay = BaseOverlay("base.bit")
Once an overlay has been instantiated, the help()
method can be used to discover what is in an overlay about. The help information can be used to interact with the overlay. Note that if you try the following code on your own board, you may see different results depending on the version of PYNQ you are using, and which board you have.
In [2]:
help(base_overlay)
This will give a list of the IP and methods available as part of the overlay.
From the help()
print out above, it can be seen that in this case the overlay includes an leds
instance, and from the report this is an AxiGPIO class:
"""
leds : AxiGPIO
4-bit output GPIO for interacting with the green LEDs LD0-3
"""
Running help()
on the leds object will provide more information about the object including details of its API.
In [3]:
help(base_overlay.leds)
The API can be used to control the object. For example, the following cell will turn on LD0 on the board.
In [4]:
base_overlay.leds[0].toggle()
Information about other IP can be found from the overlay instance in a similar way, as shown below.
In [5]:
help(base_overlay.video)