From e35a66879bcc2b28b6b6a82ce395533e3330b088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Stojke?= <100069573+mstojke@users.noreply.github.com> Date: Thu, 17 Apr 2025 21:05:27 +0200 Subject: [PATCH] Update dma.py Added argument for _SGDMAChannel.transfer() method to write BD's to selected memory --- pynq/lib/dma.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pynq/lib/dma.py b/pynq/lib/dma.py index 1857149e5..4141cc6c0 100644 --- a/pynq/lib/dma.py +++ b/pynq/lib/dma.py @@ -310,7 +310,7 @@ def stop(self): def _clear_interrupt(self): self._mmio.write(self._offset + 4, 0x1000) - def transfer(self, array, start=0, nbytes=0, cyclic=False): + def transfer(self, array, start=0, nbytes=0, cyclic=False, bd_allocate_target=None): """Transfer memory with the DMA Transfer must only be called when the channel is halted @@ -345,7 +345,9 @@ def transfer(self, array, start=0, nbytes=0, cyclic=False): Number of bytes to transfer. Default is 0. cyclic : bool Enable cyclic BD mode. Default is False. - + bd_allocate_target : PynqBuffer + The target memory to allocate buffer descriptors. Default is None. + If None, the buffer descriptors are allocated in the active memory. """ if not self.halted: @@ -377,7 +379,10 @@ def transfer(self, array, start=0, nbytes=0, cyclic=False): # Zero-Allocate buffer for descriptors: uint32[_num_descr][16] # Descriptor is only 52 bytes but each one has to be 64-byte aligned! - self._descr = allocate(shape=(self._num_descr, 16), dtype=numpy.uint32) + self._descr = allocate(shape=(self._num_descr, 16), dtype=numpy.uint32, target=bd_allocate_target) + + # Fill descriptors with zeros in case of re-use of allocated memory without board reset + self._descr.fill(0) # Idle DMA engine self.stop()