Skip to content

Commit

Permalink
Nix Cleanup + Stricter ETV
Browse files Browse the repository at this point in the history
  • Loading branch information
donn committed Aug 20, 2024
1 parent 686a457 commit 6b911cc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
8 changes: 6 additions & 2 deletions Sources/Fault/Entries/atpg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,12 @@ extension Fault {
print("Read \(etvSetVectors.count) externally-generated vectors to verify.")
}

if let tvGenerator = etvGen, ETVGFactory.validNames.contains(tvGenerator) {
let etvgen = ETVGFactory.get(name: tvGenerator)!
if let tvGenerator = etvGen {
guard let etvgen = ETVGFactory.get(name: tvGenerator) else {
Stderr.print("Unknown external test vector generator '\(tvGenerator)'.")
Foundation.exit(EX_USAGE)
}

let benchUnwrapped = bench! // Program exits if etvGen.value isn't nil and bench.value is or vice versa

if !fileManager.fileExists(atPath: benchUnwrapped) {
Expand Down
20 changes: 14 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ stdenv.mkDerivation (finalAttrs: {
];

configurePhase = generated.configure;

installPhase = ''
binPath="$(swiftpmBinPath)"
mkdir -p $out/bin
cp $binPath/fault $out/bin/fault
'';

# This doesn't work on Linux otherwise and I don't know why.
preBuild = if stdenv.isDarwin then "" else ''
Expand All @@ -81,17 +75,31 @@ stdenv.mkDerivation (finalAttrs: {
'';

checkPhase = ''
runHook preCheck
${finalAttrs.faultEnv}
PYTEST_FAULT_BIN="$(swiftpmBinPath)/fault" pytest
runHook postCheck
'';

installPhase = ''
runHook preInstall
binPath="$(swiftpmBinPath)"
mkdir -p $out/bin
cp $binPath/fault $out/bin/fault
ln -s ${nl2bench}/bin/nl2bench $out/bin/nl2bench
runHook postInstall
'';

fixupPhase = ''
runHook preFixup
wrapProgram $out/bin/fault\
--prefix PYTHONPATH : ${pyenv}/${pyenv.sitePackages}\
--prefix PATH : ${verilog}/bin\
--prefix PATH : ${quaigh}/bin\
--prefix PATH : ${yosys}/bin\
--set PYTHON_LIBRARY ${pyenv}/lib/lib${pyenv.libPrefix}${swiftPackages.stdenv.hostPlatform.extensions.sharedLibrary}\
--set FAULT_IVL_BASE ${verilog}/lib/ivl
runHook postFixup
'';

meta = with lib; {
Expand Down
4 changes: 2 additions & 2 deletions docs/Source/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ and system configuration.
To install Nix, follow OpenLane 2's Nix installation guide at
https://openlane2.readthedocs.io/en/stable/getting_started/common/nix_installation/index.html.

Afterwards, running Fault is simply `nix run github:AUCOHL/Fault`. To make
the `fault` command available in path, you can
Afterwards, to make the `fault` command (and the requisite `nl2bench` tool for
using alternative ATPGs) available in PATH, you can simply invoke
`nix profile install github:AUCOHL/Fault`.

## Docker
Expand Down

0 comments on commit 6b911cc

Please sign in to comment.