Skip to content

Commit

Permalink
replace_literal: prevent non-const generate if
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Jan 9, 2024
1 parent b5e1190 commit 05b2962
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions rtlrepair/templates/replace_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ def __init__(self, vars: dict[str, VarInfo], widths: dict[vast.Node, int]):
super().__init__(name="literal")
self.vars = vars
self.widths = widths
self.in_gen = False
self.in_proc = False

def visit_GenerateStatement(self, node: vast.GenerateStatement):
self.in_gen = True
def visit_Always(self, node: vast.Always):
self.in_proc = True
node = self.generic_visit(node)
self.in_gen = False
self.in_proc = False
return node

def visit_IfStatement(self, node: vast.IfStatement):
if self.in_proc:
node.cond = self.visit(node.cond)
node.true_statement = self.visit(node.true_statement)
node.false_statement = self.visit(node.false_statement)
return node

def visit_Identifier(self, node: vast.Identifier):
Expand Down

0 comments on commit 05b2962

Please sign in to comment.