diff --git a/lib/Dialect/ESI/runtime/cosim_dpi_server/driver.cpp b/lib/Dialect/ESI/runtime/cosim_dpi_server/driver.cpp index a94bd761b6c7..155edf84cd39 100644 --- a/lib/Dialect/ESI/runtime/cosim_dpi_server/driver.cpp +++ b/lib/Dialect/ESI/runtime/cosim_dpi_server/driver.cpp @@ -34,6 +34,7 @@ #include "signal.h" #include +#include vluint64_t timeStamp; @@ -54,6 +55,14 @@ int main(int argc, char **argv) { auto &dut = *new CLASSNAME(V, TOP_MODULE)(); char *waveformFile = getenv("SAVE_WAVE"); + char *periodStr = getenv("DEBUG_PERIOD"); + unsigned debugPeriod = 0; + if (periodStr) { + debugPeriod = std::stoi(periodStr); + std::cout << "[driver] Setting debug period to " << debugPeriod + << std::endl; + } + VerilatedVcdC *tfp = nullptr; if (waveformFile) { #ifdef TRACE @@ -97,6 +106,8 @@ int main(int argc, char **argv) { dut.clk = !dut.clk; if (tfp) tfp->dump(timeStamp); + if (debugPeriod) + std::this_thread::sleep_for(std::chrono::milliseconds(debugPeriod)); } // Tell the simulator that we're going to exit. This flushes the output(s) and diff --git a/lib/Dialect/ESI/runtime/cosim_dpi_server/esi-cosim.py b/lib/Dialect/ESI/runtime/cosim_dpi_server/esi-cosim.py index 61c742c74c6b..d4f611cf7f14 100755 --- a/lib/Dialect/ESI/runtime/cosim_dpi_server/esi-cosim.py +++ b/lib/Dialect/ESI/runtime/cosim_dpi_server/esi-cosim.py @@ -157,6 +157,8 @@ def run(self, inner_command: str, gui: bool = False) -> int: simEnv = Simulator.get_env() if self.debug: simEnv["COSIM_DEBUG_FILE"] = "cosim_debug.log" + # Slow the simulation down to one tick per millisecond. + simEnv["DEBUG_PERIOD"] = "1" simProc = subprocess.Popen(self.run_command(gui), stdout=simStdout, stderr=simStderr,