Skip to content

Commit

Permalink
repair: try finding smaller solution, switch repair order
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Jan 9, 2024
1 parent 27fd020 commit 852cedd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions rtlrepair.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'add_guard': add_guard,
}
#_default_templates = ['replace_literals', 'assign_const', 'add_guard']
_default_templates = ['replace_literals', 'conditional_overwrite', 'add_guard']
_default_templates = ['replace_literals', 'add_guard', 'conditional_overwrite']


@dataclass
Expand Down Expand Up @@ -211,8 +211,13 @@ def try_templates_in_sequence(config: Config, ast, statistics: dict, analysis: A
# we need to deep copy the ast since the template is going to modify it in place!
ast_copy = copy.deepcopy(ast)
status, solutions = try_template(config, ast, prefix, template, statistics, analysis)

# determine size of smallest solution
min_changes = min(s[1]['changes'] for s in solutions)

# early exit if there is nothing to do or if we found a solution and aren't instructed to run all templates
if status == Status.NoRepair or (not config.opts.run_all_templates and status == Status.Success):
# keep going if the current solution is pretty large
if (status == Status.NoRepair or (not config.opts.run_all_templates and status == Status.Success)) and min_changes <= 6:
return status, solutions
else:
all_solutions += solutions
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_d11(self):
""" AXIS Frame Fifo with a missing reset to zero for two registers """
changes = self.synth_success(d11_dir, "d11", solver="yices2", init="zero", incremental=True, timeout=60)
# resets `drop_frame`, but not `wr_ptr_cur` because it is not required to pass the test
self.assertEqual(changes, 1)
self.assertEqual(changes, 2)

def test_d8(self):
""" AXIS Switch with wrong index. Should be fixable by simple literal replacement... """
Expand Down

0 comments on commit 852cedd

Please sign in to comment.