Skip to content

Commit

Permalink
[nix] make trace and cover orthogonal
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed Oct 5, 2024
1 parent 2697bc9 commit ee14e96
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
16 changes: 12 additions & 4 deletions nix/t1/conversion/sv-to-vcs-simulator.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ stdenv.mkDerivation rec {
# require license
__noChroot = true;
dontPatchELF = true;
enableCover = !enableTrace;

src = rtl;

Expand All @@ -30,6 +31,8 @@ stdenv.mkDerivation rec {
"-timescale=1ns/1ps"
"-file"
"filelist.f"
]
++ lib.optionals (enableCover) [
"-cm"
"line+cond+fsm+tgl+branch+assert"
"-cm_dir"
Expand Down Expand Up @@ -69,16 +72,21 @@ stdenv.mkDerivation rec {
mkdir -p $out/bin $out/lib
cp $mainProgram $out/lib
cp -r $mainProgram.daidir $out/lib
cp -r ./cm.vdb $out/lib
${lib.optionalString enableCover ''
cp -r ./cm.vdb $out/lib
''}
# We need to carefully handle string escape here, so don't use makeWrapper
tee $out/bin/$mainProgram <<EOF
#!${bash}/bin/bash
export LD_LIBRARY_PATH="$out/lib/$mainProgram.daidir:\$LD_LIBRARY_PATH"
_argv="\$@"
cp -r $out/lib/cm.vdb ./cm.vdb
chmod +w -R ./cm.vdb
${vcs-fhs-env}/bin/vcs-fhs-env -c "$out/lib/$mainProgram -cm_dir ./cm.vdb \$_argv"
${lib.optionalString enableCover ''
cp -r $out/lib/cm.vdb ./cm.vdb
chmod +w -R ./cm.vdb
''}
${vcs-fhs-env}/bin/vcs-fhs-env -c "$out/lib/$mainProgram ${lib.optionalString enableCover ''-cm_dir ./cm.vdb''} \$_argv"
EOF
chmod +x $out/bin/$mainProgram
Expand Down
9 changes: 6 additions & 3 deletions nix/t1/run/run-vcs-emu.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ stdenvNoCC.mkDerivation (finalAttr: {
name = "${testCase.pname}-vcs-result" + (lib.optionalString emulator.enableTrace "-trace");
nativeBuildInputs = [ zstd jq ];
__noChroot = true;
enableCover = !emulator.enableTrace;

passthru.caseName = testCase.pname;

Expand All @@ -15,7 +16,7 @@ stdenvNoCC.mkDerivation (finalAttr: {
emuDriverArgsArray=(
"+t1_elf_file=${testCase}/bin/${testCase.pname}.elf"
${lib.optionalString emulator.enableTrace "+t1_wave_path=${testCase.pname}.fsdb"}
"-cm assert"
${lib.optionalString enableCover "-cm assert"}
)
emuDriverArgs="''${emuDriverArgsArray[@]}"
emuDriver="${emulator}/bin/${emulator.mainProgram}"
Expand Down Expand Up @@ -79,8 +80,10 @@ stdenvNoCC.mkDerivation (finalAttr: {
mv perf.json $out/
fi
cp -v cm.log "$out"
cp -vr cm.vdb "$out"
${lib.optionalString enableCover ''
cp -v cm.log "$out"
cp -vr cm.vdb "$out"
''}
${lib.optionalString emulator.enableTrace ''
cp -v ${testCase.pname}.fsdb "$out"
Expand Down
2 changes: 1 addition & 1 deletion script/emu/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ object Main:
)

val isTrace = finalEmuType.get.contains("-trace")
val isCover = isTrace
val isCover = !isTrace

val finalConfig = tryRestoreFromCache("config", config)
if finalConfig.isEmpty then
Expand Down

0 comments on commit ee14e96

Please sign in to comment.