Skip to content

osaidnur/BMU-Verification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

203 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ง BMU Verification Environment

RISC-V UVM SystemVerilog Coverage

A UVM-based verification environment for the RISC-V Bit Manipulation Unit (BMU)


๐Ÿ“‹ Table of Contents


๐ŸŽฏ Overview

The Bit Manipulation Unit (BMU) is a synthesizable RTL block that implements bit manipulation functionality compliant with the RISC-V BitManip extension. This verification environment provides comprehensive testing for all supported instruction subsets and ensures robust functionality across various operational scenarios.


โœจ Features

๐Ÿ”ข Currently Verified RISC-V BitManip Instructions (16 Total)

Extension Instructions Status Description
Zbb CLZ, CPOP, MIN, SEXT.H, AND/ANDN, XOR/XORN โœ… Verified Basic bit manipulation operations
Zbs BEXT โœ… Verified Single bit operations
Zbp ROL, PACKU, GORC โœ… Verified Bit permutation operations
Zba SH3ADD โœ… Verified Address generation operations
Basic ADD, SLL, SRA, SLT/SLTU โœ… Verified Core arithmetic and logical operations

๐Ÿ“Š Verified Instruction Details

Instruction Extension Control Signals
ADD Basic ap.add
CLZ Zbb ap.clz
CPOP Zbb ap.cpop
MIN Zbb ap.min + ap.sub
SEXT.H Zbb ap.siext_h
AND Basic ap.land
ANDN Zbb ap.land + ap.zbb
XOR Basic ap.lxor
XORN Zbb ap.lxor + ap.zbb
SLL Basic ap.sll
SRA Basic ap.sra
SLT Basic ap.slt + ap.sub
SLTU Basic ap.slt + ap.sub + ap.unsign
BEXT Zbs ap.bext
ROL Zbp ap.rol
PACKU Zbp ap.packu
GORC Zbp ap.gorc
SH3ADD Zba ap.sh3add + ap.zba

๐Ÿ—๏ธ BMU Architecture

๐Ÿ“‹ Interface Definition

Port Name Direction Width Description
clk Input 1 bit System clock
rst_l Input 1 bit Active-low synchronous reset
scan_mode Input 1 bit Scan test mode control
valid_in Input 1 bit Instruction valid flag
ap Input Struct Decoded instruction control signals
csr_ren_in Input 1 bit CSR read-enable
csr_rddata_in Input 32 bits CSR read data
a_in, b_in Input 32 bits Input operands A and B
result_ff Output 32 bits Final computed result
error Output 1 bit Error indicator

๐Ÿงฉ Functional Submodules

  • โž• Arithmetic Unit: ADD, SUB, SHxADD operations
  • ๐Ÿ”„ Shift Logic: SLL, SRL, SRA, ROL, ROR operations
  • ๐Ÿ”ข Count Logic: CLZ, CTZ, CPOP implementations
  • ๐Ÿ“ Extension Logic: SEXT.B, SEXT.H sign extension
  • โš–๏ธ Compare Logic: MIN, MAX signed/unsigned comparison
  • ๐Ÿ”€ Pack Logic: PACK, PACKU, PACKH data combination
  • ๐ŸŽญ Bit Logic: BSET, BCLR, BINV, BEXT operations

๐Ÿงช Verification Environment

This comprehensive UVM-based verification environment ensures thorough validation of the BMU design through:

๐ŸŽฏ Verification Components

  • ๐Ÿ–ฅ๏ธ Environment: Complete UVM environment with all necessary components
  • ๐Ÿค– Agent: Modular agent architecture for stimulus generation and monitoring
  • ๐Ÿš— Driver: Intelligent driver for transaction execution
  • ๐Ÿ‘€ Monitor: Comprehensive monitoring and protocol checking
  • ๐Ÿ“Š Scoreboard: Advanced result checking and comparison
  • ๐Ÿ“ Sequences: Targeted and random test sequences
  • โœ… Tests: Comprehensive test suite covering all scenarios

๐ŸŽช Test Categories

  • ๐Ÿ”ง Instruction-Specific Tests: Individual instruction validation
  • ๐ŸŽฒ Random Tests: Pseudo-random stimulus generation
  • โš ๏ธ Error Tests: Error condition validation
  • ๐Ÿ”„ Regression Tests: Complete test suite execution

๐Ÿ“ Directory Structure

BMU-Verification/
โ”œโ”€โ”€ ๐Ÿ“„ README.md                    # This comprehensive documentation
โ”œโ”€โ”€ ๐Ÿ”ง Makefile                     # Build and simulation scripts
โ”œโ”€โ”€ ๐Ÿ“Š .gitignore                   # Git ignore patterns
โ”‚
โ”œโ”€โ”€ ๐Ÿงฉ components/                  # Core verification components
โ”‚   โ”œโ”€โ”€ bmu_interface.sv            # BMU interface definition
โ”‚   โ”œโ”€โ”€ bmu_pkg.sv                  # UVM package declarations
โ”‚   โ”œโ”€โ”€ bmu_sequence_item.sv        # Transaction/sequence item
โ”‚   โ”œโ”€โ”€ bmu_tb.sv                   # Top-level testbench
โ”‚   โ”œโ”€โ”€ BMU.sv                      # BMU design wrapper
โ”‚   โ””โ”€โ”€ env/                        # UVM Environment Components
โ”‚       โ”œโ”€โ”€ bmu_agent.sv            # UVM agent for BMU interface
โ”‚       โ”œโ”€โ”€ bmu_driver.sv           # Driver for stimulus generation
โ”‚       โ”œโ”€โ”€ bmu_environment.sv      # Top-level UVM environment
โ”‚       โ”œโ”€โ”€ bmu_monitor.sv          # Monitor for signal observation
โ”‚       โ”œโ”€โ”€ bmu_scoreboard.sv       # Result checking and comparison
โ”‚       โ”œโ”€โ”€ bmu_sequencer.sv        # Sequence coordination
โ”‚       โ””โ”€โ”€ bmu_subscriber.sv       # Coverage and analysis subscriber
โ”‚
โ”œโ”€โ”€ ๐ŸŽฏ dut_rm/                      # Design Under Test Reference Model
โ”‚   โ””โ”€โ”€ bmu_reference_model.sv      # Golden reference implementation
โ”‚
โ”œโ”€โ”€ ๐Ÿ—๏ธ rtl/                         # RTL Design Files
โ”‚   โ”œโ”€โ”€ Bit_Manibulation_Unit.sv    # Main BMU RTL implementation
โ”‚   โ”œโ”€โ”€ bmu_design.sv               # Design wrapper
โ”‚   โ”œโ”€โ”€ rtl_def.sv                  # RTL definitions
โ”‚   โ”œโ”€โ”€ rtl_defines.sv              # RTL macros and defines
โ”‚   โ”œโ”€โ”€ rtl_lib.sv                  # RTL library components
โ”‚   โ”œโ”€โ”€ rtl_param.vh                # RTL parameters
โ”‚   โ””โ”€โ”€ rtl_pdef.sv                 # RTL package definitions
โ”‚
โ”œโ”€โ”€ ๐ŸŽช sequences/                   # UVM Test Sequences
โ”‚   โ”œโ”€โ”€ bmu_add_sequence.sv         # Addition operation sequence
โ”‚   โ”œโ”€โ”€ bmu_and_sequence.sv         # Logical AND sequence
โ”‚   โ”œโ”€โ”€ bmu_bext_sequence.sv        # Bit extract sequence
โ”‚   โ”œโ”€โ”€ bmu_clz_sequence.sv         # Count leading zeros sequence
โ”‚   โ”œโ”€โ”€ bmu_cpop_sequence.sv        # Population count sequence
โ”‚   โ”œโ”€โ”€ bmu_csr_write_sequence.sv   # CSR write sequence
โ”‚   โ”œโ”€โ”€ bmu_errors_sequence.sv      # Error condition sequence
โ”‚   โ”œโ”€โ”€ bmu_gorc_sequence.sv        # Generalized OR-combine sequence
โ”‚   โ”œโ”€โ”€ bmu_min_sequence.sv         # Minimum operation sequence
โ”‚   โ”œโ”€โ”€ bmu_packu_sequence.sv       # Pack upper sequence
โ”‚   โ”œโ”€โ”€ bmu_reset_sequence.sv       # Reset sequence
โ”‚   โ”œโ”€โ”€ bmu_rol_sequence.sv         # Rotate left sequence
โ”‚   โ”œโ”€โ”€ bmu_sh3add_sequence.sv      # Shift-add sequence
โ”‚   โ”œโ”€โ”€ bmu_siext_h_sequence.sv     # Sign extend halfword sequence
โ”‚   โ”œโ”€โ”€ bmu_sll_sequence.sv         # Shift left logical sequence
โ”‚   โ”œโ”€โ”€ bmu_slt_sequence.sv         # Set less than sequence
โ”‚   โ”œโ”€โ”€ bmu_sra_sequence.sv         # Shift right arithmetic sequence
โ”‚   โ”œโ”€โ”€ bmu_valid_in_sequence.sv    # Valid input sequence
โ”‚   โ””โ”€โ”€ bmu_xor_sequence.sv         # Logical XOR sequence
โ”‚
โ””โ”€โ”€ โœ… tests/                       # UVM Test Cases
    โ”œโ”€โ”€ bmu_add_test.sv             # Addition operation test
    โ”œโ”€โ”€ bmu_and_test.sv             # Logical AND test
    โ”œโ”€โ”€ bmu_bext_test.sv            # Bit extract test
    โ”œโ”€โ”€ bmu_clz_test.sv             # Count leading zeros test
    โ”œโ”€โ”€ bmu_cpop_test.sv            # Population count test
    โ”œโ”€โ”€ bmu_csr_write_test.sv       # CSR write test
    โ”œโ”€โ”€ bmu_errors_test.sv          # Error condition test
    โ”œโ”€โ”€ bmu_gorc_test.sv            # Generalized OR-combine test
    โ”œโ”€โ”€ bmu_min_test.sv             # Minimum operation test
    โ”œโ”€โ”€ bmu_packu_test.sv           # Pack upper test
    โ”œโ”€โ”€ bmu_regression_test.sv      # Complete regression test
    โ”œโ”€โ”€ bmu_rol_test.sv             # Rotate left test
    โ”œโ”€โ”€ bmu_sh3add_test.sv          # Shift-add test
    โ”œโ”€โ”€ bmu_siext_h_test.sv         # Sign extend halfword test
    โ”œโ”€โ”€ bmu_sll_test.sv             # Shift left logical test
    โ”œโ”€โ”€ bmu_slt_test.sv             # Set less than test
    โ”œโ”€โ”€ bmu_sra_test.sv             # Shift right arithmetic test
    โ”œโ”€โ”€ bmu_valid_in_test.sv        # Valid input test
    โ””โ”€โ”€ bmu_xor_test.sv             # Logical XOR test

๐Ÿš€ Quick Start

๐Ÿ“‹ Prerequisites

  • Cadence Xcelium or compatible SystemVerilog simulator
  • UVM 1.2 or later
  • Make utility for build automation

โšก Running Simulations

  1. Clone the repository

    git clone <repository-url>
    cd BMU-Verification
  2. Run regression test (Recommended for first-time users)

    make all
  3. Run specific test

    make TEST_NAME=bmu_add_test run_sim
  4. Run with different verbosity

    make TEST_NAME=bmu_clz_test VERBOSITY=UVM_HIGH run_sim
  5. Clean build artifacts

    make clean

๐ŸŽ›๏ธ Available Make Targets

Target Description
all Clean and run regression test
run_sim Run simulation with specified test
test Run default test from testbench
wave Open Verisium GUI
imc Open IMC GUI
clean Remove simulation artifacts

๐Ÿ” Verified Instruction Set (16 Instructions)

๐ŸŸฆ Zbb - Basic Bit Manipulation (6 Instructions)

Instruction Status Description Test Coverage
CLZ โœ… Verified Count Leading Zeros - counts zeros from MSB before first '1' Complete
CPOP โœ… Verified Count Population - counts total number of '1' bits Complete
MIN โœ… Verified Minimum - returns smaller of two signed integers Complete
SEXT.H โœ… Verified Sign Extend Halfword - extends sign bit from bit 15 Complete
ANDN โœ… Verified AND with Negation - performs a & (~b) Complete
XORN โœ… Verified Exclusive NOR - performs (a ^ ~b) Complete

๐ŸŸฉ Zbs - Single Bit Operations (1 Instruction)

Instruction Status Description Test Coverage
BEXT โœ… Verified Bit Extract - copies specific bit to LSB, clears others Complete

๐ŸŸจ Zbp - Bit Permutation (3 Instructions)

Instruction Status Description Test Coverage
ROL โœ… Verified Rotate Left - rotates bits left, MSB wraps to LSB Complete
PACKU โœ… Verified Pack Upper Halves - combines upper halves from two registers Complete
GORC โœ… Verified Generalized OR-Combine - sets all bits in byte to '1' if any bit was '1' Complete

๐ŸŸช Zba - Address Generation (1 Instruction)

Instruction Status Description Test Coverage
SH3ADD โœ… Verified Shift-Add 3 - performs (a << 3) + b Complete

๐Ÿ”ง Basic Operations (5 Instructions)

Instruction Status Description Test Coverage
ADD โœ… Verified Addition - performs a + b Complete
AND โœ… Verified Logical AND - performs a & b Complete
XOR โœ… Verified Logical XOR - performs a ^ b Complete
SLL โœ… Verified Shift Left Logical - shifts left by specified amount Complete
SRA โœ… Verified Shift Right Arithmetic - arithmetic right shift Complete
SLT โœ… Verified Set Less Than - signed comparison a < b Complete
SLTU โœ… Verified Set Less Than Unsigned - unsigned comparison a < b Complete

๐Ÿ“Š Summary: 16 Verified Instructions

  • Zbb Extension: 6 instructions (CLZ, CPOP, MIN, SEXT.H, ANDN, XNOR)
  • Zbs Extension: 1 instruction (BEXT)
  • Zbp Extension: 3 instructions (ROL, PACKU, GORC)
  • Zba Extension: 1 instruction (SH3ADD)
  • Basic Operations: 5 instructions (ADD, AND, XOR, SLL, SRA, SLT, SLTU)

๐Ÿ“Š Coverage Model

๐ŸŽฏ Functional Coverage Areas

  • โœ… Instruction Coverage: All supported instructions exercised
  • ๐Ÿ“Š Operand Coverage: Various operand combinations and edge cases
  • ๐Ÿ”„ State Coverage: All internal FSM states and transitions
  • โš ๏ธ Error Coverage: All error conditions and recovery scenarios
  • ๐ŸŽช Cross Coverage: Instruction ร— operand ร— state combinations

๐Ÿ› ๏ธ Usage

๐ŸŽฎ Running Individual Tests

Each instruction has dedicated test sequences and test cases:

# Test Zbb Extension Instructions
make TEST_NAME=bmu_clz_test run_sim        # Count leading zeros
make TEST_NAME=bmu_cpop_test run_sim       # Population count
make TEST_NAME=bmu_min_test run_sim        # Minimum operation
make TEST_NAME=bmu_siext_h_test run_sim    # Sign extend halfword
make TEST_NAME=bmu_and_test run_sim        # AND/ANDN operations
make TEST_NAME=bmu_xor_test run_sim        # XOR/XNOR operations

# Test Zbs Extension Instructions
make TEST_NAME=bmu_bext_test run_sim       # Bit extract

# Test Zbp Extension Instructions
make TEST_NAME=bmu_rol_test run_sim        # Rotate left
make TEST_NAME=bmu_packu_test run_sim      # Pack upper halves
make TEST_NAME=bmu_gorc_test run_sim       # Generalized OR-combine

# Test Zba Extension Instructions
make TEST_NAME=bmu_sh3add_test run_sim     # Shift-add-3

# Test Basic Operations
make TEST_NAME=bmu_add_test run_sim        # Addition
make TEST_NAME=bmu_sll_test run_sim        # Shift left logical
make TEST_NAME=bmu_sra_test run_sim        # Shift right arithmetic
make TEST_NAME=bmu_slt_test run_sim        # Set less than

๐ŸŽ›๏ธ Running Full Regression

To execute the complete regression suite covering all instructions and scenarios:

make all

๐Ÿ“ˆ Results

Coming soon: Detailed coverage reports and performance metrics.

๐Ÿš€ Future Expansion Opportunities

  • Additional Zbb instructions (CTZ, MAX, SEXT.B, ORN)
  • Remaining Zbs instructions (BSET, BCLR, BINV)
  • Additional Zbp instructions (ROR, PACK, PACKH, GREV)
  • Additional Zba instructions (SH1ADD, SH2ADD)

Made with SystemVerilog UVM Methodology RISC-V Compatible

About

UVM-based verification environment for RISC-V Bit Manipulation Unit (BMU) covering key BitManip instructions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors