Overview
General purpose register initialization refers to the init_gpr() step in the riscv_asm_program_gen assembly-generation flow. In the described riscv-dv flow, gen_program() generates the sections of a complete RISC-V assembly program and, after generating the program header, calls init_gpr() to initialize general purpose registers with random values. [General purpose register initialization in gen_program]
Role in riscv-dv program generation
The evidence places GPR initialization inside the broader riscv_asm_program_gen.sv class, which generates complete RISC-V assembly programs used to verify RISC-V IP. The generated program may include sections such as the initialization routine, instruction section, data section, stack section, page table, and interrupt and exception handling. [riscv_asm_program_gen generates assembly sections]
Within gen_program(), the flow described is:
- Call directed-instruction stream setup functions such as
get_directed_instr_stream()andadd_directed_instr_stream(). - Generate the program header through
gen_program_header(). - Insert the
_startsection throughgen_section("_start", str). - Call
init_gpr()to initialize general purpose registers with random values. - Generate directed and randomized instruction streams. [gen_program call sequence]
Interaction with instruction generation
After init_gpr() is called, the flow proceeds to generate_directed_instr_stream(), which decides ratios, inserts directed instruction streams, and randomizes instructions. The instruction-randomization step selects which rs1, rs2, and rd registers to use based on instruction type. The resulting assembly program uses various GPRs x0 to x31 across instructions, with post_random() in riscv_instr helping this process. [Instruction generation uses GPR operands]
Configuration context
Before program generation, riscv_instr_gen_config is randomized from riscv_instr_base_test.sv. That randomization determines configuration parameters such as the RISC-V extension, supported privilege mode, instruction counts in the main program and subprogram, and whether particular instructions such as break, debug-return, fence, or wait-for-interrupt instructions are generated. These configuration choices establish the broader environment in which GPR initialization and instruction generation occur. [Configuration before program generation]
Customization relevance
The source states that the riscv_asm_program_gen.sv class can address customization to RISC-V GPR or instruction. Therefore, GPR initialization is part of a generator architecture that is intended to be configurable for RISC-V processor verification use cases. [GPR customization support]