pynq.overlay Module¶
The pynq.overlay module inherits from the PL module and is used to manage the state and contents of a PYNQ Overlay. The module adds additional functionality to the PL module. For example, the PL module contains the methods to download the overlay file. The Overlay module sets the PL clocks and ARM architecture registers before before calling the Bitstream download() method.
-
class
pynq.overlay.
DefaultHierarchy
(description)[source]¶ Bases:
pynq.overlay._IPMap
Hierarchy exposing all IP and hierarchies as attributes
This Hierarchy is instantiated if no more specific hierarchy class registered with register_hierarchy_driver is specified. More specific drivers should inherit from DefaultHierarachy and call it’s constructor in __init__ prior to any other initialisation. checkhierarchy should also be redefined to return True if the driver matches a hierarchy. Any derived class that meets these requirements will automatically be registered in the driver database.
-
static
checkhierarchy
(description)[source]¶ Function to check if the driver matches a particular hierarchy
This function should be redefined in derived classes to return True if the description matches what is expected by the driver. The default implementation always returns False so that drivers that forget don’t get loaded for hierarchies they don’t expect.
-
static
-
class
pynq.overlay.
DefaultIP
(description)[source]¶ Bases:
object
Driver for an IP without a more specific driver
This driver wraps an MMIO device and provides a base class for more specific drivers written later. It also provides access to GPIO outputs and interrupts inputs via attributes. More specific drivers should inherit from DefaultIP and include a bindto entry containing all of the IP that the driver should bind to. Subclasses meeting these requirements will automatically be registered.
-
mmio
¶ pynq.MMIO – Underlying MMIO driver for the device
-
_interrupts
¶ dict – Subset of the PL.interrupt_pins related to this IP
-
_gpio
¶ dict – Subset of the PL.gpio_dict related to this IP
-
-
pynq.overlay.
DocumentHierarchy
(description)[source]¶ Helper function to build a custom hierarchy class with a docstring based on the description. Mimics a class constructor
-
pynq.overlay.
DocumentOverlay
(bitfile, download)[source]¶ Function to build a custom overlay class with a custom docstring based on the supplied bitstream. Mimics a class constructor.
-
class
pynq.overlay.
Overlay
(bitfile_name, download=True, ignore_version=False)[source]¶ Bases:
pynq.pl.Bitstream
This class keeps track of a single bitstream’s state and contents.
The overlay class holds the state of the bitstream and enables run-time protection of bindlings.
Our definition of overlay is: “post-bitstream configurable design”. Hence, this class must expose configurability through content discovery and runtime protection.
The overlay class exposes the IP and hierarchies as attributes in the overlay. If no other drivers are available the DefaultIP is constructed for IP cores at top level and DefaultHierarchy for any hierarchies that contain addressable IP. Custom drivers can be bound to IP and hierarchies by subclassing DefaultIP and DefaultHierarchy. See the help entries for those class for more details.
This class stores four dictionaries: IP, GPIO, interrupt controller and interrupt pin dictionaries.
Each entry of the IP dictionary is a mapping: ‘name’ -> {phys_addr, addr_range, type, config, state}, where name (str) is the key of the entry. phys_addr (int) is the physical address of the IP. addr_range (int) is the address range of the IP. type (str) is the type of the IP. config (dict) is a dictionary of the configuration parameters. state (str) is the state information about the IP.
Each entry of the GPIO dictionary is a mapping: ‘name’ -> {pin, state}, where name (str) is the key of the entry. pin (int) is the user index of the GPIO, starting from 0. state (str) is the state information about the GPIO.
Each entry in the interrupt controller dictionary is a mapping: ‘name’ -> {parent, index}, where name (str) is the name of the interrupt controller. parent (str) is the name of the parent controller or ‘’ if attached directly to the PS7. index (int) is the index of the interrupt attached to.
Each entry in the interrupt pin dictionary is a mapping: ‘name’ -> {controller, index}, where name (str) is the name of the pin. controller (str) is the name of the interrupt controller. index (int) is the line index.
-
bitfile_name
¶ str – The absolute path of the bitstream.
-
bitstream
¶ Bitstream – The corresponding bitstream object.
-
ip_dict
¶ dict – All the addressable IPs from PS7. Key is the name of the IP; value is a dictionary mapping the physical address, address range, IP type, configuration dictionary, and the state associated with that IP: {str: {‘phys_addr’ : int, ‘addr_range’ : int, ‘type’ : str, ‘config’ : dict, ‘state’ : str}}.
-
gpio_dict
¶ dict – All the GPIO pins controlled by PS7. Key is the name of the GPIO pin; value is a dictionary mapping user index (starting from 0), and the state associated with that GPIO pin: {str: {‘index’ : int, ‘state’ : str}}.
-
interrupt_controllers
¶ dict – All AXI interrupt controllers in the system attached to a PS7 interrupt line. Key is the name of the controller; value is a dictionary mapping parent interrupt controller and the line index of this interrupt: {str: {‘parent’: str, ‘index’ : int}}. The PS7 is the root of the hierarchy and is unnamed.
-
interrupt_pins
¶ dict – All pins in the design attached to an interrupt controller. Key is the name of the pin; value is a dictionary mapping the interrupt controller and the line index used: {str: {‘controller’ : str, ‘index’ : int}}.
-
download
()[source]¶ The method to download a bitstream onto PL.
Note
After the bitstream has been downloaded, the “timestamp” in PL will be updated. In addition, all the dictionaries on PL will be reset automatically.
Returns: Return type: None
-
is_loaded
()[source]¶ This method checks whether a bitstream is loaded.
This method returns true if the loaded PL bitstream is same as this Overlay’s member bitstream.
Returns: True if bitstream is loaded. Return type: bool
-
load_ip_data
(ip_name, data)[source]¶ This method loads the data to the addressable IP.
Calls the method in the super class to load the data. This method can be used to program the IP. For example, users can use this method to load the program to the Microblaze processors on PL.
Note
The data is assumed to be in binary format (.bin). The data name will be stored as a state information in the IP dictionary.
Parameters: - ip_name (str) – The name of the addressable IP.
- data (str) – The absolute path of the data to be loaded.
Returns: Return type: None
-