File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -183,3 +183,27 @@ def do_finalize(self):
183183 def do_exit (self , * args , ** kwargs ):
184184 for name , submodule in self ._submodules :
185185 submodule .do_exit (* args , ** kwargs )
186+
187+ def print_hierarchy (self , indent = 4 , include_anon = False ):
188+ """Prints a hierarchy tree for the Module.
189+
190+ This method iterates over each submodule in the design and prints out an
191+ indented hierarchy. By default it ignores any anonymous modules but this can be
192+ overridden by passing include_anon=True.
193+
194+ Note that by default, with include_anon=False, all hierarchy below an anonymous
195+ module will be skipped. It is assumed that the user will only use anonymous
196+ instantiations for leaf cells such as CSRs, synchronisers, etc where we don't
197+ particularly care about printing them in a hierarchy view.
198+
199+ """
200+ if indent == 4 :
201+ print (self .__class__ .__name__ )
202+ for name , submodule in self ._submodules :
203+ if name is None :
204+ if not include_anon :
205+ # all hierarchy below an anonymous module is skipped
206+ continue
207+ name = "anon"
208+ print ("{}{}:{}" .format (" " * indent , name , submodule .__class__ .__name__ ))
209+ submodule .print_hierarchy (indent + 4 , include_anon )
You can’t perform that action at this time.
0 commit comments