Skip to content

Commit 4816241

Browse files
authored
PhysicalLiterals, QulaifiedExpression, Component
2 parents 06c9d46 + 23dabbc commit 4816241

File tree

3 files changed

+151
-15
lines changed

3 files changed

+151
-15
lines changed

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _LatestTagName():
3737

3838
# The full version, including alpha/beta/rc tags
3939
version = "0.9" # The short X.Y version.
40-
release = "0.10.1" # The full version, including alpha/beta/rc tags.
40+
release = "0.10.2" # The full version, including alpha/beta/rc tags.
4141
try:
4242
if _IsUnderGitControl:
4343
latestTagName = _LatestTagName()[1:] # remove prefix "v"

pyVHDLModel/VHDLModel.py

Lines changed: 149 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@
4343
# load dependencies
4444
from enum import Enum
4545
from pathlib import Path
46-
from typing import List, Tuple, Union
46+
from typing import List, Tuple, Union
47+
try:
48+
from typing import Protocol
49+
except ImportError:
50+
class Protocol:
51+
pass
4752

4853
from pydecor.decorators import export
4954

@@ -251,6 +256,19 @@ def Architecture(self) -> 'Architecture':
251256
return self._architecture
252257

253258

259+
@export
260+
class ComponentSymbol(Symbol):
261+
_component: 'Component'
262+
263+
def __init__(self):
264+
super().__init__()
265+
self._component = None
266+
267+
@property
268+
def Component(self) -> 'Component':
269+
return self._component
270+
271+
254272
@export
255273
class ConfigurationSymbol(Symbol):
256274
_configuration: 'Configuration'
@@ -329,16 +347,35 @@ class EnumerationLiteralSymbol(Symbol):
329347
class ObjectSymbol(Symbol):
330348
pass
331349

350+
332351
@export
333-
class SimpleObjectSymbol(Symbol):
334-
_object: Union['Constant', 'Signal', 'Variable']
352+
class SimpleObjectOrFunctionCallSymbol(Symbol):
353+
_object: Union['Constant', 'Signal', 'Variable', 'Function']
335354

336355
def __init__(self, objectName: str):
337356
super().__init__(objectName)
338357
self._object = None
339358

340359
@property
341-
def Object(self) -> Union['Constant', 'Signal', 'Variable']:
360+
def Object(self) -> Union['Constant', 'Signal', 'Variable', 'Function']:
361+
return self._object
362+
363+
def __str__(self) -> str:
364+
if self._object is not None:
365+
return str(self._object)
366+
return super().__str__()
367+
368+
369+
@export
370+
class IndexedObjectOrFunctionCallSymbol(Symbol):
371+
_object: Union['Constant', 'Signal', 'Variable', 'Function']
372+
373+
def __init__(self, objectName: str):
374+
super().__init__(objectName)
375+
self._object = None
376+
377+
@property
378+
def Object(self) -> Union['Constant', 'Signal', 'Variable', 'Function']:
342379
return self._object
343380

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

529566

567+
@export
568+
class Alias(ModelEntity, NamedEntity):
569+
def __init__(self, name: str):
570+
"""
571+
Initializes underlying ``BaseType``.
572+
573+
:param name: Name of the type.
574+
"""
575+
super().__init__()
576+
NamedEntity.__init__(self, name)
577+
578+
530579
@export
531580
class BaseType(ModelEntity, NamedEntity):
532581
"""``BaseType`` is the base class of all type entities in this model."""
@@ -798,7 +847,45 @@ def __str__(self) -> str:
798847

799848
@export
800849
class PhysicalLiteral(NumericLiteral):
801-
pass
850+
_unitName: str
851+
852+
def __init__(self, unitName: str):
853+
super().__init__()
854+
self._unitName = unitName
855+
856+
@property
857+
def UnitName(self) -> str:
858+
return self._unitName
859+
860+
def __str__(self) -> str:
861+
return "{value} {unit}".format(value=self._value, unit=self._unitName)
862+
863+
864+
@export
865+
class PhysicalIntegerLiteral(PhysicalLiteral):
866+
_value: int
867+
_unitName: str
868+
869+
def __init__(self, value: int, unitName: str):
870+
super().__init__(unitName)
871+
self._value = value
872+
873+
@property
874+
def Value(self) -> int:
875+
return self._value
876+
877+
878+
@export
879+
class PhysicalFloatingLiteral(PhysicalLiteral):
880+
_value: float
881+
882+
def __init__(self, value: float, unitName: str):
883+
super().__init__(unitName)
884+
self._value = value
885+
886+
@property
887+
def Value(self) -> float:
888+
return self._value
802889

803890

804891
@export
@@ -849,6 +936,13 @@ def __str__(self) -> str:
849936
return "\"" + self._value + "\""
850937

851938

939+
@export
940+
class ParenthesisExpression(Protocol):
941+
@property
942+
def Operand(self) -> Expression:
943+
pass
944+
945+
852946
@export
853947
class UnaryExpression(BaseExpression):
854948
"""
@@ -873,15 +967,15 @@ def __str__(self) -> str:
873967
)
874968

875969
@export
876-
class InverseExpression(UnaryExpression):
970+
class NegationExpression(UnaryExpression):
877971
_FORMAT = ("-", "")
878972

879973
@export
880974
class IdentityExpression(UnaryExpression):
881975
_FORMAT = ("+", "")
882976

883977
@export
884-
class NegationExpression(UnaryExpression):
978+
class InverseExpression(UnaryExpression):
885979
_FORMAT = ("not ", "")
886980

887981
@export
@@ -896,8 +990,9 @@ class TypeConversion(UnaryExpression):
896990
class FunctionCall(UnaryExpression):
897991
pass
898992

993+
899994
@export
900-
class ParenthesisExpression(UnaryExpression):
995+
class SubExpression(UnaryExpression, ParenthesisExpression):
901996
_FORMAT = ("(", ")")
902997

903998

@@ -932,10 +1027,6 @@ def __str__(self) -> str:
9321027
)
9331028

9341029

935-
@export
936-
class QualifiedExpression(BinaryExpression):
937-
pass
938-
9391030
@export
9401031
class AddingExpression(BinaryExpression):
9411032
"""
@@ -1083,6 +1174,30 @@ class RotateRightExpression(RotateExpression):
10831174
class RotateLeftExpression(RotateExpression):
10841175
_FORMAT = ("", " rol ", "")
10851176

1177+
1178+
@export
1179+
class QualifiedExpression(BaseExpression, ParenthesisExpression):
1180+
_operand: Expression
1181+
_subtype: SubTypeOrSymbol
1182+
1183+
def __init__(self):
1184+
super().__init__()
1185+
1186+
@property
1187+
def Operand(self):
1188+
return self._operand
1189+
1190+
@property
1191+
def SubTyped(self):
1192+
return self._subtype
1193+
1194+
def __str__(self) -> str:
1195+
return "{subtype}'({operand!s})".format(
1196+
subtype=self._subtype,
1197+
operand=self._operand,
1198+
)
1199+
1200+
10861201
@export
10871202
class TernaryExpression(BaseExpression):
10881203
"""
@@ -1207,7 +1322,7 @@ def Elements(self) -> List[AggregateElement]:
12071322
return self._elements
12081323

12091324
def __str__(self) -> str:
1210-
choices = [self.formatAggregateElement(element) for element in self._elements]
1325+
choices = [str(element) for element in self._elements]
12111326
return "({choices})".format(
12121327
choices=", ".join(choices)
12131328
)
@@ -1711,6 +1826,27 @@ def BodyItems(self) -> List['ConcurrentStatement']:
17111826
return self._bodyItems
17121827

17131828

1829+
@export
1830+
class Component(ModelEntity, NamedEntity):
1831+
_genericItems: List[GenericInterfaceItem]
1832+
_portItems: List[PortInterfaceItem]
1833+
1834+
def __init__(self, name: str):
1835+
super().__init__()
1836+
NamedEntity.__init__(self, name)
1837+
1838+
self._genericItems = []
1839+
self._portItems = []
1840+
1841+
@property
1842+
def GenericItems(self) -> List[GenericInterfaceItem]:
1843+
return self._genericItems
1844+
1845+
@property
1846+
def PortItems(self) -> List[PortInterfaceItem]:
1847+
return self._portItems
1848+
1849+
17141850
@export
17151851
class Configuration(PrimaryUnit, MixinDesignUnitWithContext):
17161852
def __init__(self, name: str):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
# Assemble all package information
5454
setuptools_setup(
5555
name=projectName,
56-
version="0.10.1",
56+
version="0.10.2",
5757

5858
author="Patrick Lehmann",
5959
author_email="[email protected]",

0 commit comments

Comments
 (0)