-
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.
- Loading branch information
Showing
8 changed files
with
340 additions
and
530 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
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,61 @@ | ||
{ lib | ||
, stdenv | ||
, configName | ||
, rtl | ||
, verilator | ||
, enable-trace ? false | ||
, zlib | ||
}: | ||
stdenv.mkDerivation { | ||
name = "${configName}-verilated"; | ||
|
||
src = rtl; | ||
|
||
nativeBuildInputs = [ verilator ]; | ||
|
||
# zlib is required for Rust to link against | ||
propagatedBuildInputs = [ zlib ]; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
echo "[nix] running verilator" | ||
verilator \ | ||
${lib.optionalString enable-trace "--trace-fst"} \ | ||
--timing \ | ||
--threads 8 \ | ||
-O1 \ | ||
--cc TestBench | ||
echo "[nix] building verilated C lib" | ||
# backup srcs | ||
mkdir -p $out/share | ||
cp -r obj_dir $out/share/verilated_src | ||
# We can't use -C here because VTestBench.mk is generated with relative path | ||
cd obj_dir | ||
make -j "$NIX_BUILD_CORES" -f VTestBench.mk libVTestBench | ||
runHook postBuild | ||
''; | ||
|
||
passthru = { | ||
inherit enable-trace; | ||
}; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/include $out/lib | ||
cp *.h $out/include | ||
cp *.a $out/lib | ||
runHook postInstall | ||
''; | ||
|
||
# nix fortify hardening add `-O2` gcc flag, | ||
# we'd like verilator to controll optimization flags, so disable it. | ||
# `-O2` will make gcc build time in verilating extremely long | ||
hardeningDisable = [ "fortify" ]; | ||
} |
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.