diff --git a/difftest/vcs_t1rocket.nix b/difftest/vcs_t1rocket.nix new file mode 100644 index 000000000..2a5f721b3 --- /dev/null +++ b/difftest/vcs_t1rocket.nix @@ -0,0 +1,43 @@ +{ lib +, libspike +, libspike_interfaces +, rustPlatform +, rtlDesignMetadata +, enable-trace ? false +}: + +rustPlatform.buildRustPackage { + name = "vcs-dpi-lib"; + src = with lib.fileset; toSource { + root = ./.; + fileset = unions [ + ./spike_rs + ./offline + ./dpi_common + ./dpi_t1 + ./dpi_t1rocket + ./test_common + ./Cargo.lock + ./Cargo.toml + ]; + }; + + buildFeatures = ["dpi_common/vcs"] ++ lib.optionals enable-trace [ "dpi_common/trace" ]; + buildAndTestSubdir = "./dpi_t1rocket"; + + env = { + SPIKE_LIB_DIR = "${libspike}/lib"; + SPIKE_INTERFACES_LIB_DIR = "${libspike_interfaces}/lib"; + DESIGN_VLEN = rtlDesignMetadata.vlen; + DESIGN_DLEN = rtlDesignMetadata.dlen; + SPIKE_ISA_STRING = rtlDesignMetadata.march; + }; + + cargoLock = { + lockFile = ./Cargo.lock; + }; + + passthru = { + inherit enable-trace; + }; +} diff --git a/t1rocketemu/default.nix b/t1rocketemu/default.nix index e6d8014fb..4d2b1f5c0 100644 --- a/t1rocketemu/default.nix +++ b/t1rocketemu/default.nix @@ -14,7 +14,10 @@ verilator-emu-trace = scope.callPackage ./nix/verilator.nix { verilated-c-lib = scope.verilated-c-lib-trace; }; vcs-rust-package = scope.callPackage ./online_vcs { }; - inherit (scope.vcs-rust-package) vcs-dpi-lib vcs-dpi-lib-trace vcs-offline-checker; + inherit (scope.vcs-rust-package) vcs-offline-checker; + + vcs-dpi-lib = scope.callPackage ../difftest/vcs_t1rocket.nix { }; + vcs-dpi-lib-trace = scope.vcs-dpi-lib.override { enable-trace = true; }; vcs-emu = scope.callPackage ./nix/vcs.nix { }; vcs-emu-trace = scope.callPackage ./nix/vcs.nix { vcs-dpi-lib = scope.vcs-dpi-lib-trace; }; diff --git a/t1rocketemu/nix/run-vcs-emulation.nix b/t1rocketemu/nix/run-vcs-emulation.nix index 902a2c5b0..59a2478cf 100644 --- a/t1rocketemu/nix/run-vcs-emulation.nix +++ b/t1rocketemu/nix/run-vcs-emulation.nix @@ -17,10 +17,8 @@ stdenvNoCC.mkDerivation (finalAttr: { mkdir -p "$out" emuDriverArgsArray=( - "--elf-file" - "${testCase}/bin/${testCase.pname}.elf" - ${lib.optionalString emulator.enable-trace "--wave-path"} - ${lib.optionalString emulator.enable-trace "${testCase.pname}.fsdb"} + "+t1_elf_file=${testCase}/bin/${testCase.pname}.elf" + ${lib.optionalString emulator.enable-trace "+t1_wave_path=${testCase.pname}.fsdb"} ) emuDriverArgs="''${emuDriverArgsArray[@]}" emuDriver="${emulator}/bin/t1-vcs-simulator" diff --git a/t1rocketemu/nix/vcs.nix b/t1rocketemu/nix/vcs.nix index 48758bd4f..5051bbeaf 100644 --- a/t1rocketemu/nix/vcs.nix +++ b/t1rocketemu/nix/vcs.nix @@ -33,7 +33,7 @@ let -debug_access+pp+dmptf+thread \ -kdb=common_elab,hgldd_all''} \ -file filelist.f \ - ${vcs-dpi-lib}/lib/libdpi.a \ + ${vcs-dpi-lib}/lib/libdpi_t1rocket.a \ -o t1-vcs-simulator runHook postBuild