Skip to content

Commit

Permalink
[nix] add cover flow support
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed Oct 2, 2024
1 parent 0f84e26 commit e7ba09d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
10 changes: 8 additions & 2 deletions nix/t1/conversion/sv-to-vcs-simulator.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{ mainProgram
, rtl
, enableTrace ? false
, enableCover ? false
, vcsLinkLibs ? [ ]
}:

Expand Down Expand Up @@ -35,9 +36,14 @@ stdenv.mkDerivation rec {
"+define+T1_ENABLE_TRACE"
"-debug_access+pp+dmptf+thread"
"-kdb=common_elab,hgldd_all"
] ++ [
]
++ lib.optionals (enableCover) [
"-cm_dir"
"/tmp/cm"
"./cm"
]
++ lib.optionals (!enableCover) [
"-assert"
"disable_cover"
]
++ vcsLinkLibs;

Expand Down
2 changes: 2 additions & 0 deletions nix/t1/run/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
, verilator-emu-trace
, vcs-emu
, vcs-emu-trace
, vcs-emu-trace-cover
, cases
, configName
}:
Expand All @@ -31,6 +32,7 @@ let
verilator-emu-trace = runVerilatorEmu verilator-emu-trace case;
vcs-emu = runVCSEmu vcs-emu case;
vcs-emu-trace = runVCSEmu vcs-emu-trace case;
vcs-emu-trace-cover = runVCSEmu vcs-emu-trace-cover case;
};
in
# Now we have { caseName = "hello", case = <derivation> }
Expand Down
2 changes: 1 addition & 1 deletion nix/t1/run/run-vcs-emu.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ emulator:
testCase:

stdenvNoCC.mkDerivation (finalAttr: {
name = "${testCase.pname}-vcs-result" + (lib.optionalString emulator.enableTrace "-trace");
name = "${testCase.pname}-vcs-result" + (lib.optionalString emulator.enableTrace "-trace") + (lib.optionalString emulator.enableCover "-cover");
nativeBuildInputs = [ zstd jq ];
__noChroot = true;

Expand Down
7 changes: 7 additions & 0 deletions nix/t1/t1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ lib.mapAttrs
enableTrace = true;
vcsLinkLibs = [ "${ipScope.vcs-dpi-lib-trace}/lib/libdpi_t1.a" ];
};
vcs-emu-trace-cover = t1Scope.sv-to-vcs-simulator {
mainProgram = "t1-vcs-trace-cover-simulator";
rtl = ipScope.emu-rtl;
enableTrace = true;
enableCover = true;
vcsLinkLibs = [ "${ipScope.vcs-dpi-lib-trace}/lib/libdpi_t1.a" ];
};

run = ipScope.callPackage ./run { };
}); # end of ipScope
Expand Down
12 changes: 10 additions & 2 deletions script/emu/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ object Main:
s"No cached emulator selection nor --emu argument was provided"
)

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

val finalConfig = tryRestoreFromCache("config", config)
if finalConfig.isEmpty then
Expand Down Expand Up @@ -225,7 +226,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
if finalEmuType.get == "vcs-emu-trace" || finalEmuType.get == "vcs-emu-trace-cover" then
val libPath = emulator / os.up / os.up / "lib"
val daidirPath =
os.walk(libPath)
Expand Down Expand Up @@ -259,6 +260,13 @@ object Main:

Logger.info("Driver finished")

if isCover then
if os.exists(os.pwd / "cm.vdb") then
os.move(os.pwd / "cm.vdb", outputPath / "cm.vdb", replaceExisting = true)
Logger.info("Coverage database saved under ${outputPath}/cm.vdb")
else
Logger.error("No cm.vdb found")

if os.exists(os.pwd / "perf.json") then
os.move(os.pwd / "perf.json", outputPath / "perf.json", replaceExisting = true)

Expand Down

0 comments on commit e7ba09d

Please sign in to comment.