Skip to content

Conversation

@mstojke
Copy link

@mstojke mstojke commented Apr 17, 2025

Added argument for _SGDMAChannel.transfer() method to write BD's to selected memory (for example: in case when buffer descriptors will be stored in PL RAM)

Signed-off-by: Michał Stojke [email protected]

Added argument for _SGDMAChannel.transfer() method to write BD's to selected memory
@mariodruiz mariodruiz changed the base branch from master to image_v3.1 April 18, 2025 07:00
@jogomojo
Copy link
Collaborator

Hi @mstojke, thank you for your PR.

In what context have you used your updated code?

From what I can see, you add bd_allocate_target to PYNQ's allocate function as a target. However, allocate expects target to be a Device class (e.g. XrtDevice), which then calls the device's own allocate function (e.g. XrtDevice.allocate)

PYNQ/pynq/buffer.py

Lines 138 to 158 in 19ed17d

def allocate(shape, dtype="u4", target=None, **kwargs):
"""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
"""
from .pl_server import Device
if target is None:
target = Device.active_device
return target.allocate(shape, dtype, **kwargs)

@mstojke
Copy link
Author

mstojke commented Aug 15, 2025

Hi @jogomojo

I made a mistake in the description of the transfer() function in the _SGDMAChannel() class. It should actually pass a memory device instead of the described PynqBuffer.

PYNQ/pynq/lib/dma.py

Lines 348 to 350 in e35a668

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.

I used the modified code to allocate memory space in the PL DDR4. Below is a fragment from my project showing how it was used.

dma_max_transfer_size = 4194304 * 4
overlay.dma = DMA(overlay.ip_dict['axi_dma_0'])
overlay.dma.recvchannel._max_size = dma_max_transfer_size 
overlay.dma.recvchannel.transfer(buf, ddr_4_target=overlay.ddr4_0)

@jogomojo
Copy link
Collaborator

Hi @mstojke

Could you share a minimal Vivado tcl design I could build and a Python file for me to run so I can test this out?

@jogomojo jogomojo changed the base branch from image_v3.1 to image_v3.1.1 August 15, 2025 07:57
@mstojke
Copy link
Author

mstojke commented Aug 26, 2025

Hi @jogomojo

I added you to the repository with the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants