Skip to content

Commit

Permalink
PhysicalLiterals, QulaifiedExpression, Component
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels authored Jun 21, 2021
2 parents 06c9d46 + 23dabbc commit 4816241
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 15 deletions.
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _LatestTagName():

# The full version, including alpha/beta/rc tags
version = "0.9" # The short X.Y version.
release = "0.10.1" # The full version, including alpha/beta/rc tags.
release = "0.10.2" # The full version, including alpha/beta/rc tags.
try:
if _IsUnderGitControl:
latestTagName = _LatestTagName()[1:] # remove prefix "v"
Expand Down
162 changes: 149 additions & 13 deletions pyVHDLModel/VHDLModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
# load dependencies
from enum import Enum
from pathlib import Path
from typing import List, Tuple, Union
from typing import List, Tuple, Union
try:
from typing import Protocol
except ImportError:
class Protocol:
pass

from pydecor.decorators import export

Expand Down Expand Up @@ -251,6 +256,19 @@ def Architecture(self) -> 'Architecture':
return self._architecture


@export
class ComponentSymbol(Symbol):
_component: 'Component'

def __init__(self):
super().__init__()
self._component = None

@property
def Component(self) -> 'Component':
return self._component


@export
class ConfigurationSymbol(Symbol):
_configuration: 'Configuration'
Expand Down Expand Up @@ -329,16 +347,35 @@ class EnumerationLiteralSymbol(Symbol):
class ObjectSymbol(Symbol):
pass


@export
class SimpleObjectSymbol(Symbol):
_object: Union['Constant', 'Signal', 'Variable']
class SimpleObjectOrFunctionCallSymbol(Symbol):
_object: Union['Constant', 'Signal', 'Variable', 'Function']

def __init__(self, objectName: str):
super().__init__(objectName)
self._object = None

@property
def Object(self) -> Union['Constant', 'Signal', 'Variable']:
def Object(self) -> Union['Constant', 'Signal', 'Variable', 'Function']:
return self._object

def __str__(self) -> str:
if self._object is not None:
return str(self._object)
return super().__str__()


@export
class IndexedObjectOrFunctionCallSymbol(Symbol):
_object: Union['Constant', 'Signal', 'Variable', 'Function']

def __init__(self, objectName: str):
super().__init__(objectName)
self._object = None

@property
def Object(self) -> Union['Constant', 'Signal', 'Variable', 'Function']:
return self._object

def __str__(self) -> str:
Expand Down Expand Up @@ -527,6 +564,18 @@ def PackageBodies(self) -> List['PackageBody']:
return self._packageBodies


@export
class Alias(ModelEntity, NamedEntity):
def __init__(self, name: str):
"""
Initializes underlying ``BaseType``.
:param name: Name of the type.
"""
super().__init__()
NamedEntity.__init__(self, name)


@export
class BaseType(ModelEntity, NamedEntity):
"""``BaseType`` is the base class of all type entities in this model."""
Expand Down Expand Up @@ -798,7 +847,45 @@ def __str__(self) -> str:

@export
class PhysicalLiteral(NumericLiteral):
pass
_unitName: str

def __init__(self, unitName: str):
super().__init__()
self._unitName = unitName

@property
def UnitName(self) -> str:
return self._unitName

def __str__(self) -> str:
return "{value} {unit}".format(value=self._value, unit=self._unitName)


@export
class PhysicalIntegerLiteral(PhysicalLiteral):
_value: int
_unitName: str

def __init__(self, value: int, unitName: str):
super().__init__(unitName)
self._value = value

@property
def Value(self) -> int:
return self._value


@export
class PhysicalFloatingLiteral(PhysicalLiteral):
_value: float

def __init__(self, value: float, unitName: str):
super().__init__(unitName)
self._value = value

@property
def Value(self) -> float:
return self._value


@export
Expand Down Expand Up @@ -849,6 +936,13 @@ def __str__(self) -> str:
return "\"" + self._value + "\""


@export
class ParenthesisExpression(Protocol):
@property
def Operand(self) -> Expression:
pass


@export
class UnaryExpression(BaseExpression):
"""
Expand All @@ -873,15 +967,15 @@ def __str__(self) -> str:
)

@export
class InverseExpression(UnaryExpression):
class NegationExpression(UnaryExpression):
_FORMAT = ("-", "")

@export
class IdentityExpression(UnaryExpression):
_FORMAT = ("+", "")

@export
class NegationExpression(UnaryExpression):
class InverseExpression(UnaryExpression):
_FORMAT = ("not ", "")

@export
Expand All @@ -896,8 +990,9 @@ class TypeConversion(UnaryExpression):
class FunctionCall(UnaryExpression):
pass


@export
class ParenthesisExpression(UnaryExpression):
class SubExpression(UnaryExpression, ParenthesisExpression):
_FORMAT = ("(", ")")


Expand Down Expand Up @@ -932,10 +1027,6 @@ def __str__(self) -> str:
)


@export
class QualifiedExpression(BinaryExpression):
pass

@export
class AddingExpression(BinaryExpression):
"""
Expand Down Expand Up @@ -1083,6 +1174,30 @@ class RotateRightExpression(RotateExpression):
class RotateLeftExpression(RotateExpression):
_FORMAT = ("", " rol ", "")


@export
class QualifiedExpression(BaseExpression, ParenthesisExpression):
_operand: Expression
_subtype: SubTypeOrSymbol

def __init__(self):
super().__init__()

@property
def Operand(self):
return self._operand

@property
def SubTyped(self):
return self._subtype

def __str__(self) -> str:
return "{subtype}'({operand!s})".format(
subtype=self._subtype,
operand=self._operand,
)


@export
class TernaryExpression(BaseExpression):
"""
Expand Down Expand Up @@ -1207,7 +1322,7 @@ def Elements(self) -> List[AggregateElement]:
return self._elements

def __str__(self) -> str:
choices = [self.formatAggregateElement(element) for element in self._elements]
choices = [str(element) for element in self._elements]
return "({choices})".format(
choices=", ".join(choices)
)
Expand Down Expand Up @@ -1711,6 +1826,27 @@ def BodyItems(self) -> List['ConcurrentStatement']:
return self._bodyItems


@export
class Component(ModelEntity, NamedEntity):
_genericItems: List[GenericInterfaceItem]
_portItems: List[PortInterfaceItem]

def __init__(self, name: str):
super().__init__()
NamedEntity.__init__(self, name)

self._genericItems = []
self._portItems = []

@property
def GenericItems(self) -> List[GenericInterfaceItem]:
return self._genericItems

@property
def PortItems(self) -> List[PortInterfaceItem]:
return self._portItems


@export
class Configuration(PrimaryUnit, MixinDesignUnitWithContext):
def __init__(self, name: str):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# Assemble all package information
setuptools_setup(
name=projectName,
version="0.10.1",
version="0.10.2",

author="Patrick Lehmann",
author_email="Paebbels@gmail.com",
Expand Down

0 comments on commit 4816241

Please sign in to comment.