Skip to content

Commit

Permalink
repair: wip add guard template
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Jan 8, 2024
1 parent 3ae188a commit abe3306
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions rtlrepair/templates/add_guard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023-2024 The Regents of the University of California
# released under BSD 3-Clause License
# author: Kevin Laeufer <[email protected]>


from rtlrepair.repair import RepairTemplate
from rtlrepair.types import InferWidths
from rtlrepair.utils import Namespace, ensure_block
import pyverilog.vparser.ast as vast


def add_guard(ast: vast.Source):
""" Adds a condition to a boolean expression. """
namespace = Namespace(ast)
infer = InferWidths()
infer.run(ast)
repl = AddGuard(infer.widths)
repl.apply(namespace, ast)
return repl.blockified


class AddGuard(RepairTemplate):
def __init__(self, widths):
super().__init__(name="add_guard")
self.widths = widths
self.use_blocking = False
self.assigned_vars = []
# we use this list to track which new blocks we introduced in order to minimize the diff between
# buggy and repaired version
self.blockified = []
# remember all 1-bit registers
self.bool_registers = set()

2 changes: 1 addition & 1 deletion rtlrepair/templates/conditional_overwrite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Regents of the University of California
# Copyright 2023-2024 The Regents of the University of California
# released under BSD 3-Clause License
# author: Kevin Laeufer <[email protected]>

Expand Down

0 comments on commit abe3306

Please sign in to comment.