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
¶
-
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.
-
physical_address
¶
-
virtual_address
¶
-
-
pynq.buffer.
allocate
(shape, dtype='u4', target=None, **kwargs)[source]¶ Allocate a PYNQ buffer
This API mimics the numpy ndarray constructor with the following differences:
- The default dtype is 32-bit unsigned int rather than float
- A new
target
keyword parameter to determine where the buffer should be allocated
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