Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
umarcor committed Sep 14, 2023
1 parent a413531 commit bef613e
Showing 1 changed file with 143 additions and 2 deletions.
145 changes: 143 additions & 2 deletions mods/pyOSVDE/topwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def __init__(self, dirName):
self.Design = Design()
self.parseDir(Path(dirName))
resolve_Symbols(self.Design)
#self.loadFileTree()
#self.loadDesignTree()
self.printDesignTree()

def parseDir(self, dirName: Path):
"""
Expand All @@ -78,6 +77,148 @@ def parseFile(self, sourceFile: Path, library: str = "lib"):
lib = self.Design.GetLibrary(library)
self.Design.AddDocument(Document(sourceFile), lib)

def printDesignTree(self, parent=""):
"""
Print the Design Tree with the data from the pyVHDLModel Design.
"""

# def addTreeItem(parent, text, isOpen, image):
# return dtw.insert(parent, tk.END, text=text, open=isOpen, image=self.Image[image])
#
# def loadStatementsTree(item, statements):
# for statement in statements:
#
# # Note: the following share the same base class 'Instantiation'
# # ComponentInstantiation, EntityInstantiation, ConfigurationInstantiation
#
# if isinstance(statement, Instantiation):
# addTreeItem(item, "{}: inst".format(statement.Label), False, "inst")
#
# elif isinstance(statement, ConcurrentBlockStatement):
# instItem = addTreeItem(item, "{}: block".format(statement.Label), False, "file")
# innerstatements = statement.Statements
# if len(innerstatements) != 0:
# loadStatementsTree(instItem, innerstatements)
#
# # Note: the following share the same base class 'GenerateStatement'
# # ForGenerateStatement, CaseGenerateStatement, IfGenerateStatement
#
# elif isinstance(statement, IfGenerateStatement):
# instItem = addTreeItem(item, "{}: if .. generate".format(statement.Label), False, "file")
# loadStatementsTree(
# addTreeItem(
# instItem,
# "if: {}".format(statement.IfBranch.Condition),
# False,
# "file",
# ),
# statement.IfBranch.Statements,
# )
# for elsifbranch in statement.ElsifBranches:
# loadStatementsTree(
# addTreeItem(
# instItem,
# "elsif: {}".format(elsifbranch.Condition),
# False,
# "file",
# ),
# elsifbranch.Statements,
# )
# if statement.ElseBranch is not None:
# loadStatementsTree(
# addTreeItem(instItem, "else:", False, "file"),
# statement.ElseBranch.Statements,
# )
#
# elif isinstance(statement, CaseGenerateStatement):
# instItem = addTreeItem(item, "{}: case .. generate".format(statement.Label), False, "file")
# for case in statement.Cases:
# if isinstance(case, GenerateCase):
# loadStatementsTree(
# addTreeItem(
# instItem,
# "case: {}".format(" | ".join([str(c) for c in case.Choises])),
# False,
# "file",
# ),
# case.Statements,
# )
# elif isinstance(case, OthersGenerateCase):
# loadStatementsTree(
# addTreeItem(instItem, "others:", False, "file"),
# case.Statements,
# )
#
# elif isinstance(statement, ForGenerateStatement):
# instItem = addTreeItem(
# item,
# "{0}: for {1!s} generate".format(statement.Label, statement.Range),
# False,
# "file",
# )
# innerstatements = statement.Statements
# if len(innerstatements) != 0:
# loadStatementsTree(instItem, innerstatements)
#
# elif isinstance(statement, ProcessStatement):
# addTreeItem(
# item,
# "{}: process".format(statement.Label or "DefaultLabel"),
# False,
# "file",
# )

for libName, lib in self.Design.Libraries.items():
print(f"Library: {libName}")
# LibItem = addTreeItem(parent, libName, True, "lib")
for entity in lib.Entities:
print(f" Entity: {entity.Identifier}")
# EntityItem = addTreeItem(LibItem, entity.Identifier, False, "ent")
#
# generics = entity.GenericItems
# if len(generics) != 0:
# GenericsItem = addTreeItem(EntityItem, "Generics", False, "generics")
# for generic in generics:
# if isinstance(generic, GenericConstantInterfaceItem):
# addTreeItem(
# GenericsItem,
# "{} [{}]".format(",".join(generic.Identifiers), generic.Subtype),
# False,
# "generic",
# )
# elif isinstance(generic, GenericTypeInterfaceItem):
# addTreeItem(
# GenericsItem,
# "type: {}".format(generic.Identifier),
# False,
# "generic",
# )
# else:
# print(
# "[NOT IMPLEMENTED] Generic item class not supported yet: {0}",
# generic.__class__.__name__,
# )
#
# ports = entity.PortItems
# if len(ports) != 0:
# PortsItem = addTreeItem(EntityItem, "Ports", False, "ports")
# for port in ports:
# addTreeItem(
# PortsItem,
# "{} [{}]".format(",".join(port.Identifiers), port.Subtype),
# False,
# "out" if port.Mode is Mode.Out else "inout" if port.Mode is Mode.InOut else "in",
# )
#
# architectures = entity.Architectures
# if len(architectures) != 0:
# ArchitecturesItem = addTreeItem(EntityItem, "Architectures", False, "archs")
# for architecture in entity.Architectures:
# loadStatementsTree(
# addTreeItem(ArchitecturesItem, "{}".format(architecture.Identifier), False, "arch"),
# architecture.Statements,
# )

if __name__ == "__main__":
if len(sys_argv) < 2:
raise Exception('Needs one argument: the path to a directory containing VHDL sources.')
Expand Down

0 comments on commit bef613e

Please sign in to comment.