diff --git a/difftest/offline.nix b/difftest/offline.nix new file mode 100644 index 000000000..6cb220d28 --- /dev/null +++ b/difftest/offline.nix @@ -0,0 +1,40 @@ +{ lib +, elaborateConfig +, rustPlatform +, libspike +, libspike_interfaces +}: + +rustPlatform.buildRustPackage { + name = "offline"; + src = with lib.fileset; toSource { + root = ./.; + fileset = unions [ + ./spike_rs + ./offline + ./dpi_common + ./dpi_t1 + ./test_common + ./Cargo.lock + ./Cargo.toml + ]; + }; + + buildFeatures = []; + buildAndTestSubdir = "./offline"; + + env = { + SPIKE_LIB_DIR = "${libspike}/lib"; + SPIKE_INTERFACES_LIB_DIR = "${libspike_interfaces}/lib"; + DESIGN_VLEN = elaborateConfig.parameter.vLen; + DESIGN_DLEN = elaborateConfig.parameter.dLen; + SPIKE_ISA_STRING = + "rv32gc_" + + (builtins.concatStringsSep "_" elaborateConfig.parameter.extensions) + + "_Zvl${toString elaborateConfig.parameter.vLen}b"; + }; + + cargoLock = { + lockFile = ./Cargo.lock; + }; +} diff --git a/difftest/offline/src/main.rs b/difftest/offline/src/main.rs index 302e3df5d..9de4281f7 100644 --- a/difftest/offline/src/main.rs +++ b/difftest/offline/src/main.rs @@ -7,6 +7,7 @@ use std::path::PathBuf; use clap::Parser; use spike_rs::runner::{SpikeArgs, SpikeRunner}; use tracing::info; +use tracing_subscriber::{EnvFilter, FmtSubscriber}; use crate::difftest::Difftest; @@ -94,18 +95,12 @@ fn main() -> anyhow::Result<()> { } fn setup_logger() { - // setup log - // let log_level: Level = self.log_level.parse()?; - // let global_logger = FmtSubscriber::builder() - // .with_env_filter(EnvFilter::from_default_env()) - // .with_max_level(log_level) - // .without_time() - // .with_target(false) - // .with_ansi(true) - // .compact() - // .finish(); - // tracing::subscriber::set_global_default(global_logger) - // .expect("internal error: fail to setup log subscriber"); - // Ok(()) - todo!() + let global_logger = FmtSubscriber::builder() + .with_env_filter(EnvFilter::from_default_env()) + .without_time() + .with_target(false) + .compact() + .finish(); + tracing::subscriber::set_global_default(global_logger) + .expect("internal error: fail to setup log subscriber"); } diff --git a/nix/t1/default.nix b/nix/t1/default.nix index 6ffd5ff4f..87158d38c 100644 --- a/nix/t1/default.nix +++ b/nix/t1/default.nix @@ -131,6 +131,8 @@ lib.makeScope newScope # FIXME: vcs-emu should have offline check instead of using verilator one vcs-emu = ipSelf.callPackage ./vcs.nix { }; vcs-emu-trace = ipSelf.callPackage ./vcs.nix { vcs-dpi-lib = ipSelf.vcs-dpi-lib-trace; }; + + offline = ipSelf.callPackage ../../difftest/offline.nix { }; }); subsystem = rec { diff --git a/nix/t1/run-vcs-emulation.nix b/nix/t1/run-vcs-emulation.nix index 1575979e8..857fe6bab 100644 --- a/nix/t1/run-vcs-emulation.nix +++ b/nix/t1/run-vcs-emulation.nix @@ -1,5 +1,4 @@ -# FIXME: we should have offline check for VCS, importing offline check from verilator-emu is weird -{ lib, stdenvNoCC, zstd, jq, verilator-emu }: +{ lib, stdenvNoCC, zstd, jq, offline }: emulator: testCase: @@ -71,7 +70,7 @@ stdenvNoCC.mkDerivation (finalAttr: { ) offlineCheckArgs="''${offlineCheckArgsArray[@]}" echo -e "[nix] running offline check: \033[0;34m${emulator}/bin/offline $offlineCheckArgs\033[0m" - "${verilator-emu}/bin/offline" $offlineCheckArgs &> $out/offline-check-journal + "${offline}/bin/offline" $offlineCheckArgs &> $out/offline-check-journal printf "$?" > $out/offline-check-status if [ "$(cat $out/offline-check-status)" != "0" ]; then