What you practice
Memory-to-peripheral DMA (4.4). Implement a Memory-to-Peripheral DMA controller that reads from memory and writes to a peripheral port using a finite state machine. It is in Mem-to-Periph DMA — Part 4 · Data Movement of the SoC Masterclass. Move data with AXI-Stream slices, mem↔stream FIFOs, and a small DMA engine.
SoC lessons simulate the fabric and the peripheral together in the IDE. Verilator is the simulator; the waveform is where address and response show up.
What you will learn
This lesson teaches you how to implement a Memory-to-Peripheral DMA controller. You will learn to read data from memory and write to a peripheral port using a finite state machine. This pattern is essential for efficient data movement in System-on-Chip designs.
Learning objectives
- Implement a state machine to coordinate memory reads and peripheral writes.
- Manage the
busyanddone_irqstatus signals correctly. - Handle AXI read transactions and peripheral write handshakes.
- Verify the design using the provided testbench.
Theory
A DMA (Direct Memory Access) controller moves data without CPU intervention. In this lesson, you implement a simple Memory-to-Peripheral DMA. The controller reads from a memory source and writes to a peripheral destination. It uses a finite state machine to manage the flow of data. The state machine transitions through IDLE, AR, RDATA, PWRITE, and DONE states. The busy signal indicates when the transfer is active. The done_irq signal asserts when the transfer completes. You must handle the AXI read handshake and the peripheral write handshake. The peripheral write requires periph_wvalid and periph_wready to match. The memory read requires arvalid, arready, rvalid, and rready to match. The controller must track the number of words transferred using a counter. The counter decrements after each successful peripheral write. The transfer stops when the counter reaches zero. The done_irq signal asserts in the DONE state. The busy signal is high whenever the state is not IDLE. This ensures the controller reports its status correctly.
Practice
- Open RtlStudio and select this chapter (Lesson 4.4).
- Confirm files appear in the Explore tree.
- Open
student/rtl/ip/soc/mem_to_periph_dma.sv. - Implement the
busyoutput logic based on the current state. - Initialize
state,done_irq,periph_wvalid,m_mem.awvalid,m_mem.arvalid, andm_mem.rreadyto0in the reset block. - Implement the FSM logic to handle AXI reads and peripheral writes.
- Open
student/tb/tb_top.svto understand the stimulus. - Run Simulation from the sidebar.
Summary
You implemented a finite state machine to coordinate data movement from memory to a peripheral port. The design handled AXI handshake signals and managed internal registers to track transfer progress. This exercise demonstrated how to bridge different bus protocols for efficient data transfer.
© 2026 RtlStudio. Licensed under CC BY-NC-ND 4.0. Commercial use and modifications by third parties are not permitted.
Run it in the Verilog IDE
- Open the lesson workspace in the IDE. The fabric and the peripheral are one simulation.
- Run Verilator and follow the address, write data, and read response on the waveform.
- A passing log is not enough when decode or an IRQ line is the point of the lesson — those show up on the VCD.
- Run Yosys on the RTL island you just integrated when you want the mapped cells.
The lesson is done when the simulation matches Memory-to-peripheral DMA. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.