RTL Studio Open IDE

1.3 · AXI CLASS

SV struct register map: packed CTRL, STAT, and DATA

Define packed structs for CTRL, STAT, and DATA register fields and verify in a testbench.

Watch on YouTube

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 packed for 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.

TypeFields (LSB→MSB)Width
ctrl_regenable, reset, reserved[29:0]32-bit
stat_regfifo_full, fifo_empty, reserved[29:0]32-bit
data_regpayload[31:0]32-bit

All fields are logic or logic [N:0]; ordering matches bit-slice assignments in the RTL.

Practice

  1. Open this chapter in RtlStudio; confirm student/rtl/axi_lite_slave.sv and student/tb/tb_top.sv appear in Explore.
  2. Edit student/rtl/axi_lite_slave.sv to complete the three typedef struct packed definitions.
  3. Fill each __TODO__ with logic or logic [N:0] to match the golden struct layout.
  4. Run Simulation and check the Log panel for INFO messages.
  5. 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

  1. Open the lesson in the IDE and find the valid/ready or AXI channel ports in the editor.
  2. Simulate with Verilator. Confirm the beat on the VCD, not only in the transcript.
  3. Check that data moves only on the beats this lesson describes, and that backpressure holds the transfer.
  4. 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.