pynq.buffer Module
Home of the pynq.allocate function
- class pynq.buffer.PynqBuffer(*args, device=None, device_address=0, bo=0, coherent=False, **kwargs)[source]
Bases:
ndarrayA 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
- property 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.
- property physical_address
- property 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
targetkeyword 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