From 7c44541dd121b13e34ac2bc693e518b6e0b2d7c3 Mon Sep 17 00:00:00 2001 From: Avimitin Date: Thu, 5 Sep 2024 15:36:26 +0800 Subject: [PATCH] [script] let daidir copied before emulator start We need this to allow user interrupt the emulator run but still have proper trace required files. Signed-off-by: Avimitin --- script/emu/src/Main.scala | 47 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/script/emu/src/Main.scala b/script/emu/src/Main.scala index efa6f13ac..d8b05c1a7 100644 --- a/script/emu/src/Main.scala +++ b/script/emu/src/Main.scala @@ -206,32 +206,13 @@ object Main: ++ optionals(isTrace, Seq(s"+t1_wave_path=${outputPath / "wave.fsdb"}")) ++ optionals(!leftOverArguments.isEmpty, leftOverArguments) - Logger.info(s"Starting IP emulator: `${processArgs.mkString(" ")}`") if dryRun.value then return val rtlEventPath = outputPath / "rtl-event.jsonl.zst" val journalPath = outputPath / "online-drive-emu-journal" - val driverProc = os - .proc(processArgs) - .spawn( - stdout = journalPath, - stderr = os.Pipe, - env = optionalMap(verbose.value, Map("RUST_LOG" -> "TRACE")) - ) - val zstdProc = os - .proc(Seq("zstd", "-o", s"${rtlEventPath}")) - .spawn( - stdin = driverProc.stderr, - stdout = os.Inherit, - stderr = os.Inherit - ) + val statePath = outputPath / "driver-state.json" - zstdProc.join(-1) - driverProc.join(-1) - if zstdProc.exitCode() != 0 then Logger.fatal("fail to compress data") - if driverProc.exitCode() != 0 then Logger.fatal("online driver run failed") - - val statePath = outputPath / "driver-state.json" + // Save information of this run, so that user can start offline check without arguments os.write( statePath, ujson.write( @@ -243,6 +224,7 @@ object Main: ) ) + // For vcs trace simulator, we need daidir keep at same directory as the wave.fsdb file if finalEmuType.get == "vcs-emu-trace" then val libPath = emulator / os.up / os.up / "lib" val daidirPath = @@ -253,6 +235,29 @@ object Main: val daidirName = daidirPath.segments.toSeq.last os.symlink(outputPath / daidirName, daidirPath) + Logger.info(s"Starting IP emulator: `${processArgs.mkString(" ")}`") + + val driverProc = os + .proc(processArgs) + .spawn( + stdout = journalPath, + stderr = os.Pipe, + env = optionalMap(verbose.value, Map("RUST_LOG" -> "TRACE")) + ) + val zstdProc = os + .proc(Seq("zstd", "-o", s"${rtlEventPath}")) + .spawn( + stdin = driverProc.stderr, + stdout = os.Inherit, + stderr = os.Inherit + ) + + zstdProc.join(-1) + driverProc.join(-1) + if zstdProc.exitCode() != 0 then Logger.fatal("fail to compress data") + if driverProc.exitCode() != 0 then Logger.fatal("online driver run failed") + + Logger.info("Driver finished") Logger.info(s"Output saved under ${outputPath}") end run