pynq.ps Module

The pynq.ps module facilitates management of the Processing System (PS) and PS/PL interface. It provides Register and Clocks classes for setting and getting of ARM Architecture register bits. The Register class is used in the Clocks class for getting the ARM clock frequency, and getting and setting the frequencies Programmable Logic (PL) clocks.

class pynq.ps.Clocks[source]

Bases: object

Class for all the PS and PL clocks exposed to users.

With this class, users can get the CPU clock and all the PL clocks. Users can also set PL clocks to other values using this class.

cpu_mhz

float – The clock rate of the CPU, measured in MHz.

fclk0_mhz

float – The clock rate of the PL clock 0, measured in MHz.

fclk1_mhz

float – The clock rate of the PL clock 1, measured in MHz.

fclk2_mhz

float – The clock rate of the PL clock 2, measured in MHz.

fclk3_mhz

float – The clock rate of the PL clock 3, measured in MHz.

class pynq.ps.Register(address, width=32, debug=False)[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.

Note

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.

address

int – The address of the register.

width

int – 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.

Parameters:
  • index (int | slice) – The integer index, or slice to access the register value.
  • width (int) – The number of bits accessed.