Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Integrate stages into the taskloop #212

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions sbysrc/sby_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 = []

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.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.model("base"))

if self.opt_make_model is not None:
for name in self.opt_make_model.split(","):
self.model(name.strip())
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -1179,3 +1211,22 @@ def print_junit_result(self, f, junit_ts_name, junit_tc_name, junit_format_stric
print('</system-err>', file=f)
print(f'</testsuite>', file=f)
print(f'</testsuites>', 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
19 changes: 19 additions & 0 deletions tests/unsorted/stage_hack.sby
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[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, output x);

assign x = 1;

endmodule