-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nix] refactor nix to prepare support vcs emulation
- add vcs-fhs-env for vcs simulation - clean up ipemu - use `nix build --impure .#t1.blastoise.ip.vcs-emu-compiled` to elaborate .so run with - module load synopsys/vc_static-V-2023.12 - nix develop --impure .#t1.blastoise.ip.vcs-emu - pushd difftest && cargo build --release -p online_vcs && popd - C-c exit build env - nix run --impure .#vcs-fhs-env - LD_PRELOAD=/nix/store/m71p7f0nymb19yn1dascklyya2i96jfw-glibc-2.39-52/lib/librt.so.1 LD_LIBRARY_PATH=/opt/synopsys/vc_static/V-2023.12/vcs-mx/linux64/lib/:$LD_LIBRARY_PATH ./difftest/target/release/online_vcs -daidir=/nix/store/b05gwv4l299k0ajvzvvkvc7fj8lkqzh8-blastoise-vcs/share/daidir
- Loading branch information
Showing
17 changed files
with
337 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ members = [ | |
"offline", | ||
"online_dpi", | ||
"online_drive", | ||
"online_vcs", | ||
] | ||
exclude = [ | ||
"spike_interfaces" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "online_vcs" | ||
edition = "2021" | ||
version.workspace = true | ||
|
||
[dependencies] | ||
online_dpi = { path = "../online_dpi", features = ["svvpi"] } | ||
|
||
[features] | ||
trace = ["online_dpi/trace"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use std::path::Path; | ||
use std::env; | ||
|
||
fn main() { | ||
let vcs_lib_dir = env::var("VCS_LIB_DIR").unwrap(); | ||
println!("cargo:rustc-link-search=native={}", Path::new(&vcs_lib_dir).display()); | ||
let vcs_compiled_lib_dir = env::var("VCS_COMPILED_LIB_DIR").unwrap(); | ||
println!("cargo:rustc-env=LD_LIBRARY_PATH={}", Path::new(&vcs_lib_dir).display()); | ||
println!("cargo:rustc-link-search=native={}", Path::new(&vcs_compiled_lib_dir).display()); | ||
println!("cargo::rustc-link-lib=TestBench"); | ||
println!("cargo::rustc-link-lib=vcsnew64"); | ||
println!("cargo::rustc-link-lib=vcs_tls"); | ||
println!("cargo::rustc-link-lib=vfs"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// force link with online_dpi | ||
extern crate online_dpi; | ||
|
||
use std::{ | ||
ffi::{c_char, c_int, c_void, CString}, | ||
ptr, | ||
}; | ||
|
||
fn main() { | ||
let c_args: Vec<CString> = std::env::args().map(|arg| CString::new(arg).unwrap()).collect(); | ||
|
||
let mut c_args_ptr: Vec<*const c_char> = c_args.iter().map(|arg| arg.as_ptr()).collect(); | ||
c_args_ptr.push(ptr::null()); | ||
|
||
let argc = c_args.len() as c_int; | ||
let argv = c_args_ptr.as_ptr() as *mut *mut c_char; | ||
|
||
unsafe { | ||
vcs_main(argc, argv); | ||
VcsInit(); | ||
VcsSimUntil(1<<31); | ||
} | ||
} | ||
|
||
extern "C" { | ||
fn vcs_main(argc: c_int, argv: *mut *mut c_char) -> c_int; | ||
fn VcsInit() -> c_void; | ||
fn VcsSimUntil(c: c_int) -> c_void; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ lib | ||
, callPackage | ||
, elaborateConfig | ||
|
||
, rustPlatform | ||
|
||
, rust-analyzer | ||
, rust-bindgen | ||
|
||
, vcStaticInstallPath | ||
, 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_drive | ||
./online_vcs | ||
./test_common | ||
./Cargo.lock | ||
./Cargo.toml | ||
]; | ||
}; | ||
|
||
buildInputs = [ | ||
spike_interfaces | ||
vcs-lib | ||
]; | ||
|
||
buildFeatures = lib.optionals vcs-lib.enable-trace [ "trace" ]; | ||
buildAndTestSubdir = "./online_vcs"; | ||
|
||
env = { | ||
VCS_LIB_DIR = "${vcStaticInstallPath}/vcs-mx/linux64/lib"; | ||
VCS_COMPILED_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ buildFHSEnv | ||
# e.g. /opt/synopsys/vc_static/V-2023.12 | ||
, vcStaticInstallPath | ||
# e.g. port@addr | ||
, snpsLicenseFile | ||
}: | ||
buildFHSEnv { | ||
name = "vcs-fhs-env"; | ||
profile = '' | ||
export TCL_TZ=UTC | ||
export VC_STATIC_HOME=${vcStaticInstallPath} | ||
export VCS_HOME=${vcStaticInstallPath}/vcs-mx | ||
export VCS_TARGET_ARCH=amd64 | ||
export VCS_ARCH_OVERRIDE=linux | ||
export VERDI_HOME=${vcStaticInstallPath}/verdi | ||
export NOVAS_HOME=${vcStaticInstallPath}/verdi | ||
export SPYGLASS_HOME=${vcStaticInstallPath}/SG_COMPAT/SPYGLASS_HOME | ||
export SNPS_VERDI_CBUG_LCA=1 | ||
export SNPSLMD_LICENSE_FILE=${snpsLicenseFile} | ||
export PATH=${vcStaticInstallPath}/bin:$PATH | ||
export PATH=${vcStaticInstallPath}/verdi/bin:$PATH | ||
export PATH=${vcStaticInstallPath}/vcs-mx/bin:$PATH | ||
export PATH=${vcStaticInstallPath}/SG_COMPAT/SPYGLASS_HOME/bin:$PATH | ||
export LD_LIBRARY_PATH=/usr/lib64/ | ||
export LD_LIBRARY_PATH=${vcStaticInstallPath}/verdi/share/PLI/lib/LINUX64:$LD_LIBRARY_PATH | ||
export LD_LIBRARY_PATH=${vcStaticInstallPath}/verdi/share/NPI/lib/LINUX64:$LD_LIBRARY_PATH | ||
''; | ||
targetPkgs = (ps: with ps; [ | ||
libGL | ||
util-linux | ||
libxcrypt-legacy | ||
coreutils-full | ||
ncurses5 | ||
gmp5 | ||
bzip2 | ||
glib | ||
bc | ||
time | ||
elfutils | ||
ncurses5 | ||
e2fsprogs | ||
cyrus_sasl | ||
expat | ||
sqlite | ||
(nssmdns.overrideAttrs rec { | ||
version = "0.14.1"; | ||
src = fetchFromGitHub { | ||
owner = "avahi"; | ||
repo = "nss-mdns"; | ||
rev = "v${version}"; | ||
hash = "sha256-7RqV0hyfcZ168QfeHVtCJpyP4pI6cMeekJ2hDHNurdA="; | ||
}; | ||
}) | ||
(libkrb5.overrideAttrs rec { | ||
version = "1.18.2"; | ||
src = fetchurl { | ||
url = "https://kerberos.org/dist/krb5/${lib.versions.majorMinor version}/krb5-${version}.tar.gz"; | ||
hash = "sha256-xuTJ7BqYFBw/XWbd8aE1VJBQyfq06aRiDumyIIWHOuA="; | ||
}; | ||
sourceRoot = "krb5-${version}/src"; | ||
}) | ||
(gnugrep.overrideAttrs rec { | ||
version = "3.1"; | ||
doCheck = false; | ||
src = fetchurl { | ||
url = "mirror://gnu/grep/grep-${version}.tar.xz"; | ||
hash = "sha256-22JcerO7PudXs5JqXPqNnhw5ka0kcHqD3eil7yv3oH4="; | ||
}; | ||
}) | ||
keyutils | ||
graphite2 | ||
libpulseaudio | ||
gcc | ||
gnumake | ||
xorg.libX11 | ||
xorg.libXft | ||
xorg.libXScrnSaver | ||
xorg.libXext | ||
xorg.libxcb | ||
xorg.libXau | ||
xorg.libXrender | ||
xorg.libXcomposite | ||
xorg.libXi | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.