3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-03-23 04:49:15 +00:00

Convert autotest script wrapper

This commit is contained in:
Miodrag Milanovic 2026-03-16 13:07:11 +01:00
parent 896fac04ed
commit 488f144245
10 changed files with 101 additions and 110 deletions

View file

@ -42,10 +42,10 @@ MK_TEST_DIRS += ./verilog
# Tests that don't generate .mk
SH_TEST_DIRS =
#SH_TEST_DIRS += ./simple
#SH_TEST_DIRS += ./simple_abc9
#SH_TEST_DIRS += ./hana
#SH_TEST_DIRS += ./asicworld
MK_TEST_DIRS += ./simple
MK_TEST_DIRS += ./simple_abc9
MK_TEST_DIRS += ./hana
MK_TEST_DIRS += ./asicworld
#SH_TEST_DIRS += ./realmath
#SH_TEST_DIRS += ./share
#SH_TEST_DIRS += ./opt_share

View file

@ -0,0 +1,8 @@
#!/usr/bin/env python3
import sys
sys.path.append("..")
import gen_tests_makefile
gen_tests_makefile.generate_autotest("*.v", "-e")

View file

@ -1,15 +0,0 @@
#!/usr/bin/env bash
source ../common-env.sh
OPTIND=1
seed="" # default to no seed specified
while getopts "S:" opt
do
case "$opt" in
S) arg="${OPTARG#"${OPTARG%%[![:space:]]*}"}" # remove leading space
seed="SEED=$arg" ;;
esac
done
shift "$((OPTIND-1))"
exec ${MAKE:-make} -f ../tools/autotest.mk $seed EXTRA_FLAGS+="-e" *.v

View file

@ -110,3 +110,23 @@ def generate_custom(callback, extra=None):
callback()
finally:
sys.stdout = old
def generate_autotest_file(test_file):
cmd = f"../tools/autotest.sh -G -j ${{SEEDOPT}} ${{EXTRA_FLAGS}} {test_file} >/dev/null 2>&1"
generate_target(test_file, cmd)
def generate_autotest(pattern, extra_flags):
with open("Makefile", "w") as f:
old = sys.stdout
sys.stdout = f
try:
print_header([ f"EXTRA_FLAGS = {extra_flags}",
"SEED ?=",
"ifneq ($(strip $(SEED)),)",
" SEEDOPT=-S$(SEED)",
"endif"
])
for f in sorted(glob.glob(pattern)):
generate_autotest_file(f)
finally:
sys.stdout = old

View file

@ -0,0 +1,8 @@
#!/usr/bin/env python3
import sys
sys.path.append("..")
import gen_tests_makefile
gen_tests_makefile.generate_autotest("test_*.v", "-l hana_vlib.v -n 300 -e")

View file

@ -1,15 +0,0 @@
#!/usr/bin/env bash
source ../common-env.sh
OPTIND=1
seed="" # default to no seed specified
while getopts "S:" opt
do
case "$opt" in
S) arg="${OPTARG#"${OPTARG%%[![:space:]]*}"}" # remove leading space
seed="SEED=$arg" ;;
esac
done
shift "$((OPTIND-1))"
exec ${MAKE:-make} -f ../tools/autotest.mk $seed EXTRA_FLAGS="-l hana_vlib.v -n 300 -e" test_*.v

View file

@ -0,0 +1,17 @@
#!/usr/bin/env python3
import sys
sys.path.append("..")
import shutil
# ----------------------
# Check if iverilog is installed
# ----------------------
if shutil.which("iverilog") is None:
print("Error: Icarus Verilog 'iverilog' not found.", file=sys.stderr)
sys.exit(1)
import gen_tests_makefile
gen_tests_makefile.generate_autotest("*.*v", "")

View file

@ -1,21 +0,0 @@
#!/usr/bin/env bash
source ../common-env.sh
OPTIND=1
seed="" # default to no seed specified
while getopts "S:" opt
do
case "$opt" in
S) arg="${OPTARG#"${OPTARG%%[![:space:]]*}"}" # remove leading space
seed="SEED=$arg" ;;
esac
done
shift "$((OPTIND-1))"
# check for Icarus Verilog
if ! command -v iverilog > /dev/null ; then
echo "$0: Error: Icarus Verilog 'iverilog' not found."
exit 1
fi
exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.{sv,v}

View file

@ -0,0 +1,44 @@
#!/usr/bin/env python3
import sys
sys.path.append("..")
import shutil
import os
from pathlib import Path
# ----------------------
# Check if iverilog is installed
# ----------------------
if shutil.which("iverilog") is None:
print("Error: Icarus Verilog 'iverilog' not found.", file=sys.stderr)
sys.exit(1)
src_dir = Path("../simple")
# ----------------------
# Copy all files from ../simple to current directory
# ----------------------
for file in src_dir.glob("*.v"):
shutil.copy(file, os.path.join(".", file.name))
for file in src_dir.glob("*.sv"):
shutil.copy(file, os.path.join(".", file.name))
# bug 2675
bug_file = os.path.join(".", "specify.v")
if os.path.exists(bug_file):
os.remove(bug_file)
import gen_tests_makefile
gen_tests_makefile.generate_autotest("*.*v", "-f \"verilog -noblackbox -specify\" -n 300 -p '\
read_verilog -icells -lib +/abc9_model.v; \
hierarchy; \
synth -run coarse; \
opt -full; \
techmap; \
abc9 -lut 4; \
clean; \
check -assert * abc9_test037 %d; \
select -assert-none t:?_NOT_ t:?_AND_ %%; \
setattr -mod -unset blackbox -unset whitebox =*'")

View file

@ -1,55 +0,0 @@
#!/usr/bin/env bash
source ../common-env.sh
OPTIND=1
seed="" # default to no seed specified
while getopts "S:" opt
do
case "$opt" in
S) arg="${OPTARG#"${OPTARG%%[![:space:]]*}"}" # remove leading space
seed="SEED=$arg" ;;
esac
done
shift "$((OPTIND-1))"
# check for Icarus Verilog
if ! command -v iverilog > /dev/null ; then
echo "$0: Error: Icarus Verilog 'iverilog' not found."
exit 1
fi
for file in `ls *.v *.sv`; do
if [ ! -f "../simple/$file" -a "$file" != "abc9.v" ]; then
echo "Warning: $file is in simple_abc9/, but not in simple/"
backup="$file.bak"
if [ -f "$backup" ]; then
if cmp "$file" "$backup" > /dev/null; then
echo " => $backup already exists and matches; removing $file"
rm "$file"
else
echo " => $backup already exists but differs; leaving $file in place"
fi
else
echo " => moving $file to $backup"
mv -i "$file" "$backup"
fi
fi
done
cp ../simple/*.v .
cp ../simple/*.sv .
rm specify.v # bug 2675
DOLLAR='?'
exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.v *.sv EXTRA_FLAGS="-f \"verilog -noblackbox -specify\" -n 300 -p '\
read_verilog -icells -lib +/abc9_model.v; \
hierarchy; \
synth -run coarse; \
opt -full; \
techmap; \
abc9 -lut 4; \
clean; \
check -assert * abc9_test037 %d; \
select -assert-none t:${DOLLAR}_NOT_ t:${DOLLAR}_AND_ %%; \
setattr -mod -unset blackbox -unset whitebox =*'"
# NOTE: Skip 'check -assert' on abc9_test037 because it intentionally has a combinatorial loop