Skip to content

Commit

Permalink
[nix] complete formal nix and ci
Browse files Browse the repository at this point in the history
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
  • Loading branch information
unlsycn committed Sep 21, 2024
1 parent 44b2587 commit d0b54f1
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 33 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Build formal rtl"
- name: "Run Formal Verification"
run: |
nix run '.#gcd.formal-rtl'
- name: "Build formal environment"
run: |
nix run '.#cds-fhs-env' --impure
- name: "Run formal verification"
run: |
jg -batch ./scripts/formal/FPV.tcl
nix run '.#gcd.formal --impure'
2 changes: 0 additions & 2 deletions templates/chisel/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ target/
*.fst
*.fsdb
*.log

jgproject/
9 changes: 4 additions & 5 deletions templates/chisel/nix/gcd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ in
};
formal-mlirbc =
scope.callPackage ./mlirbc.nix { elaborate = scope.formal-elaborate; };
formal-rtl = scope.callPackage ./rtl.nix { mlirbc = scope.formal-mlirbc; };
formal-rtl = scope.callPackage ./rtl.nix {
mlirbc = scope.formal-mlirbc;
};
formal = scope.callPackage ./formal.nix {
rtl = scope.formal-rtl.override {
enable-layers =
[ "Verification" "Verification.Assert" "Verification.Cover" ];
};
rtl = scope.formal-rtl;
};

# TODO: designConfig should be read from OM
Expand Down
50 changes: 49 additions & 1 deletion templates/chisel/nix/gcd/formal.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,52 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 Jiuyang Liu <liu@jiuyang.me>

{ lib, stdenv, rtl }
{ stdenvNoCC
, rtl
, cds-fhs-env
}:

stdenvNoCC.mkDerivation {
name = "formal";

# Add "sandbox = relaxed" into /etc/nix/nix.conf, and run `systemctl restart nix-daemon`
#
# run nix build with "--impure" flag to build this package without chroot
# require license
__noChroot = true;
dontPatchELF = true;

src = rtl;

passthru = {
inherit rtl;
};

shellHook = ''
echo "[nix] entering fhs env"
${cds-fhs-env}/bin/cds-fhs-env
'';

buildPhase = ''
runHook preBuild
echo "[nix] running Jasper"
fhsBash=${cds-fhs-env}/bin/cds-fhs-env
"$fhsBash" -c "jg -batch ${./scripts/FPV.tcl}"
runHook postBuild
'';

installPhase = ''
runHook preInstall
ls -l
mkdir -p $out
cp report.txt $out
cp -r jgproject $out
runHook postInstall
'';

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
clear -all

# Analyze design under verification files
set RESULT_PATH ./result
set RESULT_PATH .

# Analyze source files and property files
analyze -sv12 \
Expand All @@ -26,18 +26,14 @@ get_design_info
set_max_trace_length 100
prove -all

# Report proof results
report

# Set exit code for ci, should only in batch mode

# report -file report.txt
# set failed_properties [get_property_list -include {status {cex unreachable}}]
# set length [llength $failed_properties]
# if { $length > 0 } {
# puts "There are $length failed properties!"
# exit 1
# } else {
# puts "All properties passed!"
# exit 0
# }
report -file report.txt

set failed_properties [get_property_list -include {status {cex unreachable}}]
set length [llength $failed_properties]
if { $length > 0 } {
puts "There are $length failed properties!"
exit 1
} else {
puts "All properties passed!"
exit 0
}
File renamed without changes.
2 changes: 1 addition & 1 deletion templates/chisel/nix/gcd/vcs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ stdenv.mkDerivation (finalAttr: {
cp ${binName} $out/lib
cp -r ${binName}.daidir $out/lib
substitute ${./vcs-wrapper.sh} $out/bin/${binName} \
substitute ${./scripts/vcs-wrapper.sh} $out/bin/${binName} \
--subst-var-by shell "${bash}/bin/bash" \
--subst-var-by dateBin "$(command -v date)" \
--subst-var-by vcsSimBin "$out/lib/${binName}" \
Expand Down
1 change: 1 addition & 0 deletions templates/chisel/nix/pkgs/cds-fhs-env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ lockedPkgs.buildFHSEnv {
[ ! -d "${jasperHome}" ] && echo "JASPER_HOME not accessible" && exit 1
[ -z "${cdsLicenseFile}" ] && echo "env CDS_LIC_FILE not set" && exit 1
export JASPER_HOME=${jasperHome}
export CDS_LIC_FILE=${cdsLicenseFile}
export PATH=$JASPER_HOME/bin:$PATH
export _oldCdsEnvPath="$PATH"
preHook() {
Expand Down

0 comments on commit d0b54f1

Please sign in to comment.