from sby_core import SbyTask
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:
job.error("Missing solver command.")
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":
- 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:
solver_cmd += " -kmin {}".format(job.opt_skip)
solver_cmd += " ".join([""] + solver_args[1:])
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)
else:
progress = False
basecase_only = False
induction_only = False
+ random_seed = None
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:
+ print(o, a)
if o == "--nomem":
nomem_opt = True
elif o == "--syn":
if basecase_only:
job.error("smtbmc options --basecase and --induction are exclusive.")
induction_only = True
+ elif o == "--seed":
+ random_seed = a
else:
job.error("Invalid smtbmc options {}.".format(o))
t_opt = "{}".format(job.opt_depth)
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
- (job.workdir, job.exe_paths["smtbmc"], " ".join(smtbmc_opts), t_opt, job.opt_append, model_name, p=trace_prefix),
+ "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, "--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))
if mode == "prove_basecase":