From 9cf552a22b3dd5c8ed68d5903be3096207c72d51 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Fri, 19 Aug 2022 16:58:33 +0200 Subject: [PATCH] WIP: Integrate stages into the taskloop --- sbysrc/sby_core.py | 55 +++++++++++++++++++++++++++++++++-- tests/unsorted/stage_hack.sby | 17 +++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 tests/unsorted/stage_hack.sby diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index 5b841327..e485f56d 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -579,7 +579,7 @@ def run(self): self.tasks = [] for task in tasks: task.check_timeout() - if task.procs_pending or task.procs_running: + if task.procs_pending or task.procs_running or task.stages_running: self.tasks.append(task) else: task.exit_callback() @@ -619,6 +619,9 @@ def __init__(self, sbyconfig, workdir, early_logs, reusedir, taskloop=None, logf self.taskloop = taskloop or SbyTaskloop() self.taskloop.tasks.append(self) + self.base_dependencies = [] + self.stages_running = [] + self.procs_running = [] self.procs_pending = [] @@ -803,7 +806,7 @@ def make_model(self, model_name): proc = SbyProc( self, model_name, - [], + self.base_dependencies, "cd {}/src; {} -ql ../model/design.log ../model/design.ys".format(self.workdir, self.exe_paths["yosys"]) ) proc.checkretcode = True @@ -992,6 +995,8 @@ def handle_non_engine_options(self): self.handle_str_option("make_model", None) + self.handle_str_option("stage_hack", None) + def setup_procs(self, setupmode): self.handle_non_engine_options() if self.opt_smtc is not None: @@ -1019,6 +1024,27 @@ def setup_procs(self, setupmode): self.retcode = 0 return + if self.opt_stage_hack is not None: + # TODO replace with actual configs generated for the stages + self.setup_stage(setupmode, config=[ + "[options]", + "mode bmc", + "[engines]", + "smtbmc", + "[script]", + "read_rtlil ../../model/design.il", + "setundef -zero" + ], name="bmc_zero", depends=self.make_model("base")) + self.setup_stage(setupmode, config=[ + "[options]", + "mode bmc", + "[engines]", + "smtbmc", + "[script]", + "read_rtlil ../../model/design.il", + "setundef -one" + ], name="bmc_one", depends=self.make_model("base")) + if self.opt_make_model is not None: for name in self.opt_make_model.split(","): self.model(name.strip()) @@ -1049,6 +1075,12 @@ def setup_procs(self, setupmode): if opt not in self.used_options: self.error(f"Unused option: {opt}") + def setup_stage(self, setupmode, config, name, depends): + stage = SbyStage(config, self, name) + stage.base_dependencies.extend(depends) + self.stages_running.append(stage) + stage.setup_procs(setupmode) + def summarize(self): total_clock_time = int(monotonic() - self.start_clock_time) @@ -1179,3 +1211,22 @@ def print_junit_result(self, f, junit_ts_name, junit_tc_name, junit_format_stric print('', file=f) print(f'', file=f) print(f'', file=f) + + +class SbyStage(SbyTask): + def __init__(self, sbyconfig, main_task, name): + self.main_task = main_task + self.name = name + workdir = f"{main_task.workdir}/stage_{name}" + os.mkdir(workdir) + super().__init__( + sbyconfig, workdir=workdir, early_logs=[], + reusedir=False, taskloop=main_task.taskloop, logfile=main_task.logfile) + + self.exit_callback = self.handle_stage_exit + + + def handle_stage_exit(self): + self.main_task.stages_running.remove(self) + + # TODO pass the status back to the main task diff --git a/tests/unsorted/stage_hack.sby b/tests/unsorted/stage_hack.sby new file mode 100644 index 00000000..3f845cc1 --- /dev/null +++ b/tests/unsorted/stage_hack.sby @@ -0,0 +1,17 @@ +[options] +mode bmc + +stage_hack yup + +[engines] +smtbmc + +[script] +read -formal stage_hack.sv +prep -top top + +[file stage_hack.sv] +module top(input clk); + +endmodule +