Skip to content

Commit

Permalink
General updates to the model.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Jul 19, 2024
1 parent e5da811 commit d0585f5
Show file tree
Hide file tree
Showing 27 changed files with 1,112 additions and 507 deletions.
2 changes: 1 addition & 1 deletion doc/DataStructure/CompileOrderGraph.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _datastruct:compileorder:
.. _datastruct:compileordergraph:

Compile Order Graph
###################
2 changes: 1 addition & 1 deletion doc/DataStructure/DependencyGraph.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _datastruct:dependgraph:
.. _datastruct:dependencygraph:

Dependency Graph
################
2 changes: 1 addition & 1 deletion doc/DataStructure/HierarchyGraph.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _datastruct:dependgraph:
.. _datastruct:hierarchygraph:

Hierarchy Graph
###############
2 changes: 1 addition & 1 deletion doc/Dependency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ the mandatory dependencies too.
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| **Package** | **Version** | **License** | **Dependencies** |
+=====================================================================+=============+========================================================================================+======================+
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥8.2 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥8.2 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `pytest-cov <https://GitHub.com/pytest-dev/pytest-cov>`__ | ≥5.0 | `MIT <https://GitHub.com/pytest-dev/pytest-cov/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
Expand Down
2 changes: 1 addition & 1 deletion doc/Doc-License.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ licensed under their terms and conditions, or any related information. Creative
Commons disclaims all liability for damages resulting from their use to the
fullest extent possible.

.. topic:: Using Creative Commons Public Licenses
.. rubric:: Using Creative Commons Public Licenses

Creative Commons public licenses provide a standard set of terms and conditions
that creators and other rights holders may use to share original works of
Expand Down
2 changes: 1 addition & 1 deletion doc/LanguageModel/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
VHDL Language Model
###################

.. topic:: Design Goal
.. rubric:: Design Goal

* Clearly named classes that model the semantics of VHDL.
* All language constructs (statements, declarations, specifications, …) have
Expand Down
4 changes: 4 additions & 0 deletions doc/_static/css/override.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ section > p,
text-align: justify
}

p.rubric {
text-decoration: underline
}

/* wyrm overrides */
.wy-menu-vertical header,
.wy-menu-vertical p.caption {
Expand Down
8 changes: 0 additions & 8 deletions doc/pyVHDLModel/index.rst

This file was deleted.

8 changes: 4 additions & 4 deletions pyVHDLModel/Association.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"""
from typing import Optional as Nullable, Union

from pyTooling.Decorators import export
from pyTooling.Decorators import export, readonly

from pyVHDLModel.Base import ModelEntity
from pyVHDLModel.Symbol import Symbol
Expand All @@ -62,7 +62,7 @@ class AssociationItem(ModelEntity):
_formal: Nullable[Symbol]
_actual: ExpressionUnion

def __init__(self, actual: ExpressionUnion, formal: Nullable[Symbol] = None):
def __init__(self, actual: ExpressionUnion, formal: Nullable[Symbol] = None) -> None:
super().__init__()

self._formal = formal
Expand All @@ -72,11 +72,11 @@ def __init__(self, actual: ExpressionUnion, formal: Nullable[Symbol] = None):
self._actual = actual
# actual._parent = self # FIXME: actual is provided as None

@property
@readonly
def Formal(self) -> Nullable[Symbol]: # TODO: can also be a conversion function !!
return self._formal

@property
@readonly
def Actual(self) -> ExpressionUnion:
return self._actual

Expand Down
48 changes: 26 additions & 22 deletions pyVHDLModel/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from enum import unique, Enum
from typing import Type, Tuple, Iterable, Optional as Nullable, Union, cast

from pyTooling.Decorators import export
from pyTooling.Decorators import export, readonly
from pyTooling.MetaClasses import ExtendedType


Expand Down Expand Up @@ -109,11 +109,15 @@ class ModelEntity(metaclass=ExtendedType, slots=True):

_parent: 'ModelEntity' #: Reference to a parent entity in the model.

def __init__(self) -> None:
"""Initializes a VHDL model entity."""
self._parent = None
def __init__(self, parent: Nullable["ModelEntity"] = None) -> None:
"""
Initializes a VHDL model entity.
@property
:param parent: The parent model entity of this entity.
"""
self._parent = parent

@readonly
def Parent(self) -> 'ModelEntity':
"""
Returns a reference to the parent entity.
Expand Down Expand Up @@ -142,7 +146,7 @@ class NamedEntityMixin(metaclass=ExtendedType, mixin=True):
_identifier: str #: The identifier of a model entity.
_normalizedIdentifier: str #: The normalized (lower case) identifier of a model entity.

def __init__(self, identifier: str):
def __init__(self, identifier: str) -> None:
"""
Initializes a named entity.
Expand All @@ -151,7 +155,7 @@ def __init__(self, identifier: str):
self._identifier = identifier
self._normalizedIdentifier = identifier.lower()

@property
@readonly
def Identifier(self) -> str:
"""
Returns a model entity's identifier (name).
Expand All @@ -160,7 +164,7 @@ def Identifier(self) -> str:
"""
return self._identifier

@property
@readonly
def NormalizedIdentifier(self) -> str:
"""
Returns a model entity's normalized identifier (lower case name).
Expand All @@ -183,7 +187,7 @@ class MultipleNamedEntityMixin(metaclass=ExtendedType, mixin=True):
_identifiers: Tuple[str] #: A list of identifiers.
_normalizedIdentifiers: Tuple[str] #: A list of normalized (lower case) identifiers.

def __init__(self, identifiers: Iterable[str]):
def __init__(self, identifiers: Iterable[str]) -> None:
"""
Initializes a multiple-named entity.
Expand All @@ -192,7 +196,7 @@ def __init__(self, identifiers: Iterable[str]):
self._identifiers = tuple(identifiers)
self._normalizedIdentifiers = tuple([identifier.lower() for identifier in identifiers])

@property
@readonly
def Identifiers(self) -> Tuple[str]:
"""
Returns a model entity's tuple of identifiers (names).
Expand All @@ -201,7 +205,7 @@ def Identifiers(self) -> Tuple[str]:
"""
return self._identifiers

@property
@readonly
def NormalizedIdentifiers(self) -> Tuple[str]:
"""
Returns a model entity's tuple of normalized identifiers (lower case names).
Expand All @@ -222,7 +226,7 @@ class LabeledEntityMixin(metaclass=ExtendedType, mixin=True):
_label: Nullable[str] #: The label of a model entity.
_normalizedLabel: Nullable[str] #: The normalized (lower case) label of a model entity.

def __init__(self, label: Nullable[str]):
def __init__(self, label: Nullable[str]) -> None:
"""
Initializes a labeled entity.
Expand All @@ -231,7 +235,7 @@ def __init__(self, label: Nullable[str]):
self._label = label
self._normalizedLabel = label.lower() if label is not None else None

@property
@readonly
def Label(self) -> Nullable[str]:
"""
Returns a model entity's label.
Expand All @@ -240,7 +244,7 @@ def Label(self) -> Nullable[str]:
"""
return self._label

@property
@readonly
def NormalizedLabel(self) -> Nullable[str]:
"""
Returns a model entity's normalized (lower case) label.
Expand All @@ -261,15 +265,15 @@ class DocumentedEntityMixin(metaclass=ExtendedType, mixin=True):

_documentation: Nullable[str] #: The associated documentation of a model entity.

def __init__(self, documentation: Nullable[str]):
def __init__(self, documentation: Nullable[str]) -> None:
"""
Initializes a documented entity.
:param documentation: Documentation of a model entity.
"""
self._documentation = documentation

@property
@readonly
def Documentation(self) -> Nullable[str]:
"""
Returns a model entity's associated documentation.
Expand Down Expand Up @@ -306,7 +310,7 @@ def __init__(self) -> None:
@export
class ConditionalBranchMixin(BranchMixin, ConditionalMixin, mixin=True):
"""A ``BaseBranch`` is a mixin-class for all branch statements with a condition."""
def __init__(self, condition: ExpressionUnion):
def __init__(self, condition: ExpressionUnion) -> None:
super().__init__()
ConditionalMixin.__init__(self, condition)

Expand Down Expand Up @@ -355,7 +359,7 @@ def Severity(self) -> Nullable[ExpressionUnion]:
class AssertStatementMixin(ReportStatementMixin, ConditionalMixin, mixin=True):
"""A ``MixinAssertStatement`` is a mixin-class for all assert statements."""

def __init__(self, condition: ExpressionUnion, message: Nullable[ExpressionUnion] = None, severity: Nullable[ExpressionUnion] = None):
def __init__(self, condition: ExpressionUnion, message: Nullable[ExpressionUnion] = None, severity: Nullable[ExpressionUnion] = None) -> None:
super().__init__(message, severity)
ConditionalMixin.__init__(self, condition)

Expand Down Expand Up @@ -385,8 +389,8 @@ class Range(ModelEntity):
_rightBound: ExpressionUnion
_direction: Direction

def __init__(self, leftBound: ExpressionUnion, rightBound: ExpressionUnion, direction: Direction):
super().__init__()
def __init__(self, leftBound: ExpressionUnion, rightBound: ExpressionUnion, direction: Direction, parent: ModelEntity = None) -> None:
super().__init__(parent)

self._leftBound = leftBound
leftBound._parent = self
Expand Down Expand Up @@ -417,8 +421,8 @@ class WaveformElement(ModelEntity):
_expression: ExpressionUnion
_after: ExpressionUnion

def __init__(self, expression: ExpressionUnion, after: Nullable[ExpressionUnion] = None):
super().__init__()
def __init__(self, expression: ExpressionUnion, after: Nullable[ExpressionUnion] = None, parent: ModelEntity = None) -> None:
super().__init__(parent)

self._expression = expression
expression._parent = self
Expand Down
14 changes: 7 additions & 7 deletions pyVHDLModel/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"""
from typing import List, Iterable, Union, Optional as Nullable

from pyTooling.Decorators import export
from pyTooling.Decorators import export, readonly
from pyTooling.MetaClasses import ExtendedType

from pyVHDLModel.Base import ModelEntity, LabeledEntityMixin
Expand All @@ -60,8 +60,8 @@ class Statement(ModelEntity, LabeledEntityMixin):
"""
A ``Statement`` is a base-class for all statements.
"""
def __init__(self, label: Nullable[str] = None) -> None:
super().__init__()
def __init__(self, label: Nullable[str] = None, parent=None) -> None:
super().__init__(parent)
LabeledEntityMixin.__init__(self, label)


Expand All @@ -70,7 +70,7 @@ class ProcedureCallMixin(metaclass=ExtendedType, mixin=True):
_procedure: Symbol # TODO: implement a ProcedureSymbol
_parameterMappings: List[ParameterAssociationItem]

def __init__(self, procedureName: Symbol, parameterMappings: Nullable[Iterable[ParameterAssociationItem]] = None):
def __init__(self, procedureName: Symbol, parameterMappings: Nullable[Iterable[ParameterAssociationItem]] = None) -> None:
self._procedure = procedureName
procedureName._parent = self

Expand All @@ -81,7 +81,7 @@ def __init__(self, procedureName: Symbol, parameterMappings: Nullable[Iterable[P
self._parameterMappings.append(parameterMapping)
parameterMapping._parent = self

@property
@readonly
def Procedure(self) -> Symbol:
return self._procedure

Expand All @@ -96,7 +96,7 @@ class AssignmentMixin(metaclass=ExtendedType, mixin=True):

_target: Symbol

def __init__(self, target: Symbol):
def __init__(self, target: Symbol) -> None:
self._target = target
target._parent = self

Expand All @@ -117,7 +117,7 @@ class VariableAssignmentMixin(AssignmentMixin, mixin=True):
# FIXME: move to sequential?
_expression: ExpressionUnion

def __init__(self, target: Symbol, expression: ExpressionUnion):
def __init__(self, target: Symbol, expression: ExpressionUnion) -> None:
super().__init__(target)

self._expression = expression
Expand Down
Loading

0 comments on commit d0585f5

Please sign in to comment.