Skip to content

Commit

Permalink
gen/fhdl: Cleanup/Simplify hierarchy generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Nov 3, 2023
1 parent a1704a0 commit 6f431fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions litex/gen/fhdl/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def get_tree(self, module, ident=0, with_modules=True, with_instances=True, with
r = ""
names = set()
names.add(None)
# Modules / SubModules.

# Modules / Sub-Modules.
for name, mod in module._submodules:
if name is None:
n = 0
Expand All @@ -51,10 +52,13 @@ def get_tree(self, module, ident=0, with_modules=True, with_instances=True, with
r += f"{self.tree_ident*ident}{self.tree_entry}{self._colorer(f'[{s.of}]', 'yellow')}\n"
return r

def __repr__(self):
r = "\n"
def get_hierarchy(self):
r = ""
r += f"{self._colorer(self.top.__class__.__name__, 'underline')}\n"
r += self.get_tree(self.top)
r += f"{self._colorer('* ', 'cyan')}: Generated name.\n"
r += f"{self._colorer('* ', 'cyan')}: Generated name.\n"
r += f"{self._colorer('[]', 'yellow')}: BlackBox.\n"
return r

def __repr__(self):
return f"\n{self.get_hierarchy()}"
6 changes: 3 additions & 3 deletions litex/gen/fhdl/verilog.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ def _generate_timescale(time_unit="1ns", time_precision="1ps"):
# ------------------------------------------------------------------------------------------------ #

def _generate_hierarchy(top):
hierarchy = LiteXHierarchyExplorer(top=top, depth=None, with_colors=False).__repr__()
hierarchy_explorer = LiteXHierarchyExplorer(top=top, depth=None, with_colors=False)
r = "/*\n"
for l in hierarchy.split("\n"):
for l in hierarchy_explorer.get_hierarchy().split("\n"):
r += l + "\n"
#r += "//" + l + "\n"
r = r[:-1]
r += "*/\n"
return r

Expand Down

0 comments on commit 6f431fa

Please sign in to comment.