User Book
Simulation Section
3.Sim Procedure And Micro Optimization

Simulation Interface

According to the model recompile and link back technique, Kathryn optimizes the simulation model by collecting model data, generating to C++, recompiling model, and then linking back to main model.

  • Sometimes, designers who linked model may encounter the low performance from context switching between the model and the simulation event(other simulation context)

  • Kathryn allows designers to directly inject their simulation code after the C++ simulation model is generated.

  • To do that, designers should pause the procedure before recompliing model stage.

  •   class SimInterface{
          
        explicit SimInterface(CYCLE limitCycle,
                                std::string vcdFilePath,
                                std::string profileFilePath,
                                std::string genFileName = "proxySimAutoGen.cpp",
                                SimProxyBuildMode simProxyBuildMode =
                                  SimProxyBuildMode::SPB_GEN |
                                  SimProxyBuildMode::SPB_COMPILE |
                                  SimProxyBuildMode::SPB_RUN
                                );
      };
  • At first time, designers may run the framework by specifying SimProxyBuildMode parameter only SPB_GEN in SimInterface (mentioned in previous section), then Kathryn will stop when the model is generated only. (not compile and run the model)

  • After that designeres may modify the C++ code named genFileName in modelCompile/generated/<genFileName>.cpp

  • Designers will see the function userDefUserSke. this function will be invoked every cycle design may put their code there.

  • Moreover, Kathryn will preserves the code between keyword KDMD_*. When the simulation model is regenerated, the code between the keyword will be saved and placed in the new file.

  • After modifying the simulation code, designers may start the Kathryn with SimProxyBuildMode parameter only SPB_COMPILE and SPB_RUN.

  •   //modelCompile/generated/<genFileName>.cpp
      __attribute__((always_inline)) inline void userDefUserSke(){
      
      //KDMD_manualDesigner
     
     
     
       //you may put the code between KDMD_ and KDMD_EN D the code will be not deleted
     
     
      //KDMD_END
      }