APB (APB3/APB4) Protocol Verification IP

APB VIP

Professional-grade AMBA APB3/APB4 verification component for low-bandwidth peripheral and register access verification

DUT validated v0.1 UVM 1.1d/1.2 IEEE 1800 Single Image APB3/APB4

๐Ÿ“‹ 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
๐Ÿ“ Note: In APB3 mode, the master forces APB3-compliant semantics (PSTRB=all 1's, PPROT=0) and APB4-specific assertions are automatically disabled.

๐Ÿš€ 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)

โœ… APB4 Features (APB3 + Enhancements)

โœ… Multi-Select Support

๐Ÿ“‹ Limitations & Future Enhancements

Current Limitations

Planned Enhancements


๐Ÿ” 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

  1. Start with basic APB4 transfers:
    make questa TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB4'
    

    Verifies basic read/write operations with APB4

  2. Test APB3 backward compatibility:
    make questa TEST=apb_b2b_smoke_test PLUSARGS='+APB_PROTOCOL=APB3'
    

    Ensures APB3 mode works correctly

  3. Enable wait states:
    make questa TEST=apb_wait_state_test PLUSARGS='+APB_PROTOCOL=APB4'
    

    Tests slave PREADY stalling

  4. Test byte strobes (APB4 only):
    make questa TEST=apb_strobe_test PLUSARGS='+APB_PROTOCOL=APB4'
    

    Verifies PSTRB byte-lane writes

  5. Enable error injection:
    make questa TEST=apb_error_test PLUSARGS='+APB_PROTOCOL=APB4'
    

    Tests PSLVERR error responses

  6. 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/:


๐Ÿ’ก 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

Siemens Questa 2025.3_2 Synopsys VCS 2025.06_1 Cadence Xcelium 25.03.007

๐Ÿ“ž 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