Skip to content
STIMSMITH

init_gpr

CodeArtifact WIKI v1 · 5/26/2026

init_gpr is a function in the riscv_asm_program_gen assembly-generation flow of the CHIPS Alliance riscv-dv RISC-V random instruction generator. In the documented gen_program() sequence, init_gpr() is called after program-header generation and initializes RISC-V general-purpose registers with random values.

Overview

init_gpr is a code artifact referenced as part of the riscv_asm_program_gen SystemVerilog assembly-program generation flow in the CHIPS Alliance open-source riscv-dv random instruction generator for RISC-V processor verification. The broader riscv_asm_program_gen class is described as generating the complete RISC-V assembly program used to verify RISC-V IP, including initialization, instruction, data, stack, page-table, interrupt, and exception-handling sections. [C1]

Role in program generation

Within the documented gen_program() flow, init_gpr() is invoked after gen_program_header() has generated the program header and inserted the _start section through gen_section("_start", str). [C2]

The stated functionality of init_gpr() is to initialize general-purpose registers with random values. [C3]

Placement in the generation sequence

The relevant portion of the documented generation sequence is:

  1. gen_program() is called as the main function that generates all sections of the program. [C4]
  2. gen_program() calls get_directed_instr_stream() and uses add_directed_instr_stream() to select directed-instruction ratios. [C5]
  3. gen_program_header() populates the instruction stream with header content and calls gen_section("_start", str). [C2]
  4. gen_program() calls init_gpr() to initialize GPRs with random values. [C3]
  5. Directed and random instruction streams are then generated, including selection of rs1, rs2, and rd based on instruction type, producing assembly that uses GPRs x0 through x31. [C6]

Technical significance

init_gpr() contributes to the initialization routine of generated RISC-V assembly tests. Because later generated instructions use a variety of RISC-V general-purpose registers, initializing GPRs with random values provides randomized register state before instruction-stream generation proceeds. The available evidence identifies the purpose and call placement of init_gpr() but does not provide its implementation body or the exact assembly emitted by the function. [C3]

CITATIONS

6 sources
6 citations
[1] The CHIPS Alliance riscv-dv generator is an open-source RISC-V random instruction generator for processor verification, and riscv_asm_program_gen generates complete RISC-V assembly programs with sections such as initialization, instruction, data, stack, page table, interrupt, and exception handling. RISC-V source class riscv_asm_program_gen, the brain behind ...
[2] gen_program_header() fills the instruction stream with header content and calls gen_section("_start", str). RISC-V source class riscv_asm_program_gen, the brain behind ...
[3] gen_program() calls init_gpr(), whose functionality is to initialize general-purpose registers with random values. RISC-V source class riscv_asm_program_gen, the brain behind ...
[4] gen_program() is the main function that generates all sections of the program by calling other riscv_asm_program_gen functions. RISC-V source class riscv_asm_program_gen, the brain behind ...
[5] gen_program() calls get_directed_instr_stream(), and add_directed_instr_stream() is used to select the ratio of directed instruction generation. RISC-V source class riscv_asm_program_gen, the brain behind ...
[6] After init_gpr(), directed instruction stream generation randomizes instructions and selects rs1, rs2, and rd based on instruction type, producing assembly using GPRs x0 through x31. RISC-V source class riscv_asm_program_gen, the brain behind ...