Overview
Instruction Stream Generation is a test-generation technique for processor verification in which streams of instructions are produced and supplied to a processor model, simulator, or RTL core. In the provided RISC-V cross-level verification evidence, the stated goal is to generate an endless and unrestricted instruction stream for co-simulation, with the RTL core and instruction-set simulator (ISS) expected to behave identically in their observable architectural state, especially register updates. [c1]
Role in RISC-V verification
The evidence discusses instruction stream generation in the context of RISC-V. RISC-V includes mandatory base integer instruction sets such as RV32I, RV64I, and RV128I, plus optional extensions such as M for integer multiplication/division and C for compressed instructions. Instructions are grouped into classes such as computational, load/store, and branch/jump, and use register operands and immediates. [c2]
For the verification setup described in the evidence, unrestricted generation is intended to exercise broad processor behavior. The approach supports memory-access instructions, jump instructions including self-loops from on-the-fly generation, and special RISC-V CSR access instructions. [c3]
Generation strategy
The baseline generator described in the evidence fully randomizes generated instructions. This creates a foundation for testing because unrestricted generation can include legal and illegal encodings. A figure in the evidence notes that a fully random 32-bit word is most likely an illegal instruction. [c4]
The evidence also describes guided modifications to steer generation toward interesting cases. One such modification injects a random instruction opcode to create a valid instruction while keeping the remaining instruction fields randomized. This is described as simple, generic, effective, and important for ensuring that a large set of legal instructions is considered. [c5]
Co-simulation and instruction matching
Unrestricted instruction streams introduce a synchronization problem when the same stream must be supplied to both an RTL core and an ISS. A pipelined RTL core can prefetch instructions, but prefetched instructions may not execute after jumps or traps. As a result, the ISS may fetch a different sequence of program counters than the RTL core if matching is handled naively. [c6]
The evidence describes an instruction matching algorithm that stores generated instructions, together with their program counters, in a queue of pending instructions fetched by the RTL core but not yet consumed by the ISS. The ISS fetch path then searches this pending queue for a matching (PC, instruction) pair. If a match is found, the instruction is returned; otherwise, a mismatch is reported. [c7]
RTL completion detection
The evidence identifies instruction-completion detection in a pipelined RTL core as a key implementation challenge. Illegal instructions may bypass pipeline stages and may not trigger regular register write-back notifications. Pipeline flushes, jumps, traps, and multi-cycle operations can also introduce delays and gaps. To address this, the described setup uses a core adapter that observes internal core signal changes, especially pipeline signals, and notifies the test controller when the RTL core completes an instruction while preserving correct order for illegal instructions. [c8]
Comparison with other generation approaches
The evidence contrasts unrestricted generation with several existing RISC-V test-generation approaches:
- RISC-V Torture Test is described as a Scala-based framework that generates tests from randomized instruction-sequence templates and supports several RISC-V ISA extensions. However, approaches based on predefined instruction-sequence building blocks are said to have limited coverage and to not support illegal instructions or exceptions. [c9]
- Coverage-guided fuzzing at the ISS level loosens some instruction-stream generation restrictions but is reported to have problems with branches and jumps, platform-dependent CSR and memory accesses, and to produce comparatively small test suites. [c10]
- RISC-V DV continuously generates RISC-V instruction streams from constrained-random descriptions, with each instruction stream representing a test case. The evidence says it supports many features including ISA extensions and CSR testing, but generated streams are restricted to avoid infinite loops and platform-dependent memory access operations. [c11]
Practical significance
Within the cited co-simulation setup, Instruction Stream Generation is significant because unrestricted on-the-fly generation can exercise legal instructions, illegal instructions, memory behavior, jumps, traps, and CSR accesses. The matching and core-adapter mechanisms are necessary to make this practical for pipelined RTL cores and ISS comparison without relying on the RTL core under test to define the executed stream. [c1] [c3] [c7] [c8]