pynq.allocate function is used to allocate memory that will be used by IP
in the programmable logic.
IP connected to the AXI Master (HP or ACP ports) has access to PS DRAM. Before IP in the PL accesses DRAM, some memory must first be allocated (reserved) for the IP to use and the size, and address of the memory passed to the IP. An array in Python, or Numpy, will be allocated somewhere in virtual memory. The physical memory address of the allocated memory must be provided to IP in the PL.
pynq.allocate allocates memory which is physically contiguous and returns a
pynq.Buffer object representing the allocated buffer. The buffer is a numpy
array for use with other Python libraries and also provides a
.device_address property which contains the physical address for use with
IP. For backwards compatibility a
.physical_address property is also
The allocate function uses the same signature as
numpy.ndarray allowing for
any shape and data-type supported by numpy to be used with PYNQ.
Buffer object returned is a sub-class of
additional properties and methods suited for use with the programmable logic.
device_addressis the address that should be passed to the programmable logic to access the buffer
coherentis True if the buffer is cache-coherent between the PS and PL
flushflushes a non-coherent or mirrored buffer ensuring that any changes by the PS are visible to the PL
invalidateinvalidates a non-coherent or mirrored buffer ensuring any changes by the PL are visible to the PS
sync_to_deviceis an alias to
sync_from_deviceis an alias to
Create a contiguous array of 5 32-bit unsigned integers
from pynq import allocate input_buffer = allocate(shape=(5,), dtype='u4')
device_address property of the buffer
Writing data to the buffer:
input_buffer[:] = range(5)
Flushing the buffer to ensure the updated data is visible to the programmable logic:
More information about memory allocation can be found in the pynq.buffer Module section in the library reference.