Co-Simulation Testbench
A Co-Simulation Testbench is a verification setup that runs an RTL processor core together with an instruction-set simulator (ISS) and compares their behavior while feeding both from a generated instruction stream. In the cited cross-level processor-verification approach, the co-simulation testbench is used to feed an on-the-fly, endless instruction stream to both the ISS and the RTL core. [C1]
Implementation basis
The described testbench is implemented in SystemC and uses TLM (Transaction Level Modeling). TLM is used to provide a unified memory abstraction for the RTL core and the ISS, based on a common standard. [C2]
Communication in the environment may be implemented using signals for RTL models or abstracted through TLM transactions for higher-level algorithmic models. A TLM transaction object contains a command such as read or write, a data payload, and an address. [C3]
Architecture
The RTL core is driven by a clock signal and has separate interfaces for instruction memory and data memory. The memory interfaces translate between RTL core signals and TLM transactions. The ISS is also configured with two separate memory interfaces so that it matches the RTL-side organization. [C4]
The data memory is implemented lazily: it starts empty, stores data on writes, and on reads either returns existing data or generates new random data if the address has not been accessed before. The RTL and ISS data memories use the same random seed so they behave the same when the two sides perform the same data-memory access sequence in the same order. [C5]
Instruction fetching and matching
Instruction fetching is handled through the instruction-memory interface using the program counter (PC). When the RTL core fetches an instruction, the testbench generates a new instruction on the fly, even if the same PC has been fetched before. When the ISS fetches an instruction, it receives the corresponding instruction that was fetched by the RTL core. This correspondence is handled by an instruction stream placed between the instruction generator and the memory interfaces. [C6]
Instruction-stream matching is needed because an RTL pipeline may prefetch several instructions. Some prefetched instructions may not execute if a jump or trap occurs, causing the ISS to fetch a different sequence of PCs than the RTL core. Short jumps or traps can also cause the RTL core to issue a new fetch before the ISS has the opportunity to fetch the corresponding instruction. [C7]
The matching mechanism keeps a queue of pending instructions. If an ISS fetch matches an instruction pending from the RTL side, the instruction is returned; otherwise, the setup reports a mismatch between RTL core and ISS because the ISS attempted to fetch an instruction that was not delivered to the RTL core. [C8]
Core adapter and test controller
The testbench includes a Core Adapter to hide implementation details of the RTL core and expose a clean testing interface. The adapter observes internal signal changes, especially pipeline behavior, and notifies the Test Controller whenever the RTL core completes an instruction. It also preserves the correct order in cases involving illegal instructions. [C9]
The core adapter provides access to RTL register values so they can be compared against the ISS. [C10]
The design deliberately does not directly feed the completed instruction sequence from the core adapter into the ISS, because that would compromise the testing approach: it would rely on the RTL core’s instruction propagation being correct, even though the RTL core is the unit under test. [C11]
Instruction stream generator
The Instruction Stream Generator supports endless generation of unrestricted instructions. Its baseline algorithm fully randomizes generated instructions, forming the foundation of the testing process. The cited design also considers guided modifications to steer generation toward interesting cases. [C12]
One modification injects a random instruction opcode to create a valid instruction while keeping the instruction fields randomized. This is described as simple, generic, and effective, and it helps ensure that a large set of legal instructions is considered. [C13]
Role in verification
The overall goal of the co-simulation testbench is to support cross-level processor verification by comparing an RTL core and ISS under a shared instruction stream while accounting for pipeline effects, memory behavior, and instruction-fetch ordering. [C1] [C7] [C9]