Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nix] support dwbb in verilator emu #825

Merged
merged 2 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ rec {
rvv-codegen = final.callPackage ./pkgs/rvv-codegen.nix { };
add-determinism = final.callPackage ./pkgs/add-determinism { }; # faster strip-undetereminism

vcs-fhs-env = final.callPackage ./pkgs/vcs-fhs-env.nix { };
snps-fhs-env = final.callPackage ./pkgs/snps-fhs-env.nix { };

mill = let jre = final.jdk21; in
(prev.mill.override { inherit jre; }).overrideAttrs (_: {
Expand Down
2 changes: 1 addition & 1 deletion nix/pkgs/vcs-fhs-env.nix → nix/pkgs/snps-fhs-env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let
dwbb = getEnv' "DWBB_DIR";
in
lockedPkgs.buildFHSEnv {
name = "vcs-fhs-env";
name = "snps-fhs-env";

profile = ''
[ ! -e "${vcStaticHome}" ] && echo "env VC_STATIC_HOME='${vcStaticHome}' points to unknown location" && exit 1
Expand Down
10 changes: 5 additions & 5 deletions nix/t1/conversion/sv-to-vcs-simulator.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib
, bash
, stdenv
, vcs-fhs-env
, snps-fhs-env
}:

{ mainProgram
Expand Down Expand Up @@ -52,7 +52,7 @@ stdenv.mkDerivation rec {
buildPhase = ''
runHook preBuild

fhsEnv="${vcs-fhs-env}/bin/vcs-fhs-env"
fhsEnv="${snps-fhs-env}/bin/snps-fhs-env"
DWBB_DIR=$($fhsEnv -c "echo \$DWBB_DIR")
vcsArgsStr="${lib.escapeShellArgs vcsArgs}"

Expand All @@ -63,12 +63,12 @@ stdenv.mkDerivation rec {
'';

passthru = {
inherit vcs-fhs-env enableTrace;
inherit snps-fhs-env enableTrace;
};

shellHook = ''
echo "[nix] entering fhs env"
${vcs-fhs-env}/bin/vcs-fhs-env
${snps-fhs-env}/bin/snps-fhs-env
'';

installPhase = ''
Expand All @@ -91,7 +91,7 @@ stdenv.mkDerivation rec {
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"
${snps-fhs-env}/bin/snps-fhs-env -c "$out/lib/$mainProgram ${lib.optionalString enableCover ''-cm_dir ./cm.vdb''} \$_argv"
EOF
chmod +x $out/bin/$mainProgram

Expand Down
10 changes: 9 additions & 1 deletion nix/t1/conversion/sv-to-verilator-emulator.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib
, stdenv
, verilator
, snps-fhs-env
, zlib
}:

Expand All @@ -16,6 +17,8 @@ rec {
name = mainProgram;
inherit mainProgram;

__noChroot = true;

src = rtl;

nativeBuildInputs = [ verilator ];
Expand All @@ -36,20 +39,25 @@ rec {
"--threads"
(toString verilatorThreads)
"-O1"
"-y"
"$DWBB_DIR/sim_ver"
"-Wno-lint"
"-F"
verilatorFilelist
"--top"
verilatorTop
]
++ extraVerilatorArgs
++ lib.optionals (enableTrace) [
++ lib.optionals enableTrace [
"+define+T1_ENABLE_TRACE"
"--trace-fst"
];

buildPhase = ''
runHook preBuild

DWBB_DIR=$(${snps-fhs-env}/bin/snps-fhs-env -c "echo \$DWBB_DIR")

verilatorPhase="verilator ${lib.escapeShellArgs verilatorArgs}"
echo "[nix] running verilator: $verilatorPhase"
$builder -c "$verilatorPhase"
Expand Down
2 changes: 1 addition & 1 deletion nix/t1/run/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let
cp -vr $emuOutput $out
chmod -R u+w $out

${vcs-emu.vcs-fhs-env}/bin/vcs-fhs-env -c "urg -dir $emuOutput/*/cm.vdb -format text -metric assert -show summary"
${vcs-emu.snps-fhs-env}/bin/snps-fhs-env -c "urg -dir $emuOutput/*/cm.vdb -format text -metric assert -show summary"
cp -vr urgReport $out/
'';
in
Expand Down
4 changes: 2 additions & 2 deletions nix/t1/run/run-fsdb2vcd.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenvNoCC, vcs-fhs-env }:
{ lib, stdenvNoCC, snps-fhs-env }:
vcs-emu-trace:

let
Expand All @@ -14,7 +14,7 @@ stdenvNoCC.mkDerivation (finalAttr: {
buildCommand = ''
mkdir -p "$out"

fhsEnv="${vcs-fhs-env}/bin/vcs-fhs-env"
fhsEnv="${snps-fhs-env}/bin/snps-fhs-env"
"$fhsEnv" -c "fsdb2vcd ${vcs-emu-trace}/*.fsdb -o ${caseName}.prof.vcd -s /TestBench/verification/profData"

cp -t "$out" "${caseName}.prof.vcd"
Expand Down
4 changes: 1 addition & 3 deletions script/emu/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ object Main:
val emuPath = os.Path(emuType, os.pwd)
if (os.exists(emuPath)) then return emuPath

val nixStorePath =
if emuType.contains("vcs-") then resolveNixPath(s".#t1.${config}.${ip}.${emuType}", Seq("--impure"))
else resolveNixPath(s".#t1.${config}.${ip}.${emuType}")
val nixStorePath = resolveNixPath(s".#t1.${config}.${ip}.${emuType}", Seq("--impure"))

val elfFilePath = os
.walk(os.Path(nixStorePath) / "bin")
Expand Down