pynq.registers Module

The pynq.registers module provides Register class for setting and getting of ARM Architecture register bits. This can be used for multiple purposes; for example, the Register class can be used for getting and setting the frequencies of Programmable Logic (PL) clocks.

class pynq.registers.Register(address, width=32, debug=False, buffer=None)[source]

Bases: object

Register class that allows users to access registers easily.

This class supports register slicing, which makes the access to register values much more easily. Users can either use +1 or -1 as the step when slicing the register. By default, the slice starts from MSB to LSB, which is consistent with the common hardware design practice.

For example, the following slices are acceptable: reg[31:13] (commonly used), reg[:], reg[3::], reg[:20:], reg[1:3], etc.


The slicing endpoints are closed, meaning both of the 2 endpoints will be included in the final returned value. For example, reg[31:0] will return a 32-bit value; this is consistent with most of the hardware definitions.


The address of the register.


The width of the register, e.g., 32 (default) or 64.

classmethod count(index, width=32)[source]

Provide the number of bits accessed by an index or slice

This method accepts both integer index, or slice as input parameters.

  • index (int | slice) – The integer index, or slice to access the register value.
  • width (int) – The number of bits accessed.
classmethod create_subclass(name, fields, doc=None)[source]

Create a subclass of Register that has properties for the specified fields

The fields should be in the form used by ip_dict, namely:

{name: {'access': "read-only" | "read-write" | "write-only",
        'bit_offset': int, 'bit_width': int, 'description': str}}
  • name (str) – A suffix for the name of the subclass
  • fields (dict) – A Dictionary containing the fields to add to the subclass
class pynq.registers.RegisterMap(buffer)[source]

Bases: object

Provides access to a named register map.

This class is designed to be subclassed using the create_subclass method which will create a class with properties for all of the registers in a specific map.

See the create_subclass function for more details.

classmethod create_subclass(name, registers)[source]

Create a new RegisterMap subclass with the specified registers

The dictionary should have the same form as the “registers” entry in the ip_dict. For example:

{name : {"address_offset" : int,
         "access" : "read-only" | "write-only" | "read-write",
         "size" : int,
         "description" : str,
         "fields" : dict}}

For details on the contents of the “fields” entry see the Register class documentation.

  • name (str) – Suffix to append to “RegisterMap” to make the name of the new class
  • registers (dict) – Dictionary of the registers to create in the subclass