From 7978a652249705ae2368bb32bc76220370a06e54 Mon Sep 17 00:00:00 2001 From: Jiuyang Liu Date: Sun, 21 Jul 2024 15:39:22 +0800 Subject: [PATCH] [nix] draft vcs linking --- difftest/default.nix | 8 +++++++- difftest/online_vcs/build.rs | 2 ++ nix/t1/default.nix | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/difftest/default.nix b/difftest/default.nix index 2a477dbb0..be024aa8d 100644 --- a/difftest/default.nix +++ b/difftest/default.nix @@ -8,7 +8,10 @@ , rust-bindgen , verilator -, verilated +, verilated ? null + +, vcs-lib ? null + , cmake , clang-tools }: @@ -35,6 +38,7 @@ let buildInputs = [ spike_interfaces verilated + vcs-lib ]; nativeBuildInputs = [ @@ -43,10 +47,12 @@ let ]; buildFeatures = lib.optionals verilated.enable-trace [ "trace" ]; + # buildFeatures = lib.optionals vcs-lib.enable-trace [ "trace" ]; env = { VERILATED_INC_DIR = "${verilated}/include"; VERILATED_LIB_DIR = "${verilated}/lib"; + VCS_LIB_DIR = "${vcs-lib}/lib"; DESIGN_VLEN = elaborateConfig.parameter.vLen; DESIGN_DLEN = elaborateConfig.parameter.dLen; }; diff --git a/difftest/online_vcs/build.rs b/difftest/online_vcs/build.rs index 8613e2287..d1ce988dd 100644 --- a/difftest/online_vcs/build.rs +++ b/difftest/online_vcs/build.rs @@ -1,3 +1,5 @@ fn main() { + let vcs_lib_dir = env::var("VCS_LIB_DIR").unwrap(); + println!("cargo:rustc-link-search=native={}", Path::new(&vcs_lib_dir).join("lib").display()); println!("cargo::rustc-link-lib=TestBench"); } diff --git a/nix/t1/default.nix b/nix/t1/default.nix index 309c37ab5..5ca8ed709 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 { verilated = vcs-emu-compiled; }; - vcs-emu-trace = innerSelf.callPackage ../../difftest/default.nix { verilated = vcs-emu-compiled-trace; }; + 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; }; }; subsystem = rec {