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_adapterin 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.
| Method | Direction | Purpose |
|---|---|---|
reg2bus() | Reg → Bus | Converts uvm_reg_item (e.g., read/write) into an APB transaction with PADDR, PWRITE, PWDATA, etc. |
bus2reg() | Bus → Reg | Copies 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.
- Open
student/tb/tb_top.svin the editor. - Implement the
reg2bus()method in youruvm_reg_adaptersubclass.
- 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.
- Implement
bus2reg()to copyprdataand status signals (pready,pslverr) into theuvm_reg_item. - In the environment, instantiate the adapter and connect it to the register map using
reg_model.default_map.set_sequencer(..., adapter). - 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
- Open the UVM workspace in the IDE. The DUT and the testbench compile together in the browser.
- Run the SystemVerilog simulation with Verilator and read the phase and scoreboard lines in the log.
- When the check is on pins rather than a print, open the VCD next to that log.
- 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.