mirror of
https://github.com/YosysHQ/yosys
synced 2026-03-23 04:49:15 +00:00
Convert memories tests
This commit is contained in:
parent
77147fb0db
commit
92bdccf2be
5 changed files with 65 additions and 101 deletions
|
|
@ -79,8 +79,7 @@ MK_TEST_DIRS += ./asicworld
|
|||
#endif
|
||||
|
||||
# Tests that don't generate .mk and need special args
|
||||
SH_ABC_TEST_DIRS =
|
||||
#SH_ABC_TEST_DIRS += ./memories
|
||||
MK_TEST_DIRS += ./memories
|
||||
MK_TEST_DIRS += ./aiger
|
||||
MK_TEST_DIRS += ./alumacc
|
||||
|
||||
|
|
@ -94,13 +93,6 @@ seed-./%: %/run-test.sh
|
|||
+cd $* && bash run-test.sh $(SEEDOPT)
|
||||
+@echo "...passed tests in $*"
|
||||
|
||||
# abcopt-./ is a dummy string, not a directory
|
||||
.PHONY: abcopt-tests
|
||||
abcopt-tests: $(SH_ABC_TEST_DIRS:%=abcopt-./%)
|
||||
abcopt-./%: %/run-test.sh
|
||||
+cd $* && bash run-test.sh $(ABCOPT) $(SEEDOPT)
|
||||
+@echo "...passed tests in $*"
|
||||
|
||||
# makefile-./ is a dummy string, not a directory
|
||||
.PHONY: makefile-tests
|
||||
.SILENT: $(MK_TEST_DIRS:%=%/Makefile)
|
||||
|
|
@ -117,7 +109,7 @@ makefile-./%: %/Makefile
|
|||
@$(MAKE) -C $*
|
||||
@echo "...passed tests in $*"
|
||||
|
||||
vanilla-test: makefile-tests abcopt-tests seed-tests
|
||||
vanilla-test: makefile-tests seed-tests
|
||||
@echo ""
|
||||
@echo " Passed \"make vanilla-test\"."
|
||||
ifeq ($(ENABLE_VERIFIC),1)
|
||||
|
|
|
|||
|
|
@ -111,11 +111,11 @@ def generate_custom(callback, extra=None):
|
|||
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"
|
||||
def generate_autotest_file(test_file, commands):
|
||||
cmd = f"../tools/autotest.sh -G -j ${{SEEDOPT}} ${{EXTRA_FLAGS}} {test_file} >/dev/null 2>&1; \\\n{commands}"
|
||||
generate_target(test_file, cmd)
|
||||
|
||||
def generate_autotest(pattern, extra_flags):
|
||||
def generate_autotest(pattern, extra_flags, cmds=""):
|
||||
with open("Makefile", "w") as f:
|
||||
old = sys.stdout
|
||||
sys.stdout = f
|
||||
|
|
@ -124,9 +124,9 @@ def generate_autotest(pattern, extra_flags):
|
|||
"SEED ?=",
|
||||
"ifneq ($(strip $(SEED)),)",
|
||||
" SEEDOPT=-S$(SEED)",
|
||||
"endif"
|
||||
"endif",
|
||||
])
|
||||
for f in sorted(glob.glob(pattern)):
|
||||
generate_autotest_file(f)
|
||||
generate_autotest_file(f, cmds)
|
||||
finally:
|
||||
sys.stdout = old
|
||||
|
|
|
|||
58
tests/memories/generate_mk.py
Normal file
58
tests/memories/generate_mk.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
sys.path.append("..")
|
||||
|
||||
import gen_tests_makefile
|
||||
|
||||
gen_tests_makefile.generate_autotest("*.v", "",
|
||||
"""if grep -Eq 'expect-(wr-ports|rd-ports|rd-clk)' $@; then \\
|
||||
$(YOSYS) -f verilog -qp "proc; opt; memory -nomap; dump -outfile $(@:.v=).dmp t:\\$$mem_v2" $@; \\
|
||||
if grep -q expect-wr-ports $@; then \\
|
||||
val=$$(gawk '/expect-wr-ports/ { print $$3; }' $@); \\
|
||||
grep -Fq "parameter \\\\WR_PORTS $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected number of write ports."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-wr-wide-continuation $@; then \\
|
||||
val=$$(gawk '/expect-wr-wide-continuation/ { print $$3; }' $@); \\
|
||||
grep -Fq "parameter \\\\WR_WIDE_CONTINUATION $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected write wide continuation."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-rd-ports $@; then \\
|
||||
val=$$(gawk '/expect-rd-ports/ { print $$3; }' $@); \\
|
||||
grep -Fq "parameter \\\\RD_PORTS $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected number of read ports."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-rd-clk $@; then \\
|
||||
val=$$(gawk '/expect-rd-clk/ { print $$3; }' $@); \\
|
||||
grep -Fq "connect \\\\RD_CLK $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected read clock."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-rd-en $@; then \\
|
||||
val=$$(gawk '/expect-rd-en/ { print $$3; }' $@); \\
|
||||
grep -Fq "connect \\\\RD_EN $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected read enable."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-rd-srst-sig $@; then \\
|
||||
val=$$(gawk '/expect-rd-srst-sig/ { print $$3; }' $@); \\
|
||||
grep -Fq "connect \\\\RD_SRST $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected read sync reset."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-rd-srst-val $@; then \\
|
||||
val=$$(gawk '/expect-rd-srst-val/ { print $$3; }' $@); \\
|
||||
grep -Fq "parameter \\\\RD_SRST_VALUE $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected read sync reset value."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-rd-arst-sig $@; then \\
|
||||
val=$$(gawk '/expect-rd-arst-sig/ { print $$3; }' $@); \\
|
||||
grep -Fq "connect \\\\RD_ARST $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected read async reset."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-rd-arst-val $@; then \\
|
||||
val=$$(gawk '/expect-rd-arst-val/ { print $$3; }' $@); \\
|
||||
grep -Fq "parameter \\\\RD_ARST_VALUE $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected read async reset value."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-rd-init-val $@; then \\
|
||||
val=$$(gawk '/expect-rd-init-val/ { print $$3; }' $@); \\
|
||||
grep -Fq "parameter \\\\RD_INIT_VALUE $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected read init value."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-rd-wide-continuation $@; then \\
|
||||
val=$$(gawk '/expect-rd-wide-continuation/ { print $$3; }' $@); \\
|
||||
grep -Fq "parameter \\\\RD_WIDE_CONTINUATION $$val" $(@:.v=).dmp || { echo " ERROR: Unexpected read wide continuation."; exit 1; }; \\
|
||||
fi; \\
|
||||
if grep -q expect-no-rd-clk $@; then \\
|
||||
grep -Fq "connect \\\\RD_CLK 1'x" $(@:.v=).dmp || { echo " ERROR: Expected no read clock."; exit 1; }; \\
|
||||
fi; \\
|
||||
fi""")
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
source ../common-env.sh
|
||||
|
||||
set -e
|
||||
|
||||
OPTIND=1
|
||||
seed="" # default to no seed specified
|
||||
abcopt=""
|
||||
while getopts "A:S:" opt
|
||||
do
|
||||
case "$opt" in
|
||||
A) abcopt="-A $OPTARG" ;;
|
||||
S) seed="$OPTARG" ;;
|
||||
esac
|
||||
done
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
${MAKE:-make} -f ../tools/autotest.mk SEED="$seed" EXTRA_FLAGS="$abcopt" *.v
|
||||
|
||||
for f in `egrep -l 'expect-(wr-ports|rd-ports|rd-clk)' *.v`; do
|
||||
echo -n "Testing expectations for $f .."
|
||||
../../yosys -f verilog -qp "proc; opt; memory -nomap;; dump -outfile ${f%.v}.dmp t:\$mem_v2" $f
|
||||
if grep -q expect-wr-ports $f; then
|
||||
grep -q "parameter \\\\WR_PORTS $(gawk '/expect-wr-ports/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected number of write ports."; false; }
|
||||
fi
|
||||
if grep -q expect-wr-wide-continuation $f; then
|
||||
grep -q "parameter \\\\WR_WIDE_CONTINUATION $(gawk '/expect-wr-wide-continuation/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected write wide continuation."; false; }
|
||||
fi
|
||||
if grep -q expect-rd-ports $f; then
|
||||
grep -q "parameter \\\\RD_PORTS $(gawk '/expect-rd-ports/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected number of read ports."; false; }
|
||||
fi
|
||||
if grep -q expect-rd-clk $f; then
|
||||
grep -q "connect \\\\RD_CLK \\$(gawk '/expect-rd-clk/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected read clock."; false; }
|
||||
fi
|
||||
if grep -q expect-rd-en $f; then
|
||||
grep -q "connect \\\\RD_EN \\$(gawk '/expect-rd-en/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected read enable."; false; }
|
||||
fi
|
||||
if grep -q expect-rd-srst-sig $f; then
|
||||
grep -q "connect \\\\RD_SRST \\$(gawk '/expect-rd-srst-sig/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected read sync reset."; false; }
|
||||
fi
|
||||
if grep -q expect-rd-srst-val $f; then
|
||||
grep -q "parameter \\\\RD_SRST_VALUE $(gawk '/expect-rd-srst-val/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected read sync reset value."; false; }
|
||||
fi
|
||||
if grep -q expect-rd-arst-sig $f; then
|
||||
grep -q "connect \\\\RD_ARST \\$(gawk '/expect-rd-arst-sig/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected read async reset."; false; }
|
||||
fi
|
||||
if grep -q expect-rd-arst-val $f; then
|
||||
grep -q "parameter \\\\RD_ARST_VALUE $(gawk '/expect-rd-arst-val/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected read async reset value."; false; }
|
||||
fi
|
||||
if grep -q expect-rd-init-val $f; then
|
||||
grep -q "parameter \\\\RD_INIT_VALUE $(gawk '/expect-rd-init-val/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected read init value."; false; }
|
||||
fi
|
||||
if grep -q expect-rd-wide-continuation $f; then
|
||||
grep -q "parameter \\\\RD_WIDE_CONTINUATION $(gawk '/expect-rd-wide-continuation/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Unexpected read wide continuation."; false; }
|
||||
fi
|
||||
if grep -q expect-no-rd-clk $f; then
|
||||
grep -q "connect \\\\RD_CLK 1'x\$" ${f%.v}.dmp ||
|
||||
{ echo " ERROR: Expected no read clock."; false; }
|
||||
fi
|
||||
echo " ok."
|
||||
done
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
# Don't bother defining default values for SEED and EXTRA_FLAGS.
|
||||
# Their "natural" default values should be sufficient,
|
||||
# and they may be overridden in the environment.
|
||||
ifneq ($(strip $(SEED)),)
|
||||
SEEDOPT=-S$(SEED)
|
||||
endif
|
||||
|
||||
$(MAKECMDGOALS):
|
||||
@$(basename $(MAKEFILE_LIST)).sh -G -j $(SEEDOPT) $(EXTRA_FLAGS) $@
|
||||
|
||||
.PHONY: $(MAKECMDGOALS)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue