From e09e6752752c44d2387b70db00232e61b46113fa Mon Sep 17 00:00:00 2001 From: Avimitin Date: Tue, 23 Jul 2024 09:13:56 +0800 Subject: [PATCH] [nix] add new attribute online-dpi-static-lib --- difftest/default.nix | 63 +++++++++++++++++++++------------- difftest/online_dpi/Cargo.toml | 1 + nix/t1/default.nix | 2 +- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/difftest/default.nix b/difftest/default.nix index efcd77d71..558f12ee1 100644 --- a/difftest/default.nix +++ b/difftest/default.nix @@ -17,22 +17,46 @@ let spike_interfaces = callPackage ./spike_interfaces { }; - self = rustPlatform.buildRustPackage { - name = "difftest"; - src = with lib.fileset; toSource { - root = ./.; - fileset = unions [ - ./spike_rs - ./offline - ./online_dpi - ./online_drive - ./online_vcs - ./test_common - ./Cargo.lock - ./Cargo.toml - ]; + src = with lib.fileset; toSource { + root = ./.; + fileset = unions [ + ./spike_rs + ./offline + ./online_dpi + ./online_drive + ./online_vcs + ./test_common + ./Cargo.lock + ./Cargo.toml + ]; + }; + + env = { + VERILATED_INC_DIR = "${verilated}/include"; + VERILATED_LIB_DIR = "${verilated}/lib"; + SPIKE_LIB_DIR = "${libspike}/lib"; + SPIKE_INTERFACES_LIB_DIR = "${spike_interfaces}/lib"; + DESIGN_VLEN = elaborateConfig.parameter.vLen; + DESIGN_DLEN = elaborateConfig.parameter.dLen; + }; + + online-dpi-static-lib = rustPlatform.buildRustPackage { + name = "online-dpi-static-lib"; + + inherit src env; + + cargoLock = { + lockFile = ./Cargo.lock; }; + buildFeatures = [ "svvpi" ]; + buildAndTestSubdir = "./online_dpi"; + }; + + self = rustPlatform.buildRustPackage { + name = "verilator-emu" + (lib.optionalString verilated.enable-trace "-trace"); + inherit src env; + buildInputs = [ spike_interfaces verilated @@ -46,15 +70,6 @@ let buildFeatures = lib.optionals verilated.enable-trace [ "trace" ]; buildAndTestSubdir = "./online_drive"; - env = { - VERILATED_INC_DIR = "${verilated}/include"; - VERILATED_LIB_DIR = "${verilated}/lib"; - SPIKE_LIB_DIR = "${libspike}/lib"; - SPIKE_INTERFACES_LIB_DIR = "${spike_interfaces}/lib"; - DESIGN_VLEN = elaborateConfig.parameter.vLen; - DESIGN_DLEN = elaborateConfig.parameter.dLen; - }; - cargoLock = { lockFile = ./Cargo.lock; }; @@ -69,7 +84,7 @@ let clang-tools ]; }); - inherit spike_interfaces; + inherit spike_interfaces online-dpi-static-lib; }; }; in diff --git a/difftest/online_dpi/Cargo.toml b/difftest/online_dpi/Cargo.toml index ee1f608ab..da379ad45 100644 --- a/difftest/online_dpi/Cargo.toml +++ b/difftest/online_dpi/Cargo.toml @@ -2,6 +2,7 @@ name = "online_dpi" edition = "2021" version.workspace = true +crate-type = ["staticlib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/nix/t1/default.nix b/nix/t1/default.nix index e67333b59..1fe3ebe3d 100644 --- a/nix/t1/default.nix +++ b/nix/t1/default.nix @@ -51,7 +51,7 @@ lib.makeScope newScope elaborateConfigJson = configPath; elaborateConfig = builtins.fromJSON (lib.readFile configPath); - cases = innerSelf.callPackage ../../tests { difftest = ip.difftest; difftest-trace = ip.difftest-trace; }; + cases = innerSelf.callPackage ../../tests { verilator-emu = ip.verilator-emu; verilator-emu-trace = ip.verilator-emu-trace; }; # for the convenience to use x86 cases on non-x86 machines, avoiding the extra build time cases-x86 =