3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-05-26 20:06:24 +00:00

Add check_mem command

Comes with a set of tests which (currently) pass with `read_verilog` but fail with `verific` based on #5878.
Add `--check-sv`, an alternative to `--prove-sv` with generator defined yosys commands.  Helpful for when you want to run the same set of commands on a bunch of sv files.
This commit is contained in:
Krystine Sherwin 2026-05-20 15:02:30 +12:00
parent 27ae62f492
commit a7c8651b76
No known key found for this signature in database
7 changed files with 210 additions and 4 deletions

View file

@ -37,6 +37,11 @@ def generate_tcl_test(tcl_file, yosys_args="", commands=""):
cmd += f"; \\\n{commands}"
generate_target(tcl_file, cmd)
def generate_sv_check(sv_file, yosys_args="", yosys_cmds=""):
yosys_cmd = f'read -sv {sv_file}; {yosys_cmds}'
cmd = f'$(YOSYS) -ql {sv_file}.err -p "{yosys_cmd}" {yosys_args} && mv {sv_file}.err {sv_file}.log'
generate_target(sv_file, cmd)
def generate_sv_test(sv_file, yosys_args="", commands=""):
base = os.path.splitext(sv_file)[0]
if not os.path.exists(base + ".ys"):
@ -62,19 +67,23 @@ def unpack_cmd(cmd):
def generate_cmd_test(test_name, cmd, yosys_args="", deps = None):
generate_target(test_name, unpack_cmd(cmd), deps)
def generate_tests(argv, cmds):
def generate_tests(argv, cmds, yosys_cmds=""):
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("-y", "--yosys-scripts", action="store_true")
parser.add_argument("-t", "--tcl-scripts", action="store_true")
parser.add_argument("-c", "--check-sv", action="store_true")
parser.add_argument("-s", "--prove-sv", action="store_true")
parser.add_argument("-b", "--bash", action="store_true")
parser.add_argument("-a", "--yosys-args", default="")
args = parser.parse_args(argv)
if not (args.yosys_scripts or args.tcl_scripts or args.prove_sv or args.bash):
if not (args.yosys_scripts or args.tcl_scripts or args.check_sv or args.prove_sv or args.bash):
raise RuntimeError("No file types selected")
if args.check_sv and args.prove_sv:
raise RuntimeError("Unable to use --check-sv and --prove-sv together")
if args.yosys_scripts:
for f in sorted(glob.glob("*.ys")):
generate_ys_test(f, args.yosys_args, cmds)
@ -83,6 +92,10 @@ def generate_tests(argv, cmds):
for f in sorted(glob.glob("*.tcl")):
generate_tcl_test(f, args.yosys_args, cmds)
if args.check_sv:
for f in sorted(glob.glob("*.sv")):
generate_sv_check(f, args.yosys_args, yosys_cmds)
if args.prove_sv:
for f in sorted(glob.glob("*.sv")):
generate_sv_test(f, args.yosys_args, cmds)
@ -112,11 +125,11 @@ def redirect_stdout(new_target):
finally:
sys.stdout = old_target
def generate(argv, extra=None, cmds=""):
def generate(argv, extra=None, cmds="", yosys_cmds=""):
with open("Makefile", "w") as f:
with redirect_stdout(f):
print_header(extra)
generate_tests(argv, cmds)
generate_tests(argv, cmds, yosys_cmds)
def generate_custom(callback, extra=None):
with open("Makefile", "w") as f: