-
Notifications
You must be signed in to change notification settings - Fork 680
Introduce an OSS Formal Flow #2309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2fa0ba6
b6b30fc
b10eedb
1a7709e
4293c3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright lowRISC contributors. | ||
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| dv/formal/strategies/* linguist-generated |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Copyright lowRISC contributors. | ||
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # GitHub Actions CI build configuration | ||
|
|
||
| name: Ibex OSS Formal CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - '*' | ||
|
|
||
| jobs: | ||
| fv: | ||
| name: Run the Open-Source FV flow | ||
| runs-on: nixos | ||
| concurrency: | ||
| group: oss-fv | ||
| cancel-in-progress: false # Only do one oss-fv job at a time, since we will use a huge amount of memory | ||
marnovandermaas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| steps: | ||
| - name: Setup env | ||
| run: | | ||
| echo "MAX_MEM_GB=100" >> $GITHUB_ENV # Maximum memory available to conductor.py, which is inversely proportional to time. 200GB -> 40 mins | ||
| echo "NIX_CONFIG=accept-flake-config = true" >> $GITHUB_ENV | ||
| - name: Notify about queued execution | ||
| run: | | ||
| echo "Warning: This job will block other oss-fv jobs until it finishes, since it uses a lot of memory." | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Nix | ||
| uses: cachix/install-nix-action@v27 | ||
| with: | ||
| extra_nix_config: | | ||
| substituters = https://nix-cache.lowrisc.org/public/ https://cache.nixos.org/ | ||
| trusted-public-keys = nix-cache.lowrisc.org-public-1:O6JLD0yXzaJDPiQW1meVu32JIDViuaPtGDfjlOopU7o= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= | ||
| - name: Run OSS Env | ||
| run: | | ||
| source <(nix print-dev-env .#oss-dev) | ||
| cd dv/formal | ||
| make build/aig-manip | ||
| make build/all.aig SHELL=bash | ||
| python3 conductor.py prove --check-complete --max-mem $MAX_MEM_GB | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| build | ||
| jgproject | ||
| jgproofs | ||
| aig-manip/target |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,29 +1,42 @@ | ||||
| # Copyright lowRISC contributors. | ||||
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||||
| # Original author: Louis-Emile Ploix | ||||
| # SPDX-License-Identifier: Apache-2.0 | ||||
|
|
||||
| IBEX_ROOT=../.. | ||||
|
|
||||
| SAIL=sail | ||||
| SAIL=$(shell which sail) | ||||
| PSGEN=$(shell which psgen) | ||||
|
|
||||
| SAIL_RISCV_MODEL_DIR=${LOWRISC_SAIL_RISCV_SRC}/model | ||||
|
|
||||
| include Sources.mk | ||||
| include sail-sources.mk | ||||
|
|
||||
| PSGEN_SRCS=thm/btype.proof thm/ibex.proof thm/mem.proof thm/riscv.proof | ||||
| PSGEN_FLAGS=-root riscv -task | ||||
|
|
||||
| SAIL_EXTRA_SRCS=../spec/main.sail | ||||
| SAIL_EXTRA_SRCS=spec/main.sail | ||||
|
|
||||
| SAIL_SV_FLAGS=-sv -sv-comb -sv-inregs -sv-outregs -sv-nostrings -sv-nopacked -sv-nomem -Oconstant_fold -memo-z3 \ | ||||
| -sv-unreachable translate -sv-unreachable lookup_TLB -sv-unreachable translate_tlb_miss -sv-unreachable translate_tlb_hit -sv-unreachable pt_walk \ | ||||
| -sv-fun2wires 2:read_ram \ | ||||
| -sv-fun2wires 2:write_ram \ | ||||
| -sv-fun2wires wX \ | ||||
| -sv-fun2wires 2:rX \ | ||||
| # -sv, use the SystemVerilog backend | ||||
| # --sv-comb, generate a always_comb instead of an initial block | ||||
| # --sv-inregs --sv-outregs, produce inputs and outputs for every Sail register | ||||
| # --sv-nostrings, --sv-nopacked, --sv-nomem, avoid generating some things Jasper doesn't like (FIXME: --sv-nopacked might be better removed?) | ||||
| # -Oconstrant_fold, do basic optimisation | ||||
| # -memo-z3, resolving types requires a sat solver, this helps speed up those queries | ||||
| # --sv-unreachable, remove the implementations of functions to either make the design smaller or avoid recursion loops (FIXME: Still necessary?) | ||||
| # --sv-fun2wires (n:)?f, transform a function into ports, with n (or 1) slots | ||||
| SAIL_SV_FLAGS=-sv --sv-comb --sv-inregs --sv-outregs --sv-nostrings --sv-nopacked --sv-nomem -Oconstant_fold -memo-z3 \ | ||||
| --sv-unreachable translate --sv-unreachable lookup_TLB --sv-unreachable translate_tlb_miss --sv-unreachable translate_tlb_hit --sv-unreachable pt_walk \ | ||||
| --sv-fun2wires 2:read_ram \ | ||||
| --sv-fun2wires 2:write_ram \ | ||||
| --sv-fun2wires wX | ||||
|
|
||||
| # Use fusesoc to resolve the tree of components, copy all resolved source files into the build/ directory, | ||||
| # and then generate a filelist for jasper to ingest. | ||||
| # - Note. we use the 'vcs' fusesoc backend flow to generate the filelist. This is because fusesoc does not currently implement a | ||||
| # JasperGold backend, but this is not an issue as the file-format generated by the vcs flow is compatible with jasper. | ||||
| .PHONY: fusesoc | ||||
| fusesoc: | ||||
| # JasperGold backend, but this is not an issue as the file-format generated by the vcs flow is compatible with both jasper and | ||||
| # yosys-slang. | ||||
| build/fusesoc: $(IBEX_ROOT)/rtl $(IBEX_ROOT)/vendor | ||||
| mkdir -p build/fusesoc | ||||
| fusesoc \ | ||||
| --cores-root $(IBEX_ROOT) \ | ||||
|
|
@@ -32,33 +45,52 @@ fusesoc: | |||
| --tool vcs \ | ||||
| --setup \ | ||||
| lowrisc:ibex:ibex_formal:0.1 | ||||
| touch build/fusesoc # Fix timestamps for Makefile | ||||
|
|
||||
| # The sail spec module, constructed from LOWRISC_SAIL_RISCV_SRC, compiled by our fork of the sail compiler | ||||
| build/ibexspec.sv: $(SAIL) $(SAIL_SRCS) $(SAIL_EXTRA_SRCS) sail-sources.mk Makefile spec/fix_bugs.py | ||||
| mkdir -p build | ||||
| cd build && $(SAIL) $(SAIL_SRCS) $(addprefix ../,$(SAIL_EXTRA_SRCS)) $(SAIL_SV_FLAGS) $(addprefix -sv_unreachable execute_,$(COMPRESSED_INSTRS)) -o ibexspec | ||||
| python3 spec/fix_bugs.py | ||||
|
|
||||
| # The compiled property structure, and the associated TCL | ||||
| build/psgen-jg.sv: $(PSGEN) $(PSGEN_SRCS) Makefile | ||||
| mkdir -p build | ||||
| $(PSGEN) $(addprefix -path ,$(PSGEN_SRCS)) $(PSGEN_FLAGS) -sv-out build/psgen-jg.sv -tcl-out build/psgen.tcl | ||||
|
|
||||
| .PHONY: sv | ||||
| sv: | ||||
| # Same as above, but generate our own covers, and tweak for consumption by our tools | ||||
| build/psgen-yosys.sv: $(PSGEN) $(PSGEN_SRCS) Makefile | ||||
| mkdir -p build | ||||
| python3 buildspec.py header > build/ibexspec_instrs.sv | ||||
| cd build && $(SAIL) $(SAIL_SRCS) $(SAIL_EXTRA_SRCS) $(SAIL_SV_FLAGS) `cd .. && python3 buildspec.py unreachables` -o ibexspec | ||||
| python3 spec/fix_pmp_bug.py | ||||
| python3 buildspec.py unreachable_loc_hack | ||||
| $(PSGEN) $(addprefix -path ,$(PSGEN_SRCS)) $(PSGEN_FLAGS) -sv-out build/psgen-yosys.sv -clocking -covers -cover-assert -step-prefix | ||||
|
|
||||
| # The aiger file for the OSS flow, using the yosys_formal/* plugins. The main yosys script is in build_all.ys | ||||
| build/all.aig: build/psgen-yosys.sv build/fusesoc build/ibexspec.sv check build_all.ys $(LOWRISC_YOSYS_SLANG) build/yosys_formal.so | ||||
| yosys -m $(LOWRISC_YOSYS_SLANG) -m build/yosys_formal.so -v 1 -s <(cat ./build_all.ys | sed "s|LOWRISC_SAIL_SRC|$(LOWRISC_SAIL_SRC)|g") | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Slightly annoying yosys can't do environment variable substitution, would be nice to not have to do this dance with sed.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It unfortunate. Even using Line 18 in eb6e0ac
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might be able to turn |
||||
|
|
||||
| .PHONY: psgen | ||||
| psgen: | ||||
| # Build the custom yosys plugins | ||||
| build/yosys_formal.so: yosys_formal/global_clock.cc yosys_formal/write_aiger.cc yosys_formal/opt_muxtree.cc | ||||
| yosys-config --build build/yosys_formal.so yosys_formal/global_clock.cc yosys_formal/write_aiger.cc yosys_formal/opt_muxtree.cc | ||||
|
|
||||
| # Build the aig-manip Rust tool | ||||
| build/aig-manip: aig-manip/src/main.rs | ||||
| mkdir -p build | ||||
| psgen $(addprefix -path ,$(PSGEN_SRCS)) $(PSGEN_FLAGS) -sv-out build/psgen.sv -tcl-out build/psgen.tcl | ||||
| cd aig-manip && cargo build --release | ||||
| cp aig-manip/target/release/aig-manip build/ | ||||
|
|
||||
| # Run the jasper environment in interactive mode | ||||
| .PHONY: jg | ||||
| jg: fusesoc psgen sv | ||||
| jg: build/fusesoc build/psgen-jg.sv build/ibexspec.sv | ||||
| jg verify.tcl -allow_unsupported_OS -acquire_proj | ||||
|
|
||||
| # The following default target is intended for regressions / unattended runs. | ||||
| # Jasper environment for regression and unattended runs | ||||
| .PHONY: all | ||||
| all: fusesoc psgen sv | ||||
| all: build/fusesoc build/psgen-jg.sv build/ibexspec.sv | ||||
| jg verify.tcl -allow_unsupported_OS -acquire_proj -no_gui --- "prove_no_liveness" | ||||
|
|
||||
| ################################################################################ | ||||
|
|
||||
| .PHONY: clean | ||||
| clean: | ||||
| rm -rf build/ | ||||
| rm -rf jgproject/ | ||||
| rm -rf jgproofs/ | ||||
| rm -rf build/ aig-manip/target | ||||
| rm -rf jgproject/ jgproofs/ | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.