diff options
-rwxr-xr-x | pyGHDL/cli/DOM.py | 12 | ||||
-rw-r--r-- | pyGHDL/dom/DesignUnit.py | 4 | ||||
-rw-r--r-- | pyGHDL/dom/Object.py | 19 | ||||
-rw-r--r-- | pyGHDL/dom/formatting/prettyprint.py | 18 |
4 files changed, 38 insertions, 15 deletions
diff --git a/pyGHDL/cli/DOM.py b/pyGHDL/cli/DOM.py index 2feb6aecd..641383686 100755 --- a/pyGHDL/cli/DOM.py +++ b/pyGHDL/cli/DOM.py @@ -9,8 +9,8 @@ from pydecor import export from pyGHDL import GHDLBaseException from pyGHDL.libghdl import LibGHDLException -from pyGHDL.dom import NonStandard from pyGHDL.dom.Common import DOMException +from pyGHDL.dom.NonStandard import Design, Document, Library from pyGHDL.dom.formatting.prettyprint import PrettyPrint, PrettyPrintException __all__ = [] @@ -19,14 +19,16 @@ __api__ = __all__ @export class Application: - _design: NonStandard.Design + _design: Design def __init__(self): - self._design = NonStandard.Design() + self._design = Design() def addFile(self, filename: Path, library: str): - document = NonStandard.Document(filename) - self._design.Documents.append(document) + lib = self._design.GetLibrary(library) + + document = Document(filename) + self._design.AddDocument(document, lib) def prettyPrint(self): PP = PrettyPrint() diff --git a/pyGHDL/dom/DesignUnit.py b/pyGHDL/dom/DesignUnit.py index 7eb15aebe..bf16b5c4b 100644 --- a/pyGHDL/dom/DesignUnit.py +++ b/pyGHDL/dom/DesignUnit.py @@ -115,7 +115,9 @@ class Package(VHDLModel_Package): @classmethod def parse(cls, packageNode: Iir): name = GetNameOfNode(packageNode) - generics = None # GetGenericsFromChainedNodes(nodes.Get_Generic_Chain(packageNode)) + generics = ( + None # GetGenericsFromChainedNodes(nodes.Get_Generic_Chain(packageNode)) + ) declaredItems = GetDeclaredItemsFromChainedNodes( nodes.Get_Declaration_Chain(packageNode), "package", name ) diff --git a/pyGHDL/dom/Object.py b/pyGHDL/dom/Object.py index 746971bac..953fddc41 100644 --- a/pyGHDL/dom/Object.py +++ b/pyGHDL/dom/Object.py @@ -37,6 +37,7 @@ from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode, GetExpressionFro from pyGHDL.dom._Utils import GetNameOfNode from pyVHDLModel.VHDLModel import ( Constant as VHDLModel_Constant, + DeferredConstant as VHDLModel_DeferredConstant, Variable as VHDLModel_Variable, Signal as VHDLModel_Signal, Expression, @@ -67,6 +68,24 @@ class Constant(VHDLModel_Constant): @export +class DeferredConstant(VHDLModel_DeferredConstant): + def __init__(self, name: str, subType: SubTypeOrSymbol): + super().__init__(name) + + self._name = name + self._subType = subType + + @classmethod + def parse(cls, node): + name = GetNameOfNode(node) + subTypeIndication = GetSubtypeIndicationFromNode( + node, "deferred constant", name + ) + + return cls(name, subTypeIndication) + + +@export class Variable(VHDLModel_Variable): def __init__( self, name: str, subType: SubTypeOrSymbol, defaultExpression: Expression diff --git a/pyGHDL/dom/formatting/prettyprint.py b/pyGHDL/dom/formatting/prettyprint.py index f19125811..0509b826d 100644 --- a/pyGHDL/dom/formatting/prettyprint.py +++ b/pyGHDL/dom/formatting/prettyprint.py @@ -54,7 +54,7 @@ class PrettyPrint: buffer = [] prefix = " " * level buffer.append("{prefix}Libraries:".format(prefix=prefix)) - for library in design.Libraries: + for library in design.Libraries.values(): for line in self.formatLibrary(library, level + 1): buffer.append(line) buffer.append("{prefix}Documents:".format(prefix=prefix)) @@ -74,18 +74,18 @@ class PrettyPrint: for entity in library.Entities: for line in self.formatEntity(entity, level + 1): buffer.append(line) - buffer.append("{prefix}Architectures:".format(prefix=prefix)) - for architecture in library.Architectures: - for line in self.formatArchitecture(architecture, level + 1): - buffer.append(line) + # buffer.append("{prefix}Architectures:".format(prefix=prefix)) + # for architecture in library.Architectures: + # for line in self.formatArchitecture(architecture, level + 1): + # buffer.append(line) buffer.append("{prefix}Packages:".format(prefix=prefix)) for package in library.Packages: for line in self.formatPackage(package, level + 1): buffer.append(line) - buffer.append("{prefix}PackageBodies:".format(prefix=prefix)) - for packageBodies in library.PackageBodies: - for line in self.formatPackageBody(packageBodies, level + 1): - buffer.append(line) + # buffer.append("{prefix}PackageBodies:".format(prefix=prefix)) + # for packageBodies in library.PackageBodies: + # for line in self.formatPackageBody(packageBodies, level + 1): + # buffer.append(line) buffer.append("{prefix}Configurations:".format(prefix=prefix)) for configuration in library.Configurations: for line in self.formatConfiguration(configuration, level + 1): |