pynq.buffer Module

Home of the pynq.allocate function

class pynq.buffer.PynqBuffer[source]

Bases: numpy.ndarray

A subclass of numpy.ndarray which is allocated using physically contiguous memory for use with DMA engines and hardware accelerators. As physically contiguous memory is a limited resource it is strongly recommended to free the underlying buffer with close when the buffer is no longer needed. Alternatively a with statement can be used to automatically free the memory at the end of the scope.

This class should not be constructed directly and instead created using pynq.allocate().

device_address

The physical address to the array

Type:int
coherent

Whether the buffer is coherent

Type:bool
cacheable
close()[source]

Unused - for backwards compatibility only

flush()[source]

Flush the underlying memory if necessary

freebuffer()[source]

Free the underlying memory

This will free the memory regardless of whether other objects may still be using the buffer so ensure that no other references to the array exist prior to freeing.

invalidate()[source]

Invalidate the underlying memory if necessary

physical_address
pynq.buffer.allocate(shape, dtype, target=None, **kwargs)[source]

Allocate a PYNQ buffer

The target determines where the buffer gets allocated

  • If None then the currently active device is used
  • If a Device is specified then the main memory