From 8bc8b337686bb3f56113ac6d0b47a7620509cfde Mon Sep 17 00:00:00 2001 From: Jiuyang Liu Date: Sun, 21 Jul 2024 15:46:23 +0800 Subject: [PATCH] [nix] draft vcs linking --- difftest/vcs-emu.nix | 65 ++++++++++++++++++++++++++++++++++++++++++++ nix/t1/default.nix | 4 +-- 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 difftest/vcs-emu.nix diff --git a/difftest/vcs-emu.nix b/difftest/vcs-emu.nix new file mode 100644 index 000000000..596dc2f37 --- /dev/null +++ b/difftest/vcs-emu.nix @@ -0,0 +1,65 @@ +{ lib +, callPackage +, elaborateConfig + +, rustPlatform + +, rust-analyzer +, rust-bindgen + +, vcs-lib + +, cmake +, clang-tools +}: + +let + spike_interfaces = callPackage ./spike_interfaces { }; + + self = rustPlatform.buildRustPackage { + name = "t1-vcs-emu"; + src = with lib.fileset; toSource { + root = ./.; + fileset = unions [ + ./spike_rs + ./offline + ./online_dpi + ./online_vcs + ./test_common + ./Cargo.lock + ./Cargo.toml + ]; + }; + + buildInputs = [ + spike_interfaces + vcs-lib + ]; + + buildFeatures = lib.optionals vcs-lib.enable-trace [ "trace" ]; + + env = { + VCS_LIB_DIR = "${vcs-lib}/lib"; + DESIGN_VLEN = elaborateConfig.parameter.vLen; + DESIGN_DLEN = elaborateConfig.parameter.dLen; + }; + + cargoLock = { + lockFile = ./Cargo.lock; + }; + + dontUseCmakeConfigure = true; + + passthru = { + devShell = self.overrideAttrs (old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ + rust-analyzer + rust-bindgen + clang-tools + ]; + }); + inherit spike_interfaces; + }; + }; +in +self diff --git a/nix/t1/default.nix b/nix/t1/default.nix index 5ca8ed709..2a5c9f097 100644 --- a/nix/t1/default.nix +++ b/nix/t1/default.nix @@ -117,8 +117,8 @@ lib.makeScope newScope }; vcs-emu-compiled = innerSelf.callPackage ./vcs.nix { rtl = vcs-emu-rtl; }; vcs-emu-compiled-trace = innerSelf.callPackage ./vcs.nix { rtl = vcs-emu-rtl; enable-trace = true; }; - vcs-emu = innerSelf.callPackage ../../difftest/default.nix { vcs-lib = vcs-emu-compiled; }; - vcs-emu-trace = innerSelf.callPackage ../../difftest/default.nix { vcs-lib = vcs-emu-compiled-trace; }; + vcs-emu = innerSelf.callPackage ../../difftest/vcs-emu.nix { vcs-lib = vcs-emu-compiled; }; + vcs-emu-trace = innerSelf.callPackage ../../difftest/vcs-emu.nix { vcs-lib = vcs-emu-compiled-trace; }; }; subsystem = rec {