Skip to content

Commit

Permalink
analysis: deal with some more Verilog constructs
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Jan 9, 2024
1 parent eea9f20 commit 21fdbe6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rtlrepair/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class VarInfo:
is_input: bool = False
is_output: bool = False
is_const: bool = False
is_genvar: bool = False
depends_on: set[str] = field(default_factory=set)

def is_register(self) -> bool:
Expand Down Expand Up @@ -386,6 +387,10 @@ def visit_Wire(self, node: vast.Wire):
if node.name not in self.vars:
self.vars[node.name] = VarInfo(node.name, self.widths[node.name])

def visit_Genvar(self, node: vast.Genvar):
assert node.name not in self.vars
self.vars[node.name] = VarInfo(node.name, self.widths[node.name], is_genvar=True)

def visit_Always(self, node: vast.Always):
# try to see if this process implements synchronous logic
self.proc_info = find_clock_and_reset(node.sens_list)
Expand Down Expand Up @@ -415,9 +420,9 @@ def visit_Assign(self, node: vast.Assign):
self.proc_info = None

def visit_assignment(self, is_blocking: bool, left: vast.Lvalue, right: vast.Node):
# warn about mixed assignments
if self.proc_info is None:
print("TODO")
# if we are not in a proc, we are probably in a generate for statement, which we will just ignore
return
if is_blocking and self.proc_info.is_sync():
print("[DependencyAnalysis] WARN: blocking assignment in sync logic process!")
if not is_blocking and self.proc_info.is_comb():
Expand Down
4 changes: 4 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,10 @@ def test_zip_cpu_sdspi(self):
analyze_ast(ast).var_list()
# no check, just making sure it does not crash

def test_sha3_round_s1(self):
ast = parse_verilog(sha_dir / "round_ssscrazy_buggy1.v")
analyze_ast(ast).var_list()
# no check, just making sure it does not crash



Expand Down

0 comments on commit 21fdbe6

Please sign in to comment.