Skip to content

Commit 4b0b145

Browse files
committed
Use eqy and sby to perform formal verification
This commit also changes passlist and skiplist format.
1 parent 7f99048 commit 4b0b145

File tree

19 files changed

+2368
-1734
lines changed

19 files changed

+2368
-1734
lines changed

.ci.yml

Lines changed: 27 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ stages:
22
- check_code_format
33
- build_binaries
44
- run_parsing_and_formal_tests
5-
- verify_formal_tests_passlist
65
- run_large_designs_tests
76
- optional_bsg_tests
87

@@ -12,13 +11,20 @@ check_format:
1211
stage: check_code_format
1312
script:
1413
- echo "Install dependencies"
15-
- apt update && apt install -y git clang-format
14+
- apt update && apt install -y git clang-format python3 jq
1615
- echo "Check code format"
1716
- ./.github/scripts/format_sources.sh
17+
- exit_code=0
1818
- if ! git diff --exit-code; then
1919
- echo "Format locally using ./.github/scripts/format_sources.sh"
20-
- /bin/false
20+
- exit_code=1
2121
- fi
22+
- ./.github/scripts/sort_passlists.sh
23+
- if ! git diff --exit-code; then
24+
- echo "Format locally using ./.github/scripts/format_sources.sh"
25+
- exit_code=1
26+
- fi
27+
- exit $exit_code
2228

2329
build_binaries:
2430
stage: build_binaries
@@ -45,8 +51,7 @@ build_binaries:
4551
- echo "Build sv2v binary"
4652
- git submodule update --init --recursive --checkout third_party/sv2v
4753
- wget -qO- https://get.haskellstack.org/ | sh -s - -f -d /usr/local/bin
48-
- make -j$(nproc) -C $PWD/third_party/sv2v
49-
- cp third_party/sv2v/bin/sv2v out/release/bin/
54+
- make build_sv2v -j$(nproc)
5055
artifacts:
5156
when: always
5257
paths:
@@ -129,18 +134,17 @@ formal_verification_simple_tests:
129134
script:
130135
- echo "Install dependencies"
131136
- apt update
132-
- apt install -y $DEPENDENCIES_FOR_TESTING
137+
- apt install -y $DEPENDENCIES_FOR_TESTING python3-click
138+
- echo "Load submodules"
139+
- git submodule sync
140+
- git submodule update --init --checkout third_party/{eqy,sby}
141+
- echo "Prepare eqy"
142+
- make build_eqy build_sby -j $(nproc)
133143
- echo "Start testing"
134144
- export PATH="$PWD/out/current/bin:$PATH"
135145
- ./run_fv_tests.mk -j $(nproc) TEST_SUITE_DIR:="$DIR" TEST_SUITE_NAME:="$NAME" test
136146
- echo "Gather tests results"
137-
- list_file="build/$NAME.performed_tests_list.txt"
138-
- for result_json in build/tests/*/*/result.json; do
139-
- test_name=$(jq -r '.name' "${result_json}")
140-
- printf '%s:%s\n' "$NAME" "${test_name}" >> "$list_file"
141-
- done
142-
- set -o pipefail
143-
- python3 ./tests/formal/results.py "build/tests/${NAME}" | tee "build/${NAME}_summary.txt"
147+
- ./tests/formal/gather_fv_results.sh $NAME
144148
artifacts:
145149
when: always
146150
paths:
@@ -161,21 +165,17 @@ formal_verification_yosys_tests:
161165
script:
162166
- echo "Install dependencies"
163167
- apt update
164-
- apt install -y $DEPENDENCIES_FOR_TESTING
168+
- apt install -y $DEPENDENCIES_FOR_TESTING python3-click
165169
- echo "Load submodules"
166170
- git submodule sync
167-
- git submodule update --init --recursive third_party/yosys
171+
- git submodule update --init --checkout third_party/{eqy,sby,yosys}
172+
- echo "Prepare eqy"
173+
- make build_eqy build_sby -j $(nproc)
168174
- echo "Start testing"
169175
- export PATH="$PWD/out/current/bin:$PATH"
170176
- ./run_fv_tests.mk -j $(nproc) TEST_SUITE_DIR:="$DIR" TEST_SUITE_NAME:="$NAME" test
171177
- echo "Gather tests results"
172-
- list_file="build/$NAME.performed_tests_list.txt"
173-
- for result_json in build/tests/*/*/result.json; do
174-
- test_name=$(jq -r '.name' "${result_json}")
175-
- printf '%s:%s\n' "$NAME" "${test_name}" >> "$list_file"
176-
- done
177-
- set -o pipefail
178-
- python3 ./tests/formal/results.py "build/tests/${NAME}" | tee "build/${NAME}_summary.txt"
178+
- ./tests/formal/gather_fv_results.sh $NAME
179179
artifacts:
180180
when: always
181181
paths:
@@ -196,45 +196,22 @@ formal_verification_sv2v_tests:
196196
script:
197197
- echo "Install dependencies"
198198
- apt update
199-
- apt install -y $DEPENDENCIES_FOR_TESTING
199+
- apt install -y $DEPENDENCIES_FOR_TESTING python3-click
200200
- echo "Load submodules"
201201
- git submodule sync
202-
- git submodule update --init --recursive --checkout third_party/sv2v
202+
- git submodule update --init --checkout third_party/{sv2v,eqy,sby}
203+
- echo "Prepare eqy"
204+
- make build_eqy build_sby -j $(nproc)
203205
- echo "Start testing"
204206
- export PATH="$PWD/out/current/bin:$PATH"
205207
- ./run_fv_tests.mk -j $(nproc) TEST_SUITE_DIR:="$DIR" TEST_SUITE_NAME:="$NAME" test
206208
- echo "Gather tests results"
207-
- list_file="build/$NAME.performed_tests_list.txt"
208-
- for result_json in build/tests/*/*/result.json; do
209-
- test_name=$(jq -r '.name' "${result_json}")
210-
- printf '%s:%s\n' "$NAME" "${test_name}" >> "$list_file"
211-
- done
212-
- set -o pipefail
213-
- python3 ./tests/formal/results.py "build/tests/${NAME}" | tee "build/${NAME}_summary.txt"
209+
- ./tests/formal/gather_fv_results.sh $NAME
214210
artifacts:
215211
when: always
216212
paths:
217213
- build/
218214

219-
verify_formal_tests_passlist:
220-
stage: verify_formal_tests_passlist
221-
dependencies: [formal_verification_simple_tests, formal_verification_yosys_tests, formal_verification_sv2v_tests]
222-
only:
223-
- main
224-
- merge_requests
225-
script:
226-
- echo "Check if every test from passlist.txt was executed"
227-
- sort build/*.performed_tests_list.txt > performed_tests_list.txt
228-
- cat tests/formal/passlist.txt | sed '/^#/d' | sort > sorted_passlist.txt
229-
- readarray not_performed_tests < <(comm -13 performed_tests_list.txt sorted_passlist.txt)
230-
- if (( ${#not_performed_tests[@]} > 0 )); then
231-
- printf '\x1b[1mTests from passlist.txt that were not performed:\x1b[0m\n'
232-
- printf '\x1b[91m%s\x1b[0m\n' "${not_performed_tests[@]}"
233-
- exit 1
234-
- else
235-
- exit 0
236-
- fi
237-
238215
veer_synth_large_design:
239216
stage: run_large_designs_tests
240217
dependencies: [build_binaries]

.github/scripts/run_group_test.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@ test_cases=( $(cd ${REPO_DIR}/tests && echo simple_tests/!(${filter_pat})) )
4141
global_status=0
4242
mkdir -p "$(dirname "$RESULTS_FILE")"
4343

44+
declare -a failed_tests_list
45+
4446
# Test
4547

4648
cd $REPO_DIR
4749
for test_case in "${test_cases[@]}"; do
48-
printf '::group::%s\n' "$test_case"
50+
if [ -n "$GITHUB_ACTIONS" ]; then
51+
printf '::group::%s\n' "$test_case"
52+
else
53+
printf "# %s #\n" "$test_case"
54+
fi
4955
export test_case
5056
test_name="${test_case//tests\//}"
5157
test_name="${test_name//\//_}"
@@ -119,9 +125,25 @@ for test_case in "${test_cases[@]}"; do
119125
fi
120126

121127
printf '%d\t%d\t%s\n' "$test_ok" "$asan_ok" "$test_name" >> "$RESULTS_FILE"
122-
printf '::endgroup::\n'
128+
if [ -n "$GITHUB_ACTIONS" ]; then
129+
printf '::endgroup::\n'
130+
else
131+
if (( $test_ok == 1 )); then
132+
printf "| PASS\n\n"
133+
else
134+
failed_tests_list+=("$test_name")
135+
fi
136+
fi
123137
done
124138

139+
if [ -z "$GITHUB_ACTIONS" ] && [[ $global_status -ne 0 ]]; then
140+
echo "Failed tests list:"
141+
for test_name in ${failed_tests_list[@]}
142+
do
143+
echo $test_name
144+
done
145+
fi
146+
125147
# Leave with non-zero error status if any test failed
126148
if [[ $global_status -ne 0 ]]; then
127149
exit 1

.github/scripts/sort_passlists.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ declare -r SELF_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
77
declare -r REPO_DIR=$SELF_DIR/../..
88
cd $REPO_DIR
99

10-
files_to_sort_check=(
11-
tests/formal/passlist.txt
12-
tests/opentitan/opentitan_parsing_test/ot_cores_passlist.txt
13-
)
10+
opentitan_passlist="tests/opentitan/opentitan_parsing_test/ot_cores_passlist.txt"
11+
formal_testlist="tests/formal/testlist.json"
1412

15-
for f in "${files_to_sort_check[@]}"; do
16-
LC_ALL=C.UTF-8 sort -f -u -o $f $f
17-
done
13+
LC_ALL=C.UTF-8 sort -f -u -o $opentitan_passlist $opentitan_passlist
14+
15+
cat $formal_testlist | jq -s -c 'sort_by(.d) | .[]' | python3 -m json.tool > ${formal_testlist}.tmp
16+
mv ${formal_testlist}.tmp $formal_testlist

.github/workflows/formal-verification.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
libgoogle-perftools-dev \
5757
python3 \
5858
python3-dev \
59+
python3-click \
5960
swig \
6061
tcl-dev \
6162
tclsh \
@@ -68,8 +69,7 @@ jobs:
6869
run: |
6970
git submodule sync
7071
git submodule update --depth 1 --init --recursive --checkout \
71-
third_party/yosys \
72-
third_party/sv2v \
72+
third_party/{yosys,sv2v,eqy,sby} \
7373
;
7474
7575
- name: Download binaries
@@ -87,6 +87,10 @@ jobs:
8787
name: sv2v
8888
path: out/current/bin/
8989

90+
- name: Build eqy and sby
91+
run: |
92+
make build_eqy build_sby -j$(nproc)
93+
9094
- name: Test
9195
run: |
9296
chmod +x out/current/bin/sv2v
@@ -99,17 +103,12 @@ jobs:
99103
100104
- name: Generate list of performed tests
101105
run: |
102-
list_file="build/${TEST_SUITE_NAME}.performed_tests_list.txt"
103-
touch "$list_file"
104-
for result_json in build/tests/*/*/result.json; do
105-
test_name=$(jq -r '.name' "${result_json}")
106-
printf '%s:%s\n' "${TEST_SUITE_NAME}" "${test_name}" >> "$list_file"
107-
done
106+
./tests/formal/gather_fv_results.sh $NAME
108107
109108
- name: Pack formal verification logs
110109
run: |
111110
cd build
112-
tar cf ${TEST_SUITE_NAME}.tar tests/*/*/*.out tests/*/*/slpp_all/*.log tests/*/*/*.txt tests/*/*/result.json
111+
tar cf ${TEST_SUITE_NAME}.tar tests/*/*
113112
114113
- name: Upload formal verification logs
115114
uses: actions/upload-artifact@v2

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Install dependencies
4343
run: |
4444
apt-get update -q
45-
apt-get install -y clang-format
45+
apt-get install -y git clang-format python3 jq
4646
4747
- name: Sources format check
4848
run: |
@@ -243,20 +243,20 @@ jobs:
243243
run: |
244244
export PATH=$PWD/install/bin:/usr/local/bin:${PATH}
245245
wget -qO- https://get.haskellstack.org/ | sh -s - -f -d /usr/local/bin
246-
make -j$(nproc) -C $PWD/third_party/sv2v
246+
make build_sv2v -j$(nproc)
247247
248248
- name: Upload binaries
249249
uses: actions/upload-artifact@v2
250250
with:
251251
name: sv2v
252252
path: |
253-
third_party/sv2v/bin/sv2v
253+
out/release/bin/sv2v
254254
255255
- name: Save build results to cache
256256
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' && ! (failure() || cancelled()) }}
257257
uses: actions/cache/save@v3
258258
with:
259-
path: third_party/sv2v/bin/sv2v
259+
path: out/release/bin/sv2v
260260
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
261261

262262
- name: Upload load graphs

.gitmodules

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,11 @@
5252
path = third_party/OpenROAD-flow-scripts
5353
url = https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts.git
5454
update = none
55+
[submodule "third_party/sby"]
56+
path = third_party/sby
57+
url = https://github.com/YosysHQ/sby
58+
update = none
59+
[submodule "third_party/eqy"]
60+
path = third_party/eqy
61+
url = https://github.com/YosysHQ/eqy
62+
update = none

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ list :
337337
printf ' %s\n' \
338338
'list ${F.D}|${F.!D} help' \
339339
'build' \
340+
'build_eqy' \
341+
'build_sby' \
342+
'build_sv2v' \
340343
'install' \
341344
'clean' \
342345
;
@@ -363,6 +366,21 @@ help : list
363366
.PHONY: build
364367
build : $(foreach t,${GetTargetsList}, @${t})
365368

369+
.PHONY: build_eqy
370+
build_eqy : ${OUT_DIR}/bin/yosys-config
371+
export PATH="$(realpath ${OUT_DIR})/bin:${PATH}"
372+
${MAKE} -C third_party/eqy install PREFIX=$(realpath ${OUT_DIR})
373+
374+
.PHONY: build_sby
375+
build_sby : ${OUT_DIR}/bin/yosys-config
376+
export PATH="$(realpath ${OUT_DIR})/bin:${PATH}"
377+
${MAKE} -C third_party/sby install PREFIX=$(realpath ${OUT_DIR})
378+
379+
.PHONY: build_sv2v
380+
build_sv2v :
381+
${MAKE} -C ./third_party/sv2v
382+
mkdir -p ${OUT_DIR}/bin
383+
cp ./third_party/sv2v/bin/sv2v ${OUT_DIR}/bin/sv2v
366384

367385
.PHONY: install
368386
install : $(foreach t,${GetTargetsList}, install@${t})

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ If you encounter any problems with it, please compare the results with a single
152152

153153
#### Prerequisites
154154

155+
##### `sv2v`
156+
155157
Formal Verification uses `sv2v` tool and tests from its repository, which is available as a submodule.
156158
To download the sv2v submodule run:
157159

@@ -164,9 +166,25 @@ To build sv2v and copy it to `out/current/bin` (where it is expected to be by th
164166

165167
<!-- name="sv2v-build" -->
166168
``` bash
167-
wget -qO- https://get.haskellstack.org/ | sh -s - -f -d $PWD/out/current/bin
168-
make -j$(nproc) -C $PWD/third_party/sv2v
169-
cp ./third_party/sv2v/bin/sv2v ./out/current/bin
169+
wget -qO- https://get.haskellstack.org/ | sh -s - -f -d $PWD/out/current/bin
170+
make build_sv2v -j$(nproc)
171+
```
172+
173+
##### `eqy` and `sby`
174+
175+
Formal Verification proves design equivalence using `eqy` and `sby` tools, which are included as submodules.
176+
To checkout the `eqy` and `sby` submodules, run:
177+
178+
<!-- name="eqy-sby-update" -->
179+
``` bash
180+
git submodule update --init --checkout third_party/{eqy,sby}
181+
```
182+
183+
To build `eqy` and `sby` run:
184+
185+
<!-- name="eqy-sby-build" -->
186+
``` bash
187+
make build_eqy build_sby -j$(nproc)
170188
```
171189

172190
#### Testing
@@ -189,9 +207,18 @@ To start formal verification tests, use `run_fv_tests.mk`, either as an executab
189207
* `test_suite_dir` - path to a tests directory (e.g. `./yosys/tests`). Required by all targets except `help`.
190208
* `test_suite_name` - when specified, it is used as a name of a directory inside `./build/` where results are stored. Otherwise results are stored directly inside the `./build/` directory.
191209

192-
`yosys` and `sv2v` must be present in one of `PATH` directories.
210+
To gather formal verification results use:
211+
``` bash
212+
./tests/formal/gather_fv_results.sh \
213+
TEST_SUITE_NAME:=<test_suite_name>
214+
```
215+
193216
For other dependencies, please see the `.github/workflows/formal-verification.yml` file.
194217

218+
#### More details
219+
220+
[Formal Verification README](https://github.com/chipsalliance/synlig/tree/main/tests/formal)
221+
195222
#### Available Targets
196223

197224
* ``help`` - Prints help.

0 commit comments

Comments
 (0)