Overview
get_directed_instr_stream() is documented as part of the gen_program() execution flow in riscv_asm_program_gen.sv, the SystemVerilog UVM-based assembly program generator used by the CHIPS Alliance riscv-dv random instruction generator for RISC-V processor verification. The surrounding riscv_asm_program_gen class generates the complete RISC-V assembly program, including initialization, instruction, data, stack, page-table, interrupt, and exception-handling sections.
Role in program generation
Within gen_program(), get_directed_instr_stream() is called early in the generation sequence. The source describes gen_program() as the main function that generates all sections of the program and calls other riscv_asm_program_gen functions one by one. After gen_program() is invoked from an upper layer, it calls get_directed_instr_stream() and uses add_directed_instr_stream() to select the ratio of directed instruction generation.
The article gives an example log message for adding a directed instruction stream:
riscv_asm_program_gen.sv(1552) @ 0: reporter [asm_gen] Adding directed instruction stream:riscv_jal_instr ratio: 30/1000
This indicates that directed streams can be added with explicit generation ratios, such as a riscv_jal_instr stream at 30/1000.
Position in the surrounding flow
The documented generation flow around get_directed_instr_stream() is:
gen_program()is called as the main assembly-program generation entry point.get_directed_instr_stream()is called.- Directed-instruction generation ratios are selected via
add_directed_instr_stream(). gen_program_header()is called to populate the instruction stream with header content.init_gpr()initializes general-purpose registers with random values.generate_directed_instr_stream()later decides ratios, inserts directed instruction streams, and randomizes instructions, including register selection forrs1,rs2, andrdaccording to instruction type.
Relationship to directed instruction generation
The evidence distinguishes get_directed_instr_stream() from generate_directed_instr_stream(). get_directed_instr_stream() appears in the setup phase where directed streams and their ratios are selected, while generate_directed_instr_stream() is later described as deciding the ratio, inserting the directed instruction stream, and randomizing instructions. The latter also selects source and destination registers based on instruction type and contributes to assembly using GPRs x0 through x31.
Verification context
The function exists in the broader riscv-dv context, where random assembly tests are generated for RISC-V IP verification. The generator configuration is randomized through riscv_instr_gen_config from riscv_instr_base_test.sv, determining features such as supported RISC-V extensions, privilege mode, instruction counts, and whether to generate instructions such as ebreak, dret, fence, or wfi.