Skip to content
STIMSMITH

Instruction Registry

Concept WIKI v1 · 5/26/2026

An instruction registry is the RISCV-DV/eUVM mechanism for registering RISC-V instruction types with the instruction generator. In the eUVM port, registry state and related functions are refactored from static variables into a dedicated `riscv_instr_registry` class to better fit multi-threaded execution and D-language concurrency semantics.

Overview

In the RISCV-DV/eUVM context, the Instruction Registry is a registry mechanism used to register RISC-V instructions with the instruction generator. The eUVM RISCV-DV port introduces a dedicated class named riscv_instr_registry specifically for this purpose, moving registry-related static state and functions out of the original SystemVerilog instruction class implementation.

Purpose

The original RISCV-DV SystemVerilog code contained statically scoped variables in riscv_instr.sv; these variables served the purpose of registering RISC-V instructions with the instruction generator. In the eUVM port, these variables and their related functions are refactored into the riscv_instr_registry class.

This refactoring addresses concurrency concerns. The cited DVCon paper notes that global or statically scoped variables can hurt runtime efficiency in concurrent software because shared access must be synchronized to avoid race conditions. Encapsulating the instruction-registration state in a class helps align the design with the concurrency semantics of the D programming language used by eUVM.

Singleton placement

Although the registry state is moved out of static variables, the eUVM port preserves the singleton nature of the original SystemVerilog design. An instance of riscv_instr_registry is created inside the singleton riscv_instr_gen_config class, preserving behavior similar to the original static-variable implementation.

Relationship to instruction creation

RISCV-DV implements each RISC-V ISA instruction as a separate class. Because this requires hundreds of instruction classes, registering all of them with the standard UVM Factory would make factory-based creation slow. The paper explains that the UVM Factory supports features such as type and instance overrides, but internally maintains complex data structures and performs class-name matching against registered classes during creation.

To accelerate instruction generation, RISCV-DV uses a custom factory. The custom factory includes an instr_registry mapping in which register(riscv_instr_name_t instr_name, string qualified_name) stores the association between an instruction enum value and a qualified class name. A create_instr_list() routine iterates over the registry, skips unsupported instructions, creates instruction instances, and stores them in instr_template.

Performance characteristic

The custom factory uses the riscv_instr_name_t enumeration to tag each instruction as a numeric value. Because the factory objects are hashed using this enumeration, matching is faster when instruction objects are created than name-based matching through the UVM Factory registration database.

CITATIONS

8 sources
8 citations
[1] RISCV-DV SystemVerilog used statically scoped variables in riscv_instr.sv for registering RISC-V instructions with the instruction generator. [PDF] Crafting a Million Instructions/Sec RISCV-DV - DVCon Proceedings
[2] The eUVM RISCV-DV port refactors the instruction-registration variables and related functions into a separate class named riscv_instr_registry. [PDF] Crafting a Million Instructions/Sec RISCV-DV - DVCon Proceedings
[3] The registry refactoring supports concurrent execution concerns because global or statically scoped variables accessed by multiple threads require synchronization to avoid race conditions. [PDF] Crafting a Million Instructions/Sec RISCV-DV - DVCon Proceedings
[4] An instance of riscv_instr_registry is created inside singleton riscv_instr_gen_config, preserving the singleton nature of the original static variables. [PDF] Crafting a Million Instructions/Sec RISCV-DV - DVCon Proceedings
[5] RISCV-DV implements each RISC-V ISA instruction as a separate class, leading to hundreds of registered classes. [PDF] Crafting a Million Instructions/Sec RISCV-DV - DVCon Proceedings
[6] The UVM Factory becomes slow when many types are registered because create operations require matching class names against registered class names. [PDF] Crafting a Million Instructions/Sec RISCV-DV - DVCon Proceedings
[7] RISCV-DV uses a custom factory with an instr_registry mapping from riscv_instr_name_t instruction names to qualified class names, and create_instr_list uses the registry to create and template instruction instances. [PDF] Crafting a Million Instructions/Sec RISCV-DV - DVCon Proceedings
[8] RISCV-DV uses riscv_instr_name_t as an enumeration tag for instructions, allowing the custom factory to hash factory objects by enumeration and perform faster matching during instruction-object creation. [PDF] Crafting a Million Instructions/Sec RISCV-DV - DVCon Proceedings