Skip to content
STIMSMITH

gen_program_header

CodeArtifact WIKI v1 · 5/26/2026

gen_program_header is a function in the riscv_asm_program_gen assembly-program generation flow. It is called by gen_program(), populates the instr_stream string array with program header content, and delegates insertion of the _start section to gen_section("_start", str).

Overview

gen_program_header is part of the riscv_asm_program_gen.sv assembly generation flow used in CHIPS Alliance's open-source riscv-dv random instruction generator for RISC-V processor verification. The surrounding riscv_asm_program_gen class generates complete RISC-V assembly programs, including sections such as initialization routines, instruction sections, data sections, stack sections, page tables, and interrupt/exception handling. [C1]

Role in the generation flow

gen_program() is described as the main function that generates all sections of the assembly program and calls functions in riscv_asm_program_gen one by one. In that flow, gen_program() calls gen_program_header() after directed-instruction stream setup. [C2]

gen_program_header() uses the string array instr_stream to fill in header content. The evidence gives an example header output:

.include "user_init.s"

[C3]

Section insertion

gen_program_header() calls:

gen_section("_start", str)

This call inserts header instructions into instr_stream. [C4]

Surrounding sequence

Within the documented gen_program() sequence, the header generation step occurs before init_gpr(), which initializes general-purpose registers with random values. Later steps generate directed instruction streams, convert instruction streams to assembly string format, optionally insert subprograms, and add host-interface related instructions. [C5]

Practical significance

Within the evidence-provided flow, gen_program_header() is the step responsible for establishing the generated assembly program's header content and _start section before register initialization and instruction-stream generation proceed. [C2][C3][C4][C5]

CITATIONS

5 sources
5 citations
[1] riscv_asm_program_gen is part of CHIPS Alliance's open-source riscv-dv generator and generates complete RISC-V assembly programs with multiple sections. RISC-V source class riscv_asm_program_gen, the brain behind ...
[2] gen_program() is the main assembly-program generation function and calls gen_program_header() during its sequence. RISC-V source class riscv_asm_program_gen, the brain behind ...
[3] gen_program_header() uses the instr_stream string array to fill header content, with an example output of .include "user_init.s". RISC-V source class riscv_asm_program_gen, the brain behind ...
[4] gen_program_header() calls gen_section("_start", str), which inserts header instructions into instr_stream. RISC-V source class riscv_asm_program_gen, the brain behind ...
[5] After gen_program_header(), the documented gen_program() flow calls init_gpr(), generates directed instruction streams, converts instruction streams to assembly string format, optionally inserts subprograms, and adds host-interface instructions. RISC-V source class riscv_asm_program_gen, the brain behind ...