mirror of
https://github.com/YosysHQ/yosys
synced 2026-04-26 13:53:34 +00:00
Convert xprop tests
This commit is contained in:
parent
de8b6286b8
commit
2b10385edd
4 changed files with 32 additions and 38 deletions
|
|
@ -63,7 +63,7 @@ MK_TEST_DIRS += ./asicworld
|
||||||
#SH_TEST_DIRS += ./memlib
|
#SH_TEST_DIRS += ./memlib
|
||||||
#SH_TEST_DIRS += ./bram
|
#SH_TEST_DIRS += ./bram
|
||||||
#SH_TEST_DIRS += ./svinterfaces
|
#SH_TEST_DIRS += ./svinterfaces
|
||||||
#SH_TEST_DIRS += ./xprop
|
MK_TEST_DIRS += ./xprop
|
||||||
MK_TEST_DIRS += ./select
|
MK_TEST_DIRS += ./select
|
||||||
MK_TEST_DIRS += ./peepopt
|
MK_TEST_DIRS += ./peepopt
|
||||||
MK_TEST_DIRS += ./proc
|
MK_TEST_DIRS += ./proc
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,17 @@ common_mk = os.path.relpath(os.path.join(os.path.dirname(__file__), "common.mk")
|
||||||
def _cwd_base():
|
def _cwd_base():
|
||||||
return os.path.basename(os.getcwd())
|
return os.path.basename(os.getcwd())
|
||||||
|
|
||||||
def generate_target(name, command):
|
def generate_target(name, command, out=sys.stdout):
|
||||||
#target = f"{_cwd_base()}-{name}"
|
#target = f"{_cwd_base()}-{name}"
|
||||||
target = f"{name}"
|
target = f"{name}"
|
||||||
print(f"all: {target}")
|
print(f"all: {target}", file=out)
|
||||||
print(f".PHONY: {target}")
|
print(f".PHONY: {target}", file=out)
|
||||||
print(f"{target}:")
|
print(f"{target}:", file=out)
|
||||||
print(f"\t@$(call run_test,{target}, \\")
|
if command:
|
||||||
print(f"\t{command})")
|
print(f"\t@$(call run_test,{target}, \\", file=out)
|
||||||
|
print(f"\t{command})", file=out)
|
||||||
|
else:
|
||||||
|
print(f"\t@$(call run_test,{target})", file=out)
|
||||||
|
|
||||||
def generate_ys_test(ys_file, yosys_args="", commands=""):
|
def generate_ys_test(ys_file, yosys_args="", commands=""):
|
||||||
cmd = f'$(YOSYS) -ql {ys_file}.err {yosys_args} {ys_file} >/dev/null 2>&1 && mv {ys_file}.err {ys_file}.log'
|
cmd = f'$(YOSYS) -ql {ys_file}.err {yosys_args} {ys_file} >/dev/null 2>&1 && mv {ys_file}.err {ys_file}.log'
|
||||||
|
|
@ -87,17 +90,17 @@ def generate_tests(argv, cmds):
|
||||||
if f != "run-test.sh":
|
if f != "run-test.sh":
|
||||||
generate_bash_test(f, cmds)
|
generate_bash_test(f, cmds)
|
||||||
|
|
||||||
def print_header(extra=None):
|
def print_header(extra=None, out=sys.stdout):
|
||||||
print(f"include {common_mk}")
|
print(f"include {common_mk}", file=out)
|
||||||
print(f"YOSYS ?= {yosys_basedir}/yosys")
|
print(f"YOSYS ?= {yosys_basedir}/yosys", file=out)
|
||||||
print()
|
print("", file=out)
|
||||||
print("export YOSYS_MAX_THREADS := 4")
|
print("export YOSYS_MAX_THREADS := 4", file=out)
|
||||||
if extra:
|
if extra:
|
||||||
for line in extra:
|
for line in extra:
|
||||||
print(line)
|
print(line, file=out)
|
||||||
print()
|
print("", file=out)
|
||||||
print(".PHONY: all")
|
print(".PHONY: all", file=out)
|
||||||
print("all:")
|
print("all:", file=out)
|
||||||
|
|
||||||
def generate(argv, extra=None, cmds=""):
|
def generate(argv, extra=None, cmds=""):
|
||||||
with open("Makefile", "w") as f:
|
with open("Makefile", "w") as f:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("..")
|
||||||
|
|
||||||
|
import gen_tests_makefile
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import random
|
import random
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
@ -16,7 +22,9 @@ if args.seed is None:
|
||||||
|
|
||||||
print(f"xprop PRNG seed: {args.seed}")
|
print(f"xprop PRNG seed: {args.seed}")
|
||||||
|
|
||||||
makefile = open("run-test.mk", "w")
|
makefile = open("Makefile", "w")
|
||||||
|
|
||||||
|
gen_tests_makefile.print_header(out = makefile)
|
||||||
|
|
||||||
def add_test(name, src, seq=False):
|
def add_test(name, src, seq=False):
|
||||||
if not re.search(args.filter, name):
|
if not re.search(args.filter, name):
|
||||||
|
|
@ -26,17 +34,10 @@ def add_test(name, src, seq=False):
|
||||||
os.makedirs(workdir, exist_ok=True)
|
os.makedirs(workdir, exist_ok=True)
|
||||||
with open(f"{workdir}/uut.v", "w") as uut:
|
with open(f"{workdir}/uut.v", "w") as uut:
|
||||||
print(src, file=uut)
|
print(src, file=uut)
|
||||||
print(f"all: {workdir}", file=makefile)
|
|
||||||
print(f".PHONY: {workdir}", file=makefile)
|
|
||||||
print(f"{workdir}:", file=makefile)
|
|
||||||
seq_arg = " -s" if seq else ""
|
seq_arg = " -s" if seq else ""
|
||||||
print(
|
gen_tests_makefile.generate_target(workdir,
|
||||||
f"\t@cd {workdir} && python3 -u ../test.py -S {args.seed} -c {args.count}{seq_arg} > test.log 2>&1 || echo {workdir}: failed > status\n"
|
f"cd {workdir} && python3 -u ../test.py -S {args.seed} -c {args.count}{seq_arg} > test.log 2>&1",
|
||||||
f"\t@cat {workdir}/status\n"
|
out=makefile)
|
||||||
f"\t@grep '^.*: ok' {workdir}/status\n"
|
|
||||||
,
|
|
||||||
file=makefile,
|
|
||||||
)
|
|
||||||
|
|
||||||
def cell_test(name, cell, inputs, outputs, params, initial={}, defclock=False, seq=False):
|
def cell_test(name, cell, inputs, outputs, params, initial={}, defclock=False, seq=False):
|
||||||
ports = []
|
ports = []
|
||||||
|
|
@ -119,10 +120,6 @@ def dff_test(width, pol, defclock):
|
||||||
def dffe_test(width, pol, enpol, defclock):
|
def dffe_test(width, pol, enpol, defclock):
|
||||||
cell_test(f"dffe_{width}{'np'[pol]}{'np'[enpol]}{'xd'[defclock]}", 'dffe', {"CLK": 1, "EN": 1, "D": width}, {"Q": width}, {"WIDTH": width, "CLK_POLARITY": int(pol), "EN_POLARITY": int(enpol)}, defclock=defclock, seq=True)
|
cell_test(f"dffe_{width}{'np'[pol]}{'np'[enpol]}{'xd'[defclock]}", 'dffe', {"CLK": 1, "EN": 1, "D": width}, {"Q": width}, {"WIDTH": width, "CLK_POLARITY": int(pol), "EN_POLARITY": int(enpol)}, defclock=defclock, seq=True)
|
||||||
|
|
||||||
|
|
||||||
print(".PHONY: all", file=makefile)
|
|
||||||
print("all:\n\t@echo done\n", file=makefile)
|
|
||||||
|
|
||||||
for cell in ["not", "pos", "neg"]:
|
for cell in ["not", "pos", "neg"]:
|
||||||
if args.more:
|
if args.more:
|
||||||
unary_test(cell, 1, False, 1)
|
unary_test(cell, 1, False, 1)
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
source ../common-env.sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
python3 generate.py $@
|
|
||||||
${MAKE:-make} -f run-test.mk
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue