mirror of
https://github.com/YosysHQ/yosys
synced 2026-03-23 04:49:15 +00:00
Use generic testing on few more places
This commit is contained in:
parent
80fff7ce09
commit
af3a53720c
7 changed files with 82 additions and 150 deletions
|
|
@ -23,6 +23,7 @@ MK_TEST_DIRS += ./arch/nexus
|
|||
MK_TEST_DIRS += ./arch/quicklogic/pp3
|
||||
MK_TEST_DIRS += ./arch/quicklogic/qlf_k6n10f
|
||||
MK_TEST_DIRS += ./arch/xilinx
|
||||
MK_TEST_DIRS += ./bind
|
||||
MK_TEST_DIRS += ./bugpoint
|
||||
MK_TEST_DIRS += ./opt
|
||||
MK_TEST_DIRS += ./sat
|
||||
|
|
@ -70,8 +71,8 @@ SH_TEST_DIRS =
|
|||
# Tests that don't generate .mk and need special args
|
||||
SH_ABC_TEST_DIRS =
|
||||
#SH_ABC_TEST_DIRS += ./memories
|
||||
#SH_ABC_TEST_DIRS += ./aiger
|
||||
#SH_ABC_TEST_DIRS += ./alumacc
|
||||
MK_TEST_DIRS += ./aiger
|
||||
MK_TEST_DIRS += ./alumacc
|
||||
|
||||
all: vanilla-test
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
sys.path.append("..")
|
||||
|
||||
import gen_tests_makefile
|
||||
|
||||
import glob
|
||||
import os
|
||||
|
||||
yosys = "../../yosys"
|
||||
default_abc = "../../yosys-abc"
|
||||
|
||||
aags = sorted(glob.glob("*.aag"))
|
||||
yss = sorted(glob.glob("*.ys"))
|
||||
|
||||
print("ABC ?= " + default_abc)
|
||||
print("YOSYS ?= " + yosys)
|
||||
print()
|
||||
|
||||
def base(fn):
|
||||
return os.path.splitext(fn)[0]
|
||||
|
||||
|
|
@ -23,46 +18,41 @@ def base(fn):
|
|||
# Since ABC cannot read *.aag, read the *.aig instead
|
||||
# (which would have been created by the reference aig2aig utility,
|
||||
# available from http://fmv.jku.at/aiger/)
|
||||
def create_tests():
|
||||
aags = sorted(glob.glob("*.aag"))
|
||||
yss = sorted(glob.glob("*.ys"))
|
||||
for aag in aags:
|
||||
b = base(aag)
|
||||
|
||||
for aag in aags:
|
||||
b = base(aag)
|
||||
cmd = [
|
||||
f"$(ABC) -q \"read -c {b}.aig; write {b}_ref.v\" >/dev/null 2>&1;",
|
||||
"$(YOSYS) -qp \"",
|
||||
f"read_verilog {b}_ref.v;",
|
||||
"prep;",
|
||||
"design -stash gold;",
|
||||
f"read_aiger -clk_name clock {aag};",
|
||||
"prep;",
|
||||
"design -stash gate;",
|
||||
"design -import gold -as gold;",
|
||||
"design -import gate -as gate;",
|
||||
"miter -equiv -flatten -make_assert -make_outputs gold gate miter;",
|
||||
"sat -verify -prove-asserts -show-ports -seq 16 miter;",
|
||||
f"\" -l {aag}.log >/dev/null 2>&1"
|
||||
]
|
||||
|
||||
print(f"all: {aag}")
|
||||
print(f".PHONY: {aag}")
|
||||
print(f"{aag}:")
|
||||
print(f"\t@echo Checking {aag}.")
|
||||
print(f"\t@$(ABC) -q \"read -c {b}.aig; write {b}_ref.v\" >/dev/null 2>&1")
|
||||
print("\t@$(YOSYS) -qp \"\\")
|
||||
print(f"\tread_verilog {b}_ref.v; \\")
|
||||
print("\tprep; \\")
|
||||
print("\tdesign -stash gold; \\")
|
||||
print(f"\tread_aiger -clk_name clock {aag}; \\")
|
||||
print("\tprep; \\")
|
||||
print("\tdesign -stash gate; \\")
|
||||
print("\tdesign -import gold -as gold; \\")
|
||||
print("\tdesign -import gate -as gate; \\")
|
||||
print("\tmiter -equiv -flatten -make_assert -make_outputs gold gate miter; \\")
|
||||
print("\tsat -verify -prove-asserts -show-ports -seq 16 miter; \\")
|
||||
print(f"\t\" -l {aag}.log >/dev/null 2>&1")
|
||||
print()
|
||||
gen_tests_makefile.generate_cmd_test(aag, cmd)
|
||||
|
||||
# ---- Yosys script tests ----
|
||||
for ys in yss:
|
||||
b = base(ys)
|
||||
print(f"all: {ys}")
|
||||
print(f".PHONY: {ys}")
|
||||
print(f"{ys}: ")
|
||||
print(f"\t@echo Running {ys}.")
|
||||
print(f"\t@$(YOSYS) -ql {b}.log {ys} >/dev/null 2>&1")
|
||||
print()
|
||||
# ---- Yosys script tests ----
|
||||
for ys in yss:
|
||||
gen_tests_makefile.generate_ys_test(ys)
|
||||
|
||||
# ---- aigmap test ----
|
||||
print(f"all: aigmap")
|
||||
print(f".PHONY: aigmap")
|
||||
print("aigmap:")
|
||||
print("\t@echo Running aigmap.")
|
||||
print("\t@rm -rf gate; mkdir gate")
|
||||
print('\t@$(YOSYS) --no-version -p "test_cell -aigmap -w gate/ -n 1 -s 1 all" >/dev/null 2>&1')
|
||||
print("\t@set -o pipefail; diff --brief gold gate | tee aigmap.err")
|
||||
print("\t@rm -f aigmap.err")
|
||||
print()
|
||||
cmd = [ "rm -rf gate; mkdir gate;",
|
||||
"$(YOSYS) --no-version -p \"test_cell -aigmap -w gate/ -n 1 -s 1 all\" >/dev/null 2>&1;",
|
||||
"set -o pipefail; diff --brief gold gate | tee aigmap.err;",
|
||||
"rm -f aigmap.err" ]
|
||||
|
||||
gen_tests_makefile.generate_cmd_test("aigmap", cmd)
|
||||
|
||||
extra = [ f"ABC ?= {gen_tests_makefile.yosys_basedir}/yosys-abc" ]
|
||||
|
||||
gen_tests_makefile.generate_custom(create_tests, extra)
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
source ../common-env.sh
|
||||
|
||||
set -e
|
||||
|
||||
OPTIND=1
|
||||
abcprog="../../yosys-abc" # default to built-in version of abc
|
||||
while getopts "A:" opt
|
||||
do
|
||||
case "$opt" in
|
||||
A) abcprog="$OPTARG" ;;
|
||||
esac
|
||||
done
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
# NB: *.aag and *.aig must contain a symbol table naming the primary
|
||||
# inputs and outputs, otherwise ABC and Yosys will name them
|
||||
# arbitrarily (and inconsistently with each other).
|
||||
|
||||
for aag in *.aag; do
|
||||
# Since ABC cannot read *.aag, read the *.aig instead
|
||||
# (which would have been created by the reference aig2aig utility,
|
||||
# available from http://fmv.jku.at/aiger/)
|
||||
echo "Checking $aag."
|
||||
$abcprog -q "read -c ${aag%.*}.aig; write ${aag%.*}_ref.v" >/dev/null 2>&1
|
||||
../../yosys -qp "
|
||||
read_verilog ${aag%.*}_ref.v
|
||||
prep
|
||||
design -stash gold
|
||||
read_aiger -clk_name clock $aag
|
||||
prep
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports -seq 16 miter
|
||||
" -l ${aag}.log >/dev/null 2>&1
|
||||
done
|
||||
|
||||
for aig in *.aig; do
|
||||
echo "Checking $aig."
|
||||
$abcprog -q "read -c $aig; write ${aig%.*}_ref.v" >/dev/null 2>&1
|
||||
../../yosys -qp "
|
||||
read_verilog ${aig%.*}_ref.v
|
||||
prep
|
||||
design -stash gold
|
||||
read_aiger -clk_name clock $aig
|
||||
prep
|
||||
design -stash gate
|
||||
design -import gold -as gold
|
||||
design -import gate -as gate
|
||||
miter -equiv -flatten -make_assert -make_outputs gold gate miter
|
||||
sat -verify -prove-asserts -show-ports -seq 16 miter
|
||||
" -l ${aig}.log >/dev/null 2>&1
|
||||
done
|
||||
|
||||
for y in *.ys; do
|
||||
echo "Running $y."
|
||||
../../yosys -ql ${y%.*}.log $y >/dev/null 2>&1
|
||||
done
|
||||
|
||||
# compare aigmap with reference
|
||||
# make gold with: rm gold/*; yosys --no-version -p "test_cell -aigmap -w gold/ -n 1 -s 1 all"
|
||||
rm -rf gate; mkdir gate
|
||||
../../yosys --no-version -p "test_cell -aigmap -w gate/ -n 1 -s 1 all" >/dev/null 2>&1
|
||||
(
|
||||
set -o pipefail
|
||||
diff --brief gold gate | tee aigmap.err
|
||||
)
|
||||
rm aigmap.err
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
source ../common-env.sh
|
||||
set -e
|
||||
for x in *.ys; do
|
||||
echo "Running $x.."
|
||||
../../yosys -ql ${x%.ys}.log $x
|
||||
done
|
||||
8
tests/bind/generate_mk.py
Normal file
8
tests/bind/generate_mk.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
sys.path.append("..")
|
||||
|
||||
import gen_tests_makefile
|
||||
|
||||
gen_tests_makefile.generate(["--yosys-scripts"])
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
{
|
||||
echo "all::"
|
||||
for x in *.ys; do
|
||||
echo "all:: run-$x"
|
||||
echo "run-$x:"
|
||||
echo " @echo 'Running $x..'"
|
||||
echo " @../../yosys -ql ${x%.ys}.log $x"
|
||||
done
|
||||
for s in *.sh; do
|
||||
if [ "$s" != "run-test.sh" ]; then
|
||||
echo "all:: run-$s"
|
||||
echo "run-$s:"
|
||||
echo " @echo 'Running $s..'"
|
||||
echo " @bash $s"
|
||||
fi
|
||||
done
|
||||
} > run-test.mk
|
||||
exec ${MAKE:-make} -f run-test.mk
|
||||
|
|
@ -12,11 +12,12 @@ def _cwd_base():
|
|||
return os.path.basename(os.getcwd())
|
||||
|
||||
def generate_target(name, command):
|
||||
target = f"{_cwd_base()}-{name}"
|
||||
#target = f"{_cwd_base()}-{name}"
|
||||
target = f"{name}"
|
||||
print(f"all: {target}")
|
||||
print(f".PHONY: {target}")
|
||||
print(f"{target}:")
|
||||
print(f"\t@@$(call run_test,{target}, \\")
|
||||
print(f"\t@$(call run_test,{target}, \\")
|
||||
print(f"\tYOSYS_MAX_THREADS=4 {command})")
|
||||
|
||||
def generate_ys_test(ys_file, yosys_args=""):
|
||||
|
|
@ -38,6 +39,16 @@ def generate_bash_test(sh_file):
|
|||
cmd = f"bash -v {sh_file} >{sh_file}.err 2>&1 && mv {sh_file}.err {sh_file}.log"
|
||||
generate_target(sh_file, cmd)
|
||||
|
||||
def unpack_cmd(cmd):
|
||||
if isinstance(cmd, str):
|
||||
return cmd
|
||||
if isinstance(cmd, (list, tuple)):
|
||||
return " \\\n".join(cmd)
|
||||
raise TypeError("cmd must be a string or a list/tuple of strings")
|
||||
|
||||
def generate_cmd_test(test_name, cmd, yosys_args=""):
|
||||
generate_target(test_name, unpack_cmd(cmd))
|
||||
|
||||
def generate_tests(argv):
|
||||
parser = argparse.ArgumentParser(add_help=False)
|
||||
parser.add_argument("-y", "--yosys-scripts", action="store_true")
|
||||
|
|
@ -85,3 +96,22 @@ def generate(argv, extra=None):
|
|||
generate_tests(argv)
|
||||
finally:
|
||||
sys.stdout = old
|
||||
|
||||
def generate_custom(callback, extra=None):
|
||||
with open("Makefile", "w") as f:
|
||||
old = sys.stdout
|
||||
sys.stdout = f
|
||||
try:
|
||||
print(f"include {common_mk}")
|
||||
print(f"YOSYS ?= {yosys_basedir}/yosys")
|
||||
if extra:
|
||||
for line in extra:
|
||||
print(line)
|
||||
print()
|
||||
print(".PHONY: all")
|
||||
print("all:")
|
||||
print()
|
||||
|
||||
callback()
|
||||
finally:
|
||||
sys.stdout = old
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue