Simulation Overview
Kathryn support 2 major types of simulation method as followed:
-
Hybrid simulation
-
manual simulate HDL generated file
-
aspect Hybrid Simulation manual simulation performance medium-high n/a co-simulate yes no high-level model accessibility yes no zero-effort profiler yes no -
Performance is tested using simple riscv 4 stage pipeline with merge sort workload. (see more in publication section)
-
co-simulation: Kathryn provides the cycle-accurate base simulation which can be co-simulate with arbitary user define simulation or other other framework like gem5.
1. Hybrid simulator
-
The Hybrid Simulator (HS) is the cycle-accurate level hardware simulator that inter-simulates various types of simulation; moreover, HS aims to bridge the gap between performance and maintaining high-level structure context by using model recompile and link back technique. This technique allows designers to accesses the high-level structure that they wrote in Kathryn while achieving performance close to compiled simulator
-
Hybrid Simulator structure diagram
-
- Model Compiler is the component that compile User model to shared object (.so file).
-
- Model SimEvent is the wrapper of compiled model.
-
- Model UserEvent and RealTimeEvent is the user defined simulation event (SE)
-
- SimController controls simulation Queue and simulation event during simulation time.
-
- Simulation Queue is the sorted queue for simulation event (priority queue) so SimController will fetch the queue for simulation cycle by cycle. If some cycle that there is no simEvent, the queue will be skipped.
-
Example simulation code
-
#include "kathryn.h" using namespace kathryn; class ExModule: public Module{ ///// your code mReg(a, 8); }; class mySim :public SimAutoInterface{ public: testSimMod29* _md; mySim(ExModule* md, int idx):SimAutoInterface(idx,200, ///// limit cycle "vcdFilePath","profilerFilePath"),_md(md){} void describeCon() override{ conNextCycle(6); for(int i =1; i <= 48; i++){ if (i % 10 == 1) testAndPrint("check intr par a start", ull(_md->a),i); conNextCycle(1); } } }; int main(int argc, char* argv[]){ //// first input operand must be the parameter file path auto params = readParamKathryn(argv[1]); mMod(ex, ExModule, 0); startModelKathryn(); mySim simulator(&ex, 0); simulator.startSim(); resetKathryn(); }