Skip to content

Commit

Permalink
[difftest] add zstd for all event log
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Jun 17, 2024
1 parent 308a4d5 commit 7f20bf4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
ammonite
# To develop T1-script, run nix develop .#t1-script.withLsp
t1-script
zstd
];
};
};
Expand Down
47 changes: 27 additions & 20 deletions script/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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",
Expand All @@ -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}"
)
Expand Down
6 changes: 5 additions & 1 deletion tests/make-emu-result.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CallPackage args
{ runCommand
, zstd
, t1-script
, ip-emu
, elaborateConfigJson
Expand All @@ -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"
Expand All @@ -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
''

0 comments on commit 7f20bf4

Please sign in to comment.