What you practice
SV struct register map: packed CTRL, STAT, and DATA (1.3). Define packed structs for CTRL, STAT, and DATA register fields and verify in a testbench. It is in SV Struct Register Map — Part 1 · AXI4-Lite RTL Design of the AXI Masterclass. Design an AXI4-Lite slave in pure SystemVerilog.
AXI only counts when the handshake simulates. RTL Studio is the Verilog and SystemVerilog IDE where you edit the RTL and prove each beat on a VCD.
What you will learn
Today you will define SystemVerilog packed structs to represent AXI-Lite register fields cleanly, mapping WDATA directly into control, status, and data fields.
Learning objectives
- Define
typedef struct packedfor register maps (CTRL, STAT, DATA). - Decode addresses 0x00, 0x04, 0x08 per OWNER decision B.
- Verify struct packing and field mapping via testbench stimulus.
Theory
Packed structs ensure bit-exact layout for hardware registers, avoiding implementation-defined padding.
| Type | Fields (LSB→MSB) | Width |
|---|---|---|
ctrl_reg | enable, reset, reserved[29:0] | 32-bit |
stat_reg | fifo_full, fifo_empty, reserved[29:0] | 32-bit |
data_reg | payload[31:0] | 32-bit |
All fields are logic or logic [N:0]; ordering matches bit-slice assignments in the RTL.
Practice
- Open this chapter in RtlStudio; confirm
student/rtl/axi_lite_slave.svandstudent/tb/tb_top.svappear in Explore. - Edit
student/rtl/axi_lite_slave.svto complete the threetypedef struct packeddefinitions. - Fill each
__TODO__withlogicorlogic [N:0]to match the golden struct layout. - Run Simulation and check the Log panel for INFO messages.
- Open Waveform tab to inspect signal timing if VCD is generated.
Summary
You practiced mapping AXI4-Lite write data into a SystemVerilog packed struct to represent control, status, and data registers. You implemented address decode logic for 0x00, 0x04, and 0x08 per OWNER Decision B and assigned WDATA directly to the CTRL_REG struct. The key takeaway is that using packed structs improves register readability, maintainability, and ensures correct bit-field alignment in RTL. This approach aligns with hardware design best practices for structuring register maps in a type-safe and self-documenting way.
Run it in the Verilog IDE
- Open the lesson in the IDE and find the valid/ready or AXI channel ports in the editor.
- Simulate with Verilator. Confirm the beat on the VCD, not only in the transcript.
- Check that data moves only on the beats this lesson describes, and that backpressure holds the transfer.
- Synthesize the RTL master, slave, or buffer with Yosys. Leave the UVM bench out of synthesis.
The lesson is done when the simulation matches SV struct register map: packed CTRL, STAT, and DATA. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.