2020-09-16 10:59:37 -05:00
|
|
|
set -eu
|
|
|
|
|
|
|
|
YOSYS_BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../ >/dev/null 2>&1 && pwd)"
|
|
|
|
|
|
|
|
# $ generate_target target_name test_command
|
|
|
|
generate_target() {
|
|
|
|
target_name=$1
|
|
|
|
test_command=$2
|
2020-09-16 12:58:16 -05:00
|
|
|
echo "all: $target_name"
|
2020-09-16 10:59:37 -05:00
|
|
|
echo ".PHONY: $target_name"
|
|
|
|
echo "$target_name:"
|
|
|
|
printf "\t@%s\n" "$test_command"
|
|
|
|
printf "\t@echo 'Passed %s'\n" "$target_name"
|
|
|
|
}
|
|
|
|
|
|
|
|
# $ generate_ys_test ys_file [yosys_args]
|
|
|
|
generate_ys_test() {
|
|
|
|
ys_file=$1
|
2024-02-12 05:58:13 -06:00
|
|
|
yosys_args_=${2:-}
|
|
|
|
generate_target "$ys_file" "\"$YOSYS_BASEDIR/yosys\" -ql ${ys_file%.*}.log $yosys_args_ $ys_file"
|
2020-09-16 10:59:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# $ generate_bash_test bash_file
|
|
|
|
generate_bash_test() {
|
|
|
|
bash_file=$1
|
|
|
|
generate_target "$bash_file" "bash -v $bash_file >${bash_file%.*}.log 2>&1"
|
|
|
|
}
|
|
|
|
|
|
|
|
# $ generate_tests [-y|--yosys-scripts] [-s|--prove-sv] [-b|--bash] [-a|--yosys-args yosys_args]
|
|
|
|
generate_tests() {
|
|
|
|
do_ys=false
|
|
|
|
do_sv=false
|
|
|
|
do_sh=false
|
|
|
|
yosys_args=""
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
arg="$1"
|
|
|
|
case "$arg" in
|
|
|
|
-y|--yosys-scripts)
|
|
|
|
do_ys=true
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-s|--prove-sv)
|
|
|
|
do_sv=true
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-b|--bash)
|
|
|
|
do_sh=true
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-a|--yosys-args)
|
|
|
|
yosys_args+="$2"
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "Unknown argument: $1"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ ! ( $do_ys = true || $do_sv = true || $do_sh = true ) ]]; then
|
|
|
|
echo >&2 "Error: No file types selected"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ".PHONY: all"
|
2020-09-16 12:58:16 -05:00
|
|
|
echo "all:"
|
2020-09-16 10:59:37 -05:00
|
|
|
|
|
|
|
if [[ $do_ys = true ]]; then
|
|
|
|
for x in *.ys; do
|
|
|
|
generate_ys_test "$x" "$yosys_args"
|
|
|
|
done
|
|
|
|
fi;
|
|
|
|
if [[ $do_sv = true ]]; then
|
|
|
|
for x in *.sv; do
|
|
|
|
if [ ! -f "${x%.sv}.ys" ]; then
|
2024-01-22 10:44:05 -06:00
|
|
|
generate_ys_test "$x" "-p \"prep -top top; async2sync; sat -enable_undef -verify -prove-asserts\" $yosys_args"
|
2020-09-16 10:59:37 -05:00
|
|
|
fi;
|
|
|
|
done
|
|
|
|
fi;
|
|
|
|
if [[ $do_sh == true ]]; then
|
|
|
|
for s in *.sh; do
|
|
|
|
if [ "$s" != "run-test.sh" ]; then
|
|
|
|
generate_bash_test "$s"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
run_tests() {
|
|
|
|
generate_tests "$@" > run-test.mk
|
|
|
|
exec ${MAKE:-make} -f run-test.mk
|
|
|
|
}
|