This reference design demonstrates low-level DMA control and channel chaining on a Ryzen™ AI NPU (npu2_1col).
This design showcases advanced DMA programming techniques:
-
MemTile Buffer Initialization: A 1kB buffer in MemTile (row 1) is initialized with values 1-256 using the
initial_valueparameter. -
Explicit DMA Control: The MemTile DMA is controlled via explicit locks rather than automatic ObjectFIFO management. The DMA waits for a lock release triggered by
npu_write32in the runtime sequence. -
Low-Level Runtime Sequence: Uses explicit DMA buffer descriptor operations:
npu_writebd- Configure buffer descriptors with lock parametersnpu_address_patch- Patch buffer addresses into BDsnpu_push_queue- Push BDs to DMA queuesnpu_sync- Wait for DMA completion
-
Lock-Based Sequencing: DMA operations are sequenced using locks in the buffer descriptors rather than tokens, providing explicit control over data flow timing.
-
Data Flow:
- Write Path: MemTile (1KB initialized data) → DDR buffer A
- Read Path: DDR buffer B (4KB) → ComputeTile (data discarded, locks toggled)
The design uses:
- ShimTile (row 0) - Interfaces with external DDR memory
- MemTile (row 1) - Stores initialized data, controlled by lock at address 0xC0000
- ComputeTile (row 2) - Receives data and toggles locks in an infinite loop
- Explicit Flows - Connect MemTile→ShimTile and ShimTile→ComputeTile DMAs
To compile and run the design:
make # Build without tracing
make run # Run testTo enable ShimTile tracing for debugging DMA channels and data traffic:
make TRACE=1 # Build with tracing enabled
make run TRACE=1 # Run with tracing
make parse_trace # Parse and analyze trace dataThe trace will capture DMA channel activity, lock operations, and data traffic on the ShimTile. Trace data is written to trace.txt and can be analyzed with the parse_trace target, which generates trace_chaining_channels.json and displays a summary. You can then use perfetto to view the trace as shown below:
make clean # Clean all build artifacts and trace files
make clean_trace # Clean only trace filesThe test verifies that buffer A contains the initialized pattern (values 1-256) that was written from the MemTile.
