diff --git a/flake.nix b/flake.nix index 44c0f1279..089dbbb23 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,7 @@ ammonite # To develop T1-script, run nix develop .#t1-script.withLsp t1-script + zstd ]; }; }; diff --git a/script/src/Main.scala b/script/src/Main.scala index 604c7e437..8cf2b5894 100644 --- a/script/src/Main.scala +++ b/script/src/Main.scala @@ -745,27 +745,25 @@ object Main: @main def difftest( - @arg( - name = "config", - short = 'c', - doc = "specify the elaborate config for running test case" - ) config: String, - @arg( - name = "case-attr", - short = 'C', - doc = "Specify test case attribute to run diff test" - ) caseAttr: String, - @arg( - name = "log-level", - short = 'L', - doc = "Specify log level to run diff test" - ) logLevel: String + @arg( + name = "config", + short = 'c', + doc = "specify the elaborate config for running test case" + ) config: String, + @arg( + name = "case-attr", + short = 'C', + doc = "Specify test case attribute to run diff test" + ) caseAttr: String, + @arg( + name = "log-level", + short = 'L', + doc = "Specify log level to run diff test" + ) logLevel: String = "ERROR" ): Unit = - Logger.info("Building simulator") val difftest = nixResolvePath(".#t1-simulator") val fullCaseAttr = s".#t1.${config}.cases.${caseAttr}" - Logger.info(s"Building cases ${fullCaseAttr}") val caseElf = nixResolvePath(fullCaseAttr) import scala.util.chaining._ @@ -775,11 +773,20 @@ object Main: .pipe(text => ujson.read(text)) val dLen = configJson.obj("parameter").obj("dLen").num.toInt val vLen = configJson.obj("parameter").obj("vLen").num.toInt - Logger.info(s"Using DLEN ${dLen}, VLEN ${vLen}") - Logger.info(s"Running emulator to get event log") + Logger.trace(s"Running emulator to get event log") val eventLog = nixResolvePath(s"${fullCaseAttr}.emu-result") + Logger.trace("Running zstd to get event log") + os.proc(Seq( + "zstd", + "--decompress", + "-f", + s"${eventLog}/rtl-event.log.zstd", + "-o", + s"${config}-${caseAttr}.event.log" + )).call(stdout = os.Inherit, stderr = os.Inherit) + Logger.info(s"Starting t1-simulator with DLEN ${dLen}, VLEN ${vLen} for ${fullCaseAttr}") os.proc( Seq( s"${difftest}/bin/t1-simulator", @@ -790,7 +797,7 @@ object Main: "--elf-file", s"${caseElf}/bin/${caseAttr}.elf", "--log-file", - s"${eventLog}/rtl-event.log", + s"${config}-${caseAttr}.event.log", "--log-level", s"${logLevel}" ) diff --git a/tests/make-emu-result.nix b/tests/make-emu-result.nix index 678baee73..5aa2070a3 100644 --- a/tests/make-emu-result.nix +++ b/tests/make-emu-result.nix @@ -1,5 +1,6 @@ # CallPackage args { runCommand +, zstd , t1-script , ip-emu , elaborateConfigJson @@ -8,7 +9,7 @@ # makeEmuResult arg testCase: -runCommand "get-emu-result" { } '' +runCommand "get-emu-result" { nativeBuildInputs = [ zstd ]; } '' echo "[NIX] Running test case ${testCase.pname}" mkdir -p "$out" @@ -30,4 +31,7 @@ runCommand "get-emu-result" { } '' else printf "1" > $out/emu-success fi + + zstd $out/rtl-event.log -o $out/rtl-event.log.zstd + rm $out/rtl-event.log ''