Skip to content

Commit

Permalink
[script] let daidir copied before emulator start
Browse files Browse the repository at this point in the history
We need this to allow user interrupt the emulator run but still have
proper trace required files.

Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin authored and sequencer committed Sep 5, 2024
1 parent 24a4b34 commit 7c44541
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions script/emu/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 =
Expand All @@ -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

Expand Down

0 comments on commit 7c44541

Please sign in to comment.