RTL Studio Open IDE

5.3 · UVM CLASS

RAL adapter: reg ops to APB bus transactions

Implement a register adapter that translates register operations into APB bus transactions.

Watch on YouTube

What you practice

RAL adapter: reg ops to APB bus transactions (5.3). Implement a register adapter that translates register operations into APB bus transactions. It is in RAL adapter — Part 5 · AMBA APB and UVM RAL of the UVM Masterclass. APB protocol, register abstraction, and the roadmap to AXI.

The UVM bench compiles in that same browser SystemVerilog simulator. You edit the test in the IDE, run Verilator, and read the log beside the waveform.

What you will learn

You will implement a UVM register adapter to translate register read/write operations into APB bus transactions, enabling the RAL model to drive real hardware interfaces.

Learning objectives

  • Understand the role of uvm_reg_adapter in UVM register layer communication.
  • Implement reg2bus() to convert register operations to APB protocol signals.
  • Implement bus2reg() to extract APB response data back into register fields.
  • Hook the adapter to the register model's default map in the environment.

Theory

The uvm_reg_adapter bridges the register layer and the bus layer in UVM. It translates high-level register operations (uvm_reg_item) into low-level bus transactions (uvm_sequence_item), such as APB cycles.

MethodDirectionPurpose
reg2bus()Reg → BusConverts uvm_reg_item (e.g., read/write) into an APB transaction with PADDR, PWRITE, PWDATA, etc.
bus2reg()Bus → RegCopies APB response signals (PRDATA, PREADY, PSLVERR) back into the uvm_reg_item.

The adapter is registered with the register model’s default_map using reg_model.default_map.set_sequencer(..., adapter). The APB protocol uses PADDR, PWRITE, PWDATA, PSel, PEnable, PRData, PReady, and PSlvErr signals.

Practice

Open the lesson chapter in RtlStudio. Files appear automatically in Explore.

  1. Open student/tb/tb_top.sv in the editor.
  2. Implement the reg2bus() method in your uvm_reg_adapter subclass.

- Inside reg2bus(), create an APB transaction (e.g., apb_transaction), cast the input uvm_reg_item, and set paddr, pwrite, pwdata based on the item’s address and data.

  1. Implement bus2reg() to copy prdata and status signals (pready, pslverr) into the uvm_reg_item.
  2. In the environment, instantiate the adapter and connect it to the register map using reg_model.default_map.set_sequencer(..., adapter).
  3. Run Simulation and verify the log output matches expected results.

Summary

You implemented a UVM register adapter to translate register operations into APB bus transactions. You completed the reg2bus() method to drive PADDR, PWRITE, and PWDATA, and bus2reg() to capture PRDATA. The adapter was successfully hooked to the register model’s default map in the environment. The key takeaway is that adapters act as the bridge between high-level register abstractions and low-level protocol transactions.

Run it in the Verilog IDE

  1. Open the UVM workspace in the IDE. The DUT and the testbench compile together in the browser.
  2. Run the SystemVerilog simulation with Verilator and read the phase and scoreboard lines in the log.
  3. When the check is on pins rather than a print, open the VCD next to that log.
  4. Edit the sequence, driver, or scoreboard in the IDE and rerun. You stay in the same simulator.

The lesson is done when the simulation matches RAL adapter: reg ops to APB bus transactions. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.