mirror of
https://github.com/YosysHQ/yosys
synced 2026-03-23 04:49:15 +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 += ./bram
|
||||
#SH_TEST_DIRS += ./svinterfaces
|
||||
#SH_TEST_DIRS += ./xprop
|
||||
MK_TEST_DIRS += ./xprop
|
||||
MK_TEST_DIRS += ./select
|
||||
MK_TEST_DIRS += ./peepopt
|
||||
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():
|
||||
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"{name}"
|
||||
print(f"all: {target}")
|
||||
print(f".PHONY: {target}")
|
||||
print(f"{target}:")
|
||||
print(f"\t@$(call run_test,{target}, \\")
|
||||
print(f"\t{command})")
|
||||
print(f"all: {target}", file=out)
|
||||
print(f".PHONY: {target}", file=out)
|
||||
print(f"{target}:", file=out)
|
||||
if 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=""):
|
||||
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":
|
||||
generate_bash_test(f, cmds)
|
||||
|
||||
def print_header(extra=None):
|
||||
print(f"include {common_mk}")
|
||||
print(f"YOSYS ?= {yosys_basedir}/yosys")
|
||||
print()
|
||||
print("export YOSYS_MAX_THREADS := 4")
|
||||
def print_header(extra=None, out=sys.stdout):
|
||||
print(f"include {common_mk}", file=out)
|
||||
print(f"YOSYS ?= {yosys_basedir}/yosys", file=out)
|
||||
print("", file=out)
|
||||
print("export YOSYS_MAX_THREADS := 4", file=out)
|
||||
if extra:
|
||||
for line in extra:
|
||||
print(line)
|
||||
print()
|
||||
print(".PHONY: all")
|
||||
print("all:")
|
||||
print(line, file=out)
|
||||
print("", file=out)
|
||||
print(".PHONY: all", file=out)
|
||||
print("all:", file=out)
|
||||
|
||||
def generate(argv, extra=None, cmds=""):
|
||||
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 re
|
||||
import sys
|
||||
import random
|
||||
import argparse
|
||||
|
||||
|
|
@ -16,7 +22,9 @@ if args.seed is None:
|
|||
|
||||
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):
|
||||
if not re.search(args.filter, name):
|
||||
|
|
@ -26,17 +34,10 @@ def add_test(name, src, seq=False):
|
|||
os.makedirs(workdir, exist_ok=True)
|
||||
with open(f"{workdir}/uut.v", "w") as 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 ""
|
||||
print(
|
||||
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"\t@cat {workdir}/status\n"
|
||||
f"\t@grep '^.*: ok' {workdir}/status\n"
|
||||
,
|
||||
file=makefile,
|
||||
)
|
||||
gen_tests_makefile.generate_target(workdir,
|
||||
f"cd {workdir} && python3 -u ../test.py -S {args.seed} -c {args.count}{seq_arg} > test.log 2>&1",
|
||||
out=makefile)
|
||||
|
||||
def cell_test(name, cell, inputs, outputs, params, initial={}, defclock=False, seq=False):
|
||||
ports = []
|
||||
|
|
@ -119,10 +120,6 @@ def dff_test(width, pol, 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)
|
||||
|
||||
|
||||
print(".PHONY: all", file=makefile)
|
||||
print("all:\n\t@echo done\n", file=makefile)
|
||||
|
||||
for cell in ["not", "pos", "neg"]:
|
||||
if args.more:
|
||||
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