Skip to content

Commit

Permalink
Set parent reference or None.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Sep 26, 2024
1 parent 8e29087 commit 11134c7
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 115 deletions.
16 changes: 8 additions & 8 deletions pyVHDLModel/IEEE.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,20 @@ def __init__(self) -> None:
EnumerationLiteral("L"),
EnumerationLiteral("H"),
EnumerationLiteral("-"),
))
), None)
self._types[stdULogic._normalizedIdentifier] = stdULogic
self._declaredItems.append(stdULogic)

stdULogicVector = ArrayType("std_ulogic_vector", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")))
stdULogicVector = ArrayType("std_ulogic_vector", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")), None)
self._types[stdULogicVector._normalizedIdentifier] = stdULogicVector
self._declaredItems.append(stdULogicVector)

stdLogic = Subtype("std_logic", SimpleSubtypeSymbol(SimpleName("std_ulogic")))
stdLogic = Subtype("std_logic", SimpleSubtypeSymbol(SimpleName("std_ulogic")), None)
stdLogic._baseType = stdULogic
self._subtypes[stdLogic._normalizedIdentifier] = stdLogic
self._declaredItems.append(stdLogic)

stdLogicVector = Subtype("std_logic_vector", SimpleSubtypeSymbol(SimpleName("std_ulogic_vector")))
stdLogicVector = Subtype("std_logic_vector", SimpleSubtypeSymbol(SimpleName("std_ulogic_vector")), None)
stdLogicVector._baseType = stdULogicVector
self._subtypes[stdLogicVector._normalizedIdentifier] = stdLogicVector
self._declaredItems.append(stdLogicVector)
Expand Down Expand Up @@ -267,20 +267,20 @@ def __init__(self) -> None:
self._AddLibraryClause(("IEEE", ))
self._AddPackageClause(("IEEE.std_logic_1164.all", ))

unresolvedUnsigned = ArrayType("unresolved_unsigned", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")))
unresolvedUnsigned = ArrayType("unresolved_unsigned", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")), None)
self._types[unresolvedUnsigned._normalizedIdentifier] = unresolvedUnsigned
self._declaredItems.append(unresolvedUnsigned)

unsigned = Subtype("unsigned", SimpleSubtypeSymbol(SimpleName("unresolved_unsigned")))
unsigned = Subtype("unsigned", SimpleSubtypeSymbol(SimpleName("unresolved_unsigned")), None)
unsigned._baseType = unresolvedUnsigned
self._subtypes[unsigned._normalizedIdentifier] = unsigned
self._declaredItems.append(unsigned)

unresolvedSigned = ArrayType("unresolved_signed", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")))
unresolvedSigned = ArrayType("unresolved_signed", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")), None)
self._types[unresolvedSigned._normalizedIdentifier] = unresolvedSigned
self._declaredItems.append(unresolvedSigned)

signed = Subtype("signed", SimpleSubtypeSymbol(SimpleName("unresolved_signed")))
signed = Subtype("signed", SimpleSubtypeSymbol(SimpleName("unresolved_signed")), None)
signed._baseType = unresolvedSigned
self._subtypes[signed._normalizedIdentifier] = signed
self._declaredItems.append(signed)
Expand Down
6 changes: 3 additions & 3 deletions pyVHDLModel/PSLModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ class PSLPrimaryUnit(PrimaryUnit):
@export
class VerificationUnit(PSLPrimaryUnit):
def __init__(self, identifier: str) -> None:
super().__init__(identifier)
super().__init__(identifier, parent=None)


@export
class VerificationProperty(PSLPrimaryUnit):
def __init__(self, identifier: str) -> None:
super().__init__(identifier)
super().__init__(identifier, parent=None)


@export
class VerificationMode(PSLPrimaryUnit):
def __init__(self, identifier: str) -> None:
super().__init__(identifier)
super().__init__(identifier, parent=None)


@export
Expand Down
8 changes: 4 additions & 4 deletions pyVHDLModel/Predefined.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class PredefinedLibrary(Library):
* :class:`~pyVHDLModel.IEEE.Ieee`
"""

def __init__(self, packages):
super().__init__(self.__class__.__name__)
def __init__(self, packages) -> None:
super().__init__(self.__class__.__name__, None)

self.AddPackages(packages)

Expand Down Expand Up @@ -105,7 +105,7 @@ class PredefinedPackage(Package, PredefinedPackageMixin):
"""

def __init__(self) -> None:
super().__init__(self.__class__.__name__)
super().__init__(self.__class__.__name__, parent=None)


@export
Expand All @@ -116,4 +116,4 @@ class PredefinedPackageBody(PackageBody, PredefinedPackageMixin):

def __init__(self) -> None:
packageSymbol = PackageSymbol(SimpleName(self.__class__.__name__[:-5]))
super().__init__(packageSymbol)
super().__init__(packageSymbol, parent=None)
55 changes: 25 additions & 30 deletions pyVHDLModel/STD.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ class Standard(PredefinedPackage):
def __init__(self) -> None:
super().__init__()

boolean = EnumeratedType("boolean", (EnumerationLiteral("false"), EnumerationLiteral("true")))
boolean = EnumeratedType("boolean", (EnumerationLiteral("false"), EnumerationLiteral("true")), None)
self._types[boolean._normalizedIdentifier] = boolean
self._declaredItems.append(boolean)

bit = EnumeratedType("bit", (EnumerationLiteral("'0'"), EnumerationLiteral("'1'")))
bit = EnumeratedType("bit", (EnumerationLiteral("'0'"), EnumerationLiteral("'1'")), None)
self._types[bit._normalizedIdentifier] = bit
self._declaredItems.append(bit)

Expand All @@ -108,83 +108,78 @@ def __init__(self) -> None:
"'È'", "'É'", "'Ê'", "'Ë'", "'Ì'", "'Í'", "'Î'", "'Ï'", "'Ð'", "'Ñ'", "'Ò'", "'Ó'", "'Ô'", "'Õ'", "'Ö'", "'×'", "'Ø'", "'Ù'", "'Ú'", "'Û'",\
"'Ü'", "'Ý'", "'Þ'", "'ß'", "'à'", "'á'", "'â'", "'ã'", "'ä'", "'å'", "'æ'", "'ç'", "'è'", "'é'", "'ê'", "'ë'", "'ì'", "'í'", "'î'", "'ï'",\
"'ð'", "'ñ'", "'ò'", "'ó'", "'ô'", "'õ'", "'ö'", "'÷'", "'ø'", "'ù'", "'ú'", "'û'", "'ü'", "'ý'", "'þ'", "'ÿ'"
character = EnumeratedType("character", [EnumerationLiteral(char) for char in chars])
character = EnumeratedType("character", [EnumerationLiteral(char) for char in chars], None)
self._types[character._normalizedIdentifier] = character
self._declaredItems.append(character)

levels = "note", "warning", "error", "failure"
severityLevel = EnumeratedType("severityLevel", [EnumerationLiteral(level) for level in levels])
severityLevel = EnumeratedType("severityLevel", [EnumerationLiteral(level) for level in levels], None)
self._types[severityLevel._normalizedIdentifier] = severityLevel
self._declaredItems.append(severityLevel)

integer = IntegerType("integer", Range(IntegerLiteral(-2**31), IntegerLiteral(2**31-1), Direction.To))
integer = IntegerType("integer", Range(IntegerLiteral(-2**31), IntegerLiteral(2**31 - 1), Direction.To), None)
self._types[integer._normalizedIdentifier] = integer
self._declaredItems.append(integer)

# real

time = PhysicalType(
"time",
Range(IntegerLiteral(-2**63), IntegerLiteral(2**63-1), Direction.To),
primaryUnit="fs",
units=(
("ps", PhysicalIntegerLiteral(1000, "fs")),
("ns", PhysicalIntegerLiteral(1000, "ps")),
("us", PhysicalIntegerLiteral(1000, "ns")),
("ms", PhysicalIntegerLiteral(1000, "us")),
("sec", PhysicalIntegerLiteral(1000, "ms")),
("min", PhysicalIntegerLiteral(60, "sec")),
("hr", PhysicalIntegerLiteral(60, "min")),
)
)
time = PhysicalType("time", Range(IntegerLiteral(-2**63), IntegerLiteral(2**63 - 1), Direction.To), primaryUnit="fs", units=(
("ps", PhysicalIntegerLiteral(1000, "fs")),
("ns", PhysicalIntegerLiteral(1000, "ps")),
("us", PhysicalIntegerLiteral(1000, "ns")),
("ms", PhysicalIntegerLiteral(1000, "us")),
("sec", PhysicalIntegerLiteral(1000, "ms")),
("min", PhysicalIntegerLiteral(60, "sec")),
("hr", PhysicalIntegerLiteral(60, "min")),
), parent=None)
self._types[time._normalizedIdentifier] = time
self._declaredItems.append(time)

# delay_length

# now

natural = Subtype("natural", SimpleSubtypeSymbol(SimpleName("integer")))
natural = Subtype("natural", SimpleSubtypeSymbol(SimpleName("integer")), None)
natural._baseType = integer
natural._range = Range(IntegerLiteral(0), IntegerLiteral(2**31-1), Direction.To)
natural._range = Range(IntegerLiteral(0), IntegerLiteral(2**31 - 1), Direction.To)
self._subtypes[natural._normalizedIdentifier] = natural
self._declaredItems.append(natural)

positive = Subtype("positive", SimpleSubtypeSymbol(SimpleName("integer")))
positive = Subtype("positive", SimpleSubtypeSymbol(SimpleName("integer")), None)
positive._baseType = integer
positive._range = Range(IntegerLiteral(1), IntegerLiteral(2**31-1), Direction.To)
positive._range = Range(IntegerLiteral(1), IntegerLiteral(2**31 - 1), Direction.To)
self._subtypes[positive._normalizedIdentifier] = positive
self._declaredItems.append(positive)

string = ArrayType("string", (SimpleSubtypeSymbol(SimpleName("positive")), ), SimpleSubtypeSymbol(SimpleName("character")))
string = ArrayType("string", (SimpleSubtypeSymbol(SimpleName("positive")),), SimpleSubtypeSymbol(SimpleName("character")), None)
self._types[string._normalizedIdentifier] = string
self._declaredItems.append(string)

booleanVector = ArrayType("boolean_vector", (SimpleSubtypeSymbol(SimpleName("natural")), ), SimpleSubtypeSymbol(SimpleName("boolean")))
booleanVector = ArrayType("boolean_vector", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("boolean")), None)
self._types[booleanVector._normalizedIdentifier] = booleanVector
self._declaredItems.append(booleanVector)

bitVector = ArrayType("bit_vector", (SimpleSubtypeSymbol(SimpleName("natural")), ), SimpleSubtypeSymbol(SimpleName("bit")))
bitVector = ArrayType("bit_vector", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("bit")), None)
self._types[bitVector._normalizedIdentifier] = bitVector
self._declaredItems.append(bitVector)

integerVector = ArrayType("integer_vector", (SimpleSubtypeSymbol(SimpleName("natural")), ), SimpleSubtypeSymbol(SimpleName("integer")))
integerVector = ArrayType("integer_vector", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("integer")), None)
self._types[integerVector._normalizedIdentifier] = integerVector
self._declaredItems.append(integerVector)

# real_vector

timeVector = ArrayType("time_vector", (SimpleSubtypeSymbol(SimpleName("natural")), ), SimpleSubtypeSymbol(SimpleName("time")))
timeVector = ArrayType("time_vector", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("time")), None)
self._types[timeVector._normalizedIdentifier] = timeVector
self._declaredItems.append(timeVector)

fileOpenKinds = "read_mode", "write_mode", "append_mode"
openFileKind = EnumeratedType("open_file_kind", [EnumerationLiteral(kind) for kind in fileOpenKinds])
openFileKind = EnumeratedType("open_file_kind", [EnumerationLiteral(kind) for kind in fileOpenKinds], None)
self._types[openFileKind._normalizedIdentifier] = openFileKind
self._declaredItems.append(openFileKind)

fileOpenStati = "open_ok", "status_error", "name_error", "mode_error"
fileOpenStatus = EnumeratedType("open_file_status", [EnumerationLiteral(status) for status in fileOpenStati])
fileOpenStatus = EnumeratedType("open_file_status", [EnumerationLiteral(status) for status in fileOpenStati], None)
self._types[fileOpenStatus._normalizedIdentifier] = fileOpenStatus
self._declaredItems.append(fileOpenStatus)

Expand Down
20 changes: 11 additions & 9 deletions tests/unit/Analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def CreateDesign(self) -> Design:
library = design.GetLibrary("lib_1")

path = Path("tests.vhdl")
document = Document(path, documentation="Testing 'Library' class.")
document = Document(path, documentation="Testing 'Library' class.", parent=None)

contextReferences = [
LibraryClause([
Expand All @@ -64,7 +64,7 @@ def CreateDesign(self) -> Design:
AllPackageMembersReferenceSymbol(AllName(SelectedName("std_logic_1164", SimpleName("ieee")))),
])
]
context = Context("ctx_1", contextReferences, documentation="My first context.")
context = Context("ctx_1", contextReferences, documentation="My first context.", parent=None)
document._AddDesignUnit(context)

entityAReferences = [
Expand All @@ -81,44 +81,46 @@ def CreateDesign(self) -> Design:
AllPackageMembersReferenceSymbol(AllName(SelectedName("pack_1", SimpleName("work")))),
])
]
entityA = Entity("entity_A", entityAReferences, documentation="My first entity.")
entityA = Entity("entity_A", entityAReferences, documentation="My first entity.", parent=None)
document._AddDesignUnit(entityA)

architectureAReferences = [
UseClause([
AllPackageMembersReferenceSymbol(AllName(SelectedName("textio", SimpleName("std")))),
]),
]
architectureA = Architecture("arch_A", EntitySymbol(SimpleName("entity_A")), architectureAReferences, documentation="My first entity implementation.")
architectureA = Architecture("arch_A", EntitySymbol(SimpleName("entity_A")), architectureAReferences, documentation="My first entity implementation.",
parent=None)
document._AddDesignUnit(architectureA)

entityBReferences = [
ContextReference([
ContextReferenceSymbol(SelectedName("ctx_1", SimpleName("work"))),
]),
]
entityB = Entity("entity_B", entityBReferences, documentation="My second entity.")
entityB = Entity("entity_B", entityBReferences, documentation="My second entity.", parent=None)
document._AddDesignUnit(entityB)

architectureBStatements = [
EntityInstantiation("instWork", EntityInstantiationSymbol(SelectedName("entity_A", SimpleName("work")))),
EntityInstantiation("instLib", EntityInstantiationSymbol(SelectedName("entity_A", SimpleName("lib_1")))),
]
architectureB = Architecture("arch_B", EntitySymbol(SimpleName("entity_B")), None, None, architectureBStatements, documentation="My second entity implementation.")
architectureB = Architecture("arch_B", EntitySymbol(SimpleName("entity_B")), None, None, architectureBStatements,
documentation="My second entity implementation.", parent=None)
document._AddDesignUnit(architectureB)

packageReferences = [
ContextReference([
ContextReferenceSymbol(SelectedName("ctx_1", SimpleName("work"))),
]),
]
package = Package("pack_1", packageReferences, documentation="My first utility package.")
package = Package("pack_1", packageReferences, documentation="My first utility package.", parent=None)
document._AddDesignUnit(package)

packageBody = PackageBody(PackageSymbol(SimpleName("pack_1")))
packageBody = PackageBody(PackageSymbol(SimpleName("pack_1")), parent=None)
document._AddDesignUnit(packageBody)

configuration = Configuration("cfg_1")
configuration = Configuration("cfg_1", parent=None)
document._AddDesignUnit(configuration)

design.AddDocument(document, library)
Expand Down
Loading

0 comments on commit 11134c7

Please sign in to comment.