APB (APB3/APB4) Protocol Verification IP
APB VIP
Professional-grade AMBA APB3/APB4 verification component for low-bandwidth peripheral and register access verification
๐ Overview
The KVIPS APB VIP is a vendor-neutral SystemVerilog/UVM verification component supporting both APB3 and APB4 protocols in a single compiled image with runtime protocol selection. Ideal for verifying register access interfaces and low-bandwidth peripheral connections.
๐ฏ Master Agent
- Setup/access phase sequencing
- Configurable PSEL drop/continuous modes
- APB3/APB4 protocol compliance
- Configurable address/data widths
- PPROT generation (APB4)
- PSTRB byte-lane control (APB4)
๐ Slave Agent
- Word-addressed memory model
- Configurable wait states (PREADY control)
- Error injection (PSLVERR responses)
- Address range-based error injection
- PSTRB-aware byte-lane writes (APB4)
- Multiple PSEL support
โ Protocol Checkers
- Setup/access phase timing validation
- Signal stability assertions
- APB3-specific checks
- APB4-specific checks (PPROT, PSTRB)
- Runtime assertion enable/disable switches
- PSEL/PENABLE sequencing checks
๐ Verification Features
- Expected memory scoreboard
- Transaction reconstruction on completion
- Functional coverage collection
- Optional transaction recording (UVM TR)
- Configurable trace levels
- Read data integrity checking
๐ Protocol Selection
The APB VIP supports both APB3 and APB4 in a single compiled image. The interface always includes APB4 signals (PPROT, PSTRB), but the mode determines their behavior:
# APB3 mode - legacy compatibility
+APB_PROTOCOL=APB3
# Master forces PSTRB='1, PPROT=0
# APB4-only assertions are disabled
# APB4 mode (default) - full APB4 features
+APB_PROTOCOL=APB4
# PPROT and PSTRB are actively driven
# All APB4 assertions are enabled
๐ Quick Start
Run Example Tests
Navigate to the APB examples directory and run tests:
cd apb/examples/
# List available tests
make list-tests
# Run smoke test on Questa with APB4
make questa TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB4'
# Run with APB3 mode
make questa TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB3'
# Run on VCS
make vcs TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB4'
# Run on Xcelium
make xcelium TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB4'
# Run on Verilator
make verilator TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB4'
# Full Verilator regression
make regress-verilator
# Run with LSF (if tools require job scheduler)
# source <path-to-lsf>/conf/profile.lsf
make questa USE_LSF=1 TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB4'
๐ Note: SVA assertions are skipped under Verilator.
Available Test Cases
| Test Name | Description | Protocol |
|---|---|---|
apb_b2b_smoke_test |
Basic back-to-back read/write transfers | APB3/APB4 |
apb_wait_state_test |
Tests slave wait state insertion (PREADY=0) | APB3/APB4 |
apb_error_test |
Error response injection (PSLVERR) testing | APB3/APB4 |
apb_strobe_test |
Byte-lane strobing tests | APB4 only |
apb_prot_test |
PPROT signal generation tests | APB4 only |
apb_random_stress_test |
Random mixed transactions | APB3/APB4 |
๐งช APB4 RTL-DUT verification
The separate apb/examples/uvm_dut/
flow connects the KVIPS APB4 master to a byte-addressed signal-level RAM DUT.
It is an executable integration target, not the APB master/slave loopback
demo. The eight DUT tests cover deterministic readback, continuous transfers,
PSTRB, PPROT, wait states, the mapped boundary, unmapped PSLVERR, and
randomized APB4 traffic.
Run the evidence-gated commercial regressions from the repository root:
make -C apb/examples regress-rtl-questa USE_LSF=1
make -C apb/examples regress-rtl-vcs USE_LSF=1
make -C apb/examples regress-rtl-xcelium USE_LSF=1
The gate requires observed monitor handshakes, expected error behavior, zero protocol/UVM/simulator errors, and zero scoreboard mismatches. GitHub Actions runs the DUT list with Verilator; Verilator remains a CI-only path on the development workstation. The complete test matrix and remaining single-slave boundaries are in the APB4 DUT verification milestone.
๐ Architecture
Component Hierarchy
apb_env
โโโ apb_agent (master)
โ โโโ apb_sequencer
โ โโโ apb_master_driver
โ โโโ apb_monitor
โโโ apb_agent (slave)
โ โโโ apb_sequencer
โ โโโ apb_slave_driver
โ โโโ apb_monitor
โโโ apb_scoreboard
โโโ apb_txn_logger (optional)
Directory Structure
kvips/apb/
โโโ sv/
โ โโโ if/
โ โ โโโ apb_if.sv # APB interface + clocking blocks
โ โโโ assertions/
โ โ โโโ apb_if_sva.svh # Protocol assertions (SVA)
โ โโโ pkg/
โ โ โโโ apb_types_pkg.sv # Type definitions, enums
โ โ โโโ apb_uvm_pkg.sv # UVM package
โ โโโ uvm/
โ โโโ apb_cfg.sv # Configuration object
โ โโโ apb_txn.sv # Transaction item
โ โโโ apb_sequencer.sv # Sequencer
โ โโโ apb_master_driver.sv # Master driver
โ โโโ apb_slave_driver.sv # Slave driver/responder
โ โโโ apb_monitor.sv # Passive monitor
โ โโโ apb_scoreboard.sv # Data integrity checker
โ โโโ apb_agent.sv # Agent wrapper
โ โโโ apb_env.sv # Environment
โ โโโ sequences/
โ โโโ apb_base_seq.sv
โ โโโ apb_single_seq.sv
โ โโโ apb_burst_seq.sv
โโโ docs/
โ โโโ user_guide.md # Detailed usage guide
โ โโโ integration_guide.md # Integration instructions
โ โโโ supported_features.md # Feature list & roadmap
โ โโโ assertions.md # Assertion documentation
โ โโโ testplan.md # Test coverage plan
โ โโโ directory_structure.md # File organization
โ โโโ dut_verification.md # APB4 RTL-DUT milestone
โโโ examples/
โ โโโ uvm_back2back/ # Self-contained VIP-to-VIP demo
โ โโโ uvm_dut/ # APB4 master to RTL-DUT integration
โโโ README.md # Quick reference
โ๏ธ Configuration
Key Configuration Knobs
class apb_cfg extends uvm_object;
// Protocol Selection
apb_protocol_t protocol = APB4; // APB3 or APB4
// Address/Data Configuration
int unsigned addr_width = 32;
int unsigned data_width = 32;
int unsigned nsel = 1; // Number of PSEL signals
// Master Configuration
bit drop_psel_between = 1; // Drop PSEL between transactions
int unsigned sel_index = 0; // Which PSEL to drive (0..nsel-1)
// Slave Configuration - Wait States
bit allow_wait_states = 1;
int unsigned min_wait_cycles = 0; // Minimum PREADY=0 cycles
int unsigned max_wait_cycles = 5; // Maximum PREADY=0 cycles
// Slave Configuration - Error Injection
bit err_enable = 0; // Enable PSLVERR injection
bit [31:0] err_addr_lo = 0; // Error range start
bit [31:0] err_addr_hi = 0; // Error range end
int unsigned err_pct = 10; // Error probability %
// APB4-Specific Configuration
bit randomize_pprot = 1; // Random PPROT generation
bit randomize_pstrb = 0; // Random PSTRB (0=full strobes)
// Debug & Coverage
bit trace_enable = 0; // Transaction tracing
bit coverage_enable = 1; // Coverage sampling
// Assertion Control
bit assertions_enable = 1; // Enable SVA checks
// Memory Configuration
bit [31:0] mem_base = 32'h0000_0000;
bit [31:0] mem_size = 32'h0001_0000;
endclass
Runtime Configuration via Plusargs
# Protocol mode selection
+APB_PROTOCOL=APB3 # APB3 mode
+APB_PROTOCOL=APB4 # APB4 mode (default)
# Debug options
+VIP_TRACE # Enable transaction tracing
+UVM_VERBOSITY=UVM_HIGH # Verbose UVM messaging
# Scoreboard options
+KVIPS_APB_SB_WARN_UNINIT # Warn on reads from uninitialized memory
๐ Supported Features
โ APB3 Features (Current)
- โ Master driver with setup/access phase sequencing
- โ Optional drop/continuous PSEL style
- โ Slave responder with word-addressed memory model
- โ Configurable wait-state insertion (PREADY control)
- โ Error injection (PSLVERR) by address range
- โ Monitor with transaction reconstruction
- โ Scoreboard with expected memory model
- โ Read data integrity checking
โ APB4 Features (APB3 + Enhancements)
- โ
PPROT signal generation and checking
- Optional randomization
- Protocol-aware constraints
- โ
PSTRB byte-lane strobing
- Byte-lane masked writes in memory model
- Optional randomization or full strobes
- โ
APB4-specific assertions
- Automatically enabled in APB4 mode
- Gated off in APB3 mode
โ Multi-Select Support
- โ Vector PSEL[NSEL-1:0] interface support
- โ Configurable NSEL parameter
- โ Master selects specific sel_index
๐ Limitations & Future Enhancements
Current Limitations
- ๐ Slave memory model is simplified (not a full register model)
- ๐ No negative/bad-driver test modes yet
- ๐ Limited constrained random coverage scenarios
Planned Enhancements
- ๐ Register abstraction layer (RAL) integration
- ๐ Advanced error injection modes
- ๐ Protocol violation tests
- ๐ Formal verification property exports
- ๐ Performance monitoring
- ๐ Multi-master arbitration scenarios
๐ APB3 vs APB4 Comparison
| Feature | APB3 | APB4 |
|---|---|---|
| PSEL/PENABLE | โ | โ |
| PADDR/PWDATA/PRDATA | โ | โ |
| PWRITE | โ | โ |
| PREADY | โ | โ |
| PSLVERR | โ | โ |
| PPROT[2:0] | โ | โ Protection control |
| PSTRB[n-1:0] | โ | โ Byte lane strobes |
| Write Granularity | Full word only | Byte-lane selective |
| Protection Types | None | Normal/Privileged/Secure |
๐ Debug Workflow
Recommended Bring-Up Sequence
- Start with basic APB4 transfers:
make questa TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB4'Verifies basic read/write operations with APB4
- Test APB3 backward compatibility:
make questa TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB3'Ensures APB3 mode works correctly
- Enable wait states:
make questa TEST=apb_wait_state_test PLUSARGS='+APB_PROTOCOL=APB4'Tests slave PREADY stalling
- Test byte strobes (APB4 only):
make questa TEST=apb_strobe_test PLUSARGS='+APB_PROTOCOL=APB4'Verifies PSTRB byte-lane writes
- Enable error injection:
make questa TEST=apb_error_test PLUSARGS='+APB_PROTOCOL=APB4'Tests PSLVERR error responses
- Random stress testing:
make questa TEST=apb_random_stress_test PLUSARGS='+APB_PROTOCOL=APB4'Runs mixed random transactions
Debug Options
# Verbose UVM messaging
+UVM_VERBOSITY=UVM_HIGH
# Enable transaction tracing
+VIP_TRACE
# Warn on uninitialized memory reads
+KVIPS_APB_SB_WARN_UNINIT
# Waveform dumping
+KVIPS_WAVES
# Protocol mode selection
+APB_PROTOCOL=APB3 # or APB4
๐ Detailed Documentation
For comprehensive information, refer to the following source documents in
apb/docs/:
- User Guide - Detailed configuration and usage
- Integration Guide - Step-by-step integration
- Supported Features - Complete feature list
- Assertions - SVA checker documentation
- Testplan - Test coverage mapping
- Directory Structure - File organization
- APB4 DUT verification - Executable DUT test matrix and evidence rules
๐ก Integration Example
Minimal Testbench Integration
// 1. Instantiate APB interface
apb_if #(
.ADDR_W(32),
.DATA_W(32),
.NSEL(1)
) apb_if_inst (
.PCLK(clk),
.PRESETn(rst_n)
);
// 2. In your UVM environment
class my_env extends uvm_env;
apb_env apb_env_inst;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
// Create APB configuration
apb_cfg cfg = apb_cfg::type_id::create("cfg");
cfg.protocol = APB4;
cfg.allow_wait_states = 1;
cfg.max_wait_cycles = 3;
cfg.trace_enable = 1;
// Set virtual interface
if (!uvm_config_db#(virtual apb_if)::get(this, "", "vif", cfg.vif))
`uvm_fatal("ENV", "Failed to get APB interface")
// Create environment
uvm_config_db#(apb_cfg)::set(this, "apb_env_inst", "cfg", cfg);
apb_env_inst = apb_env::type_id::create("apb_env_inst", this);
endfunction
endclass
// 3. Start sequences
class my_test extends uvm_test;
task run_phase(uvm_phase phase);
apb_single_seq seq;
phase.raise_objection(this);
// Write to register
seq = apb_single_seq::type_id::create("seq");
seq.addr = 32'h1000;
seq.data = 32'hCAFEBABE;
seq.is_write = 1;
seq.strb = 4'hF; // All bytes (APB4)
seq.start(env.apb_env_inst.master_agent.sequencer);
// Read back
seq = apb_single_seq::type_id::create("seq");
seq.addr = 32'h1000;
seq.is_write = 0;
seq.start(env.apb_env_inst.master_agent.sequencer);
phase.drop_objection(this);
endtask
endclass
๐ Example Tests
The back-to-back tests are located in kvips/apb/examples/uvm_back2back/.
The APB4 RTL-DUT tests are located in kvips/apb/examples/uvm_dut/:
examples/
โโโ tb/
โ โโโ top.sv # Top-level testbench
โ โโโ test_pkg.sv # Test package
โโโ tests/
โ โโโ apb_base_test.sv
โ โโโ apb_b2b_smoke_test.sv
โ โโโ apb_wait_state_test.sv
โ โโโ apb_error_test.sv
โ โโโ apb_strobe_test.sv # APB4 only
โ โโโ apb_random_stress_test.sv
โโโ sim/
โโโ Makefile
โโโ run_questa.sh
โโโ run_vcs.sh
โโโ run_xcelium.sh
uvm_dut/
โโโ tb/dut/apb_ram_slave.sv # Signal-level APB4 RAM DUT
โโโ tb/tests/ # Eight DUT-focused UVM tests
โโโ sim/ # Commercial and Verilator runners
๐ง Validated Tool Versions
๐ Support & Resources
๐ Documentation
๐ฌ Community
Ready to Verify APB Interfaces?
Get started with KVIPS APB VIP and accelerate your register verification!
Get Started View on GitHub