-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]> | ||
|
||
|