Skip to content

Commit

Permalink
[nix] fix vcs-emu offline check
Browse files Browse the repository at this point in the history
  • Loading branch information
FanShupei committed Aug 27, 2024
1 parent a03093f commit 4102d7e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 17 deletions.
40 changes: 40 additions & 0 deletions difftest/offline.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
23 changes: 9 additions & 14 deletions difftest/offline/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
}
2 changes: 2 additions & 0 deletions nix/t1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions nix/t1/run-vcs-emulation.nix
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4102d7e

Please sign in to comment.