Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/Dependency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pyVHDLModel Package
+--------------------------------------------------------+-------------+------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
| **Package** | **Version** | **License** | **Dependencies** |
+========================================================+=============+==========================================================================================+=================================================================================================================================+
| `pyTooling <https://GitHub.com/pyTooling/pyTooling>`__ | ≥8.7 | `Apache License, 2.0 <https://GitHub.com/pyTooling/pyTooling/blob/master/LICENSE.txt>`__ | *None* |
| `pyTooling <https://GitHub.com/pyTooling/pyTooling>`__ | ≥8.8 | `Apache License, 2.0 <https://GitHub.com/pyTooling/pyTooling/blob/master/LICENSE.txt>`__ | *None* |
+--------------------------------------------------------+-------------+------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+


Expand Down Expand Up @@ -51,7 +51,7 @@ the mandatory dependencies too.
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| **Package** | **Version** | **License** | **Dependencies** |
+=====================================================================+=============+========================================================================================+======================+
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥8.4 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥9.0 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `pytest-cov <https://GitHub.com/pytest-dev/pytest-cov>`__ | ≥7.0 | `MIT <https://GitHub.com/pytest-dev/pytest-cov/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
Expand Down Expand Up @@ -89,7 +89,7 @@ the mandatory dependencies too.
+-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+----------------------+
| **Package** | **Version** | **License** | **Dependencies** |
+=================================================================================================+==============+==========================================================================================================+======================+
| `pyTooling <https://GitHub.com/pyTooling/pyTooling>`__ | ≥8.7 | `Apache License, 2.0 <https://GitHub.com/pyTooling/pyTooling/blob/main/LICENSE.md>`__ | *None* |
| `pyTooling <https://GitHub.com/pyTooling/pyTooling>`__ | ≥8.8 | `Apache License, 2.0 <https://GitHub.com/pyTooling/pyTooling/blob/main/LICENSE.md>`__ | *None* |
+-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+----------------------+
| `Sphinx <https://GitHub.com/sphinx-doc/sphinx>`__ | ≥8.2 | `BSD 3-Clause <https://GitHub.com/sphinx-doc/sphinx/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+----------------------+
Expand Down Expand Up @@ -129,7 +129,7 @@ install the mandatory dependencies too.
+----------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| **Package** | **Version** | **License** | **Dependencies** |
+============================================================================+==============+==========================================================================================================+======================================================================================================================================================+
| `pyTooling <https://GitHub.com/pyTooling/pyTooling>`__ | ≥8.7 | `Apache License, 2.0 <https://GitHub.com/pyTooling/pyTooling/blob/main/LICENSE.md>`__ | *None* |
| `pyTooling <https://GitHub.com/pyTooling/pyTooling>`__ | ≥8.8 | `Apache License, 2.0 <https://GitHub.com/pyTooling/pyTooling/blob/main/LICENSE.md>`__ | *None* |
+----------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| `wheel <https://GitHub.com/pypa/wheel>`__ | ≥0.45 | `MIT <https://github.com/pypa/wheel/blob/main/LICENSE.txt>`__ | *Not yet evaluated.* |
+----------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
Expand Down
36 changes: 22 additions & 14 deletions pyVHDLModel/Exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,36 @@
The module ``Exceptions`` contains all structured errors that are raised by pyVHDLModel. Besides a default error
message in english, each exception object contains one or multiple references to the exception's context.
"""
from sys import version_info
from typing import List

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

from pyVHDLModel.Symbol import Symbol


@export
class VHDLModelWarning(Warning):
pass


@export
class NotImplementedWarning(VHDLModelWarning):
pass


from pyVHDLModel.Symbol import Symbol
@export
class VHDLModelCriticalWarning(Warning):
pass


@export
class BlackboxWarning(VHDLModelCriticalWarning):
pass


@export
class VHDLModelException(Exception):
"""Base-class for all exceptions (errors) raised by pyVHDLModel."""

# WORKAROUND: for Python <3.11
# Implementing a dummy method for Python versions before
__notes__: List[str]
if version_info < (3, 11): # pragma: no cover
def add_note(self, message: str) -> None:
try:
self.__notes__.append(message)
except AttributeError:
self.__notes__ = [message]


@export
class LibraryExistsInDesignError(VHDLModelException):
Expand Down
81 changes: 40 additions & 41 deletions pyVHDLModel/Expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
All declarations for literals, aggregates, operators forming an expressions.
"""
from enum import Flag
from typing import Tuple, List, Iterable, Union, ClassVar
from typing import Tuple, List, Iterable, Union, ClassVar, Optional as Nullable

from pyTooling.Decorators import export, readonly

Expand Down Expand Up @@ -211,77 +211,76 @@ class BitStringBase(Flag):
@export
class BitStringLiteral(Literal):
# _base: ClassVar[BitStringBase]
_value: str
_bits: int
_value: str
_binaryValue: str
_bits: int
_length: Nullable[int]
_signed: Nullable[bool]

def __init__(self, value: str) -> None:
def __init__(self, value: str, length: Nullable[int] = None, signed: Nullable[bool] = None) -> None:
super().__init__()
self._bits = len(value)
self._value = value
self._length = length
self._signed = signed

@readonly
def Bits(self) -> int:
return self._bits
self._binaryValue = None
self._bits = None

@readonly
def Value(self) -> str:
return self._value

@readonly
def BinaryValue(self) -> str:
return self._binaryValue

@readonly
def Bits(self) -> Nullable[int]:
return self._bits

@readonly
def Length(self) -> Nullable[int]:
return self._length

@readonly
def Signed(self) -> Nullable[bool]:
return self._signed

def __str__(self) -> str:
return "\"" + self._value + "\""
signed = "" if self._signed is None else "s" if self._signed is True else "u"
if self._base is BitStringBase.NoBase:
base = ""
elif self._base is BitStringBase.Binary:
base = "b"
elif self._base is BitStringBase.Octal:
base = "o"
elif self._base is BitStringBase.Decimal:
base = "d"
elif self._base is BitStringBase.Hexadecimal:
base = "x"
length = "" if self._length is None else str(self._length)
return length + signed + base + "\"" + self._value + "\""


@export
class BinaryBitStringLiteral(BitStringLiteral):
_base: ClassVar[BitStringBase] = BitStringBase.Binary

def __init__(self, value: str, bits: int = 0) -> None:
super().__init__(value)
if bits > 0:
self._bits = bits

def __str__(self) -> str:
return "b\"" + self._value + "\""


@export
class OctalBitStringLiteral(BitStringLiteral):
_base: ClassVar[BitStringBase] = BitStringBase.Octal

def __init__(self, value: str, bits: int = 0) -> None:
super().__init__(value)
if bits > 0:
self._bits = bits

def __str__(self) -> str:
return "o\"" + self._value + "\""


@export
class DecimalBitStringLiteral(BitStringLiteral):
_base: ClassVar[BitStringBase] = BitStringBase.Decimal

def __init__(self, value: str, bits: int = 0) -> None:
super().__init__(value)
if bits > 0:
self._bits = bits

def __str__(self) -> str:
return "d\"" + self._value + "\""


@export
class HexadecimalBitStringLiteral(BitStringLiteral):
_base: ClassVar[BitStringBase] = BitStringBase.Hexadecimal

def __init__(self, value: str, bits: int = 0) -> None:
super().__init__(value)
if bits > 0:
self._bits = bits

def __str__(self) -> str:
return "x\"" + self._value + "\""


@export
class ParenthesisExpression: #(Protocol):
Expand Down
13 changes: 12 additions & 1 deletion pyVHDLModel/Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

tbd.
"""
from typing import List, Dict, Iterable, Optional as Nullable
from typing import List, Dict, Iterable, Optional as Nullable, Any

from pyTooling.Decorators import export, readonly
from pyTooling.MetaClasses import ExtendedType
Expand All @@ -61,6 +61,7 @@ class ConcurrentDeclarationRegionMixin(metaclass=ExtendedType, mixin=True):
# _subprograms: Dict[str, Dict[str, Subprogram]] #: Dictionary of all subprograms declared in this concurrent declaration region.
_functions: Dict[str, Dict[str, Function]] #: Dictionary of all functions declared in this concurrent declaration region.
_procedures: Dict[str, Dict[str, Procedure]] #: Dictionary of all procedures declared in this concurrent declaration region.
_components: Dict[str, Any] #: Dictionary of all components declared in this concurrent declaration region.

def __init__(self, declaredItems: Nullable[Iterable] = None) -> None:
# TODO: extract to mixin
Expand All @@ -80,6 +81,7 @@ def __init__(self, declaredItems: Nullable[Iterable] = None) -> None:
# self._subprograms = {}
self._functions = {}
self._procedures = {}
self._components = {}

@readonly
def DeclaredItems(self) -> List:
Expand Down Expand Up @@ -125,6 +127,10 @@ def Functions(self) -> Dict[str, Dict[str, Function]]:
def Procedures(self) -> Dict[str, Dict[str, Procedure]]:
return self._procedures

@readonly
def Components(self) -> Dict[str, Any]:
return self._components

def IndexDeclaredItems(self) -> None:
"""
Index declared items listed in the concurrent declaration region.
Expand Down Expand Up @@ -155,6 +161,8 @@ def IndexDeclaredItems(self) -> None:
:meth:`pyVHDLModel.Library._IndexOtherDeclaredItem`
Iterate all packages in the library and index declared items.
"""
from pyVHDLModel.DesignUnit import Component

for item in self._declaredItems:
if isinstance(item, FullType):
self._types[item._normalizedIdentifier] = item
Expand Down Expand Up @@ -187,6 +195,9 @@ def IndexDeclaredItems(self) -> None:
for normalizedIdentifier in item._normalizedIdentifiers:
self._files[normalizedIdentifier] = item
self._namespace._elements[normalizedIdentifier] = item
elif isinstance(item, Component):
self._components[item._normalizedIdentifier] = item
self._namespace._elements[item._normalizedIdentifier] = item
else:
self._IndexOtherDeclaredItem(item)

Expand Down
11 changes: 9 additions & 2 deletions pyVHDLModel/STD.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
from pyVHDLModel.Base import Range, Direction
from pyVHDLModel.Name import SimpleName
from pyVHDLModel.Symbol import SimpleSubtypeSymbol
from pyVHDLModel.Expression import EnumerationLiteral, IntegerLiteral, PhysicalIntegerLiteral
from pyVHDLModel.Type import EnumeratedType, IntegerType, Subtype, PhysicalType, ArrayType
from pyVHDLModel.Expression import EnumerationLiteral, IntegerLiteral, FloatingPointLiteral, PhysicalIntegerLiteral
from pyVHDLModel.Type import EnumeratedType, IntegerType, RealType, PhysicalType, ArrayType, AccessType, Subtype
from pyVHDLModel.Predefined import PredefinedLibrary, PredefinedPackage, PredefinedPackageBody


Expand Down Expand Up @@ -122,6 +122,9 @@ def __init__(self) -> None:
self._declaredItems.append(integer)

# real
real = RealType("real", Range(FloatingPointLiteral(-5.0), FloatingPointLiteral(5.0), Direction.To), None)
self._types[real._normalizedIdentifier] = real
self._declaredItems.append(real)

time = PhysicalType("time", Range(IntegerLiteral(-2**63), IntegerLiteral(2**63 - 1), Direction.To), primaryUnit="fs", units=(
("ps", PhysicalIntegerLiteral(1000, "fs")),
Expand Down Expand Up @@ -155,6 +158,10 @@ def __init__(self) -> None:
self._types[string._normalizedIdentifier] = string
self._declaredItems.append(string)

line = AccessType("line", SimpleSubtypeSymbol(SimpleName("character")), None)
self._types[line._normalizedIdentifier] = line
self._declaredItems.append(line)

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