3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-04-05 22:14:08 +00:00

add --seed option to smtbmc and btor engines

This commit is contained in:
N. Engelhardt 2020-07-01 18:05:20 +02:00
parent 2751d19216
commit ee5cfdef76
2 changed files with 20 additions and 6 deletions

View file

@ -21,21 +21,31 @@ from types import SimpleNamespace
from sby_core import SbyTask from sby_core import SbyTask
def run(mode, job, engine_idx, engine): def run(mode, job, engine_idx, engine):
opts, solver_args = getopt.getopt(engine[1:], "", []) random_seed = None
opts, solver_args = getopt.getopt(engine[1:], "", ["seed="])
if len(solver_args) == 0: if len(solver_args) == 0:
job.error("Missing solver command.") job.error("Missing solver command.")
for o, a in opts: for o, a in opts:
job.error("Unexpected BTOR engine options.") if o == "--seed":
random_seed = a
else:
job.error("Unexpected BTOR engine options.")
if solver_args[0] == "btormc": if solver_args[0] == "btormc":
solver_cmd = job.exe_paths["btormc"] + " --stop-first {} -v 1 -kmax {}".format(0 if mode == "cover" else 1, job.opt_depth - 1) solver_cmd = ""
if random_seed:
solver_cmd += "BTORSEED={} ".format(random_seed)
solver_cmd += job.exe_paths["btormc"] + " --stop-first {} -v 1 -kmax {}".format(0 if mode == "cover" else 1, job.opt_depth - 1)
if job.opt_skip is not None: if job.opt_skip is not None:
solver_cmd += " -kmin {}".format(job.opt_skip) solver_cmd += " -kmin {}".format(job.opt_skip)
solver_cmd += " ".join([""] + solver_args[1:]) solver_cmd += " ".join([""] + solver_args[1:])
elif solver_args[0] == "cosa2": elif solver_args[0] == "cosa2":
if random_seed:
job.error("Setting the random seed is not available for the cosa2 solver.")
solver_cmd = job.exe_paths["cosa2"] + " -v 1 -e bmc -k {}".format(job.opt_depth - 1) solver_cmd = job.exe_paths["cosa2"] + " -v 1 -e bmc -k {}".format(job.opt_depth - 1)
else: else:

View file

@ -31,11 +31,13 @@ def run(mode, job, engine_idx, engine):
progress = False progress = False
basecase_only = False basecase_only = False
induction_only = False induction_only = False
random_seed = None
opts, args = getopt.getopt(engine[1:], "", ["nomem", "syn", "stbv", "stdt", "presat", opts, args = getopt.getopt(engine[1:], "", ["nomem", "syn", "stbv", "stdt", "presat",
"nopresat", "unroll", "nounroll", "dumpsmt2", "progress", "basecase", "induction"]) "nopresat", "unroll", "nounroll", "dumpsmt2", "progress", "basecase", "induction", "seed="])
for o, a in opts: for o, a in opts:
print(o, a)
if o == "--nomem": if o == "--nomem":
nomem_opt = True nomem_opt = True
elif o == "--syn": elif o == "--syn":
@ -64,6 +66,8 @@ def run(mode, job, engine_idx, engine):
if basecase_only: if basecase_only:
job.error("smtbmc options --basecase and --induction are exclusive.") job.error("smtbmc options --basecase and --induction are exclusive.")
induction_only = True induction_only = True
elif o == "--seed":
random_seed = a
else: else:
job.error("Invalid smtbmc options {}.".format(o)) job.error("Invalid smtbmc options {}.".format(o))
@ -135,8 +139,8 @@ def run(mode, job, engine_idx, engine):
t_opt = "{}".format(job.opt_depth) t_opt = "{}".format(job.opt_depth)
task = SbyTask(job, taskname, job.model(model_name), task = SbyTask(job, taskname, job.model(model_name),
"cd {}; {} {} -t {} --append {} --dump-vcd {p}.vcd --dump-vlogtb {p}_tb.v --dump-smtc {p}.smtc model/design_{}.smt2".format "cd {}; {} {} -t {} {} --append {} --dump-vcd {p}.vcd --dump-vlogtb {p}_tb.v --dump-smtc {p}.smtc model/design_{}.smt2".format
(job.workdir, job.exe_paths["smtbmc"], " ".join(smtbmc_opts), t_opt, job.opt_append, model_name, p=trace_prefix), (job.workdir, job.exe_paths["smtbmc"], " ".join(smtbmc_opts), t_opt, "--info \"(set-option :random-seed {})\"".format(random_seed) if random_seed else "", job.opt_append, model_name, p=trace_prefix),
logfile=open(logfile_prefix + ".txt", "w"), logstderr=(not progress)) logfile=open(logfile_prefix + ".txt", "w"), logstderr=(not progress))
if mode == "prove_basecase": if mode == "prove_basecase":