Skip to content

Commit

Permalink
add_guard: skip if no width info available
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Jan 16, 2024
1 parent 1706e86 commit 5cd53f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rtlrepair/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ def generic_visit(self, node):
# check the lhs first because it might influence the lhs
lhs_width = self.expr_width(node.left.var, None)
rhs_width = self.expr_width(node.right.var, lhs_width)
except RuntimeError:
except RuntimeError as e:
# print(e)
pass # ignore failure
elif isinstance(node, vast.IfStatement):
self.expr_width(node.cond, 1)
Expand Down
8 changes: 8 additions & 0 deletions rtlrepair/templates/add_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def visit_Assign(self, node: vast.Assign):
# assignments outside of a process
if self.in_proc:
return node # unexpected
# Sometimes our with inference algorithm is at wit's end, and we need to skip the node because we do
# not know if it will be 1-bit. This generally happens in generate for loops when the induction variable
# would need to be known in order to determine the width of an expression. In that case there might
# not even be a single with for that particular expression, as the width could be different in each loop
# iteration.
if node.left.var not in self.a.widths:
return node

# check to see if this is a 1-bit assignment
if self.a.widths[node.left.var] != 1:
return node
Expand Down

0 comments on commit 5cd53f1

Please sign in to comment.