diff --git a/nix/pkgs/snps-fhs-env.nix b/nix/pkgs/snps-fhs-env.nix index 152a5ab68..7aea10162 100644 --- a/nix/pkgs/snps-fhs-env.nix +++ b/nix/pkgs/snps-fhs-env.nix @@ -78,6 +78,7 @@ lockedPkgs.buildFHSEnv { nssmdns fontconfig numactl + python3 (krb5.overrideAttrs rec { version = "1.18.2"; src = fetchurl { diff --git a/nix/t1/conversion/sv-to-vcs-simulator.nix b/nix/t1/conversion/sv-to-vcs-simulator.nix index 6f56c98b0..3e1074e15 100644 --- a/nix/t1/conversion/sv-to-vcs-simulator.nix +++ b/nix/t1/conversion/sv-to-vcs-simulator.nix @@ -26,6 +26,11 @@ stdenv.mkDerivation rec { dontUnpack = true; + # VCS simulation profiling + # This is a debug feature, thus intentionally not exposed + # Enable it by changing line below to 'true' + enableProfile = false; + vcsArgs = [ "-sverilog" "-full64" @@ -56,6 +61,9 @@ stdenv.mkDerivation rec { "-debug_access+pp+dmptf+thread" "-kdb=common_elab,hgldd_all" ] + ++ lib.optionals enableProfile [ + "-simprofile" + ] ++ vcsLinkLibs; buildPhase = '' diff --git a/nix/t1/run/default.nix b/nix/t1/run/default.nix index bfbcc3283..9c0ee5d51 100644 --- a/nix/t1/run/default.nix +++ b/nix/t1/run/default.nix @@ -16,10 +16,9 @@ let runVerilatorEmu = callPackage ./run-verilator-emu.nix { }; runVCSEmu_ = callPackage ./run-vcs-emu.nix { }; runFsdb2vcd = callPackage ./run-fsdb2vcd.nix { }; - runVCSEmu = emulator: runVCSEmu_ { inherit emulator; }; - runVCSEmuRT = emulator: runVCSEmu_ { + runVCSEmu = emulator: runVCSEmu_ { inherit emulator; - dpilib = vcs-dpi-lib; + dpilib = if emulator.isRuntimeLoad then vcs-dpi-lib else null; }; # cases is now { mlir = { hello = ...; ... }; ... } @@ -39,7 +38,7 @@ let innerMapper = caseName: case: { verilator-emu = runVerilatorEmu verilator-emu case; verilator-emu-trace = runVerilatorEmu verilator-emu-trace case; - vcs-emu = runVCSEmuRT vcs-emu-rtlink case; + vcs-emu = runVCSEmu vcs-emu-rtlink case; vcs-emu-cover = runVCSEmu vcs-emu-cover case; vcs-emu-trace = runVCSEmu vcs-emu-trace case; vcs-prof-vcd = runFsdb2vcd (runVCSEmu vcs-emu-trace case); diff --git a/nix/t1/run/run-vcs-emu.nix b/nix/t1/run/run-vcs-emu.nix index 80b66a0aa..cb7ca0a6d 100644 --- a/nix/t1/run/run-vcs-emu.nix +++ b/nix/t1/run/run-vcs-emu.nix @@ -1,4 +1,11 @@ -{ lib, stdenvNoCC, zstd, jq, offline-checker, snps-fhs-env }: +{ lib +, stdenvNoCC +, zstd +, jq +, offline-checker +, snps-fhs-env +, writeShellScriptBin +}: { emulator , dpilib ? null @@ -8,26 +15,55 @@ testCase: assert lib.assertMsg (!emulator.isRuntimeLoad || (dpilib != null)) "dpilib must be set for rtlink emu"; -stdenvNoCC.mkDerivation (finalAttr: { +stdenvNoCC.mkDerivation (rec { name = "${testCase.pname}-vcs-result" + (lib.optionalString emulator.enableTrace "-trace"); nativeBuildInputs = [ zstd jq ]; __noChroot = true; - passthru.caseName = testCase.pname; + passthru = { + caseName = testCase.pname; + + # to open 'profileReport.html' in firefox, + # set 'security.fileuri.strict_origin_policy = false' in 'about:config' + profile = writeShellScriptBin "runSimProfile" '' + ${emuDriver} \ + ${lib.escapeShellArgs emuDriverArgs} \ + -simprofile time \ + 2> ${testCase.pname}-rtl-event.jsonl + ''; + }; + + emuDriver = "${emulator}/bin/${emulator.mainProgram}"; + emuDriverArgs = lib.optionals emulator.isRuntimeLoad [ + "-sv_root" + "${dpilib}/lib" + "-sv_lib" + "${dpilib.svLibName}" + ] + ++ [ + "-exitstatus" + "-assert" + "global_finish_maxfail=10000" + "+t1_elf_file=${testCase}/bin/${testCase.pname}.elf" + ] + ++ lib.optionals emulator.enableCover [ + "-cm" + "assert" + ] + ++ lib.optionals emulator.enableTrace [ + "+t1_wave_path=${testCase.pname}.fsdb" + ]; buildCommand = '' + ${lib.optionalString emulator.enableProfile '' + echo "ERROR: 'enableProfile = true' is inherently nondetermistic" + echo " use 'nix run <...>.profile --impure' instead" + exit 1 + ''} + mkdir -p "$out" - emuDriverArgsArray=( - ${lib.optionalString emulator.isRuntimeLoad "-sv_root ${dpilib}/lib -sv_lib ${dpilib.svLibName}"} - "-exitstatus" - "+t1_elf_file=${testCase}/bin/${testCase.pname}.elf" - ${lib.optionalString emulator.enableTrace "+t1_wave_path=${testCase.pname}.fsdb"} - ${lib.optionalString emulator.enableCover "-cm assert"} - "-assert global_finish_maxfail=10000" - ) - emuDriverArgs="''${emuDriverArgsArray[@]}" - emuDriver="${emulator}/bin/${emulator.mainProgram}" + emuDriverArgs="${lib.escapeShellArgs emuDriverArgs}" rtlEventOutPath="$out/${testCase.pname}-rtl-event.jsonl"