Skip to content

Commit

Permalink
v0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Aug 15, 2023
2 parents 1a1a278 + 113c1ac commit a84b5f9
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 77 deletions.
28 changes: 15 additions & 13 deletions doc/Dependency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,21 @@ the mandatory dependencies too.
.. rubric:: Dependency List

+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| **Package** | **Version** | **License** | **Dependencies** |
+===========================================================+=============+========================================================================================+======================+
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥7.2.0 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `pytest-cov <https://GitHub.com/pytest-dev/pytest-cov>`__ | ≥4.0.0 | `MIT <https://GitHub.com/pytest-dev/pytest-cov/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `Coverage <https://GitHub.com/nedbat/coveragepy>`__ | ≥7.0 | `Apache License, 2.0 <https://GitHub.com/nedbat/coveragepy/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `mypy <https://GitHub.com/python/mypy>`__ | ≥1.2 | `MIT <https://GitHub.com/python/mypy/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `lxml <https://GitHub.com/lxml/lxml>`__ | ≥4.9 | `BSD 3-Clause <https://GitHub.com/lxml/lxml/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| **Package** | **Version** | **License** | **Dependencies** |
+=====================================================================+=============+========================================================================================+======================+
| `pytest <https://GitHub.com/pytest-dev/pytest>`__ | ≥7.4.0 | `MIT <https://GitHub.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `pytest-cov <https://GitHub.com/pytest-dev/pytest-cov>`__ | ≥4.1.0 | `MIT <https://GitHub.com/pytest-dev/pytest-cov/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `Coverage <https://GitHub.com/nedbat/coveragepy>`__ | ≥7.3 | `Apache License, 2.0 <https://GitHub.com/nedbat/coveragepy/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `mypy <https://GitHub.com/python/mypy>`__ | ≥1.5 | `MIT <https://GitHub.com/python/mypy/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `typing-extensions <https://GitHub.com/python/typing_extensions>`__ | ≥4.7.1 | `PSF-2.0 <https://github.com/python/typing_extensions/blob/main/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `lxml <https://GitHub.com/lxml/lxml>`__ | ≥4.9 | `BSD 3-Clause <https://GitHub.com/lxml/lxml/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+


.. _dependency-documentation:
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
extlinks = {
"ghissue": ('https://GitHub.com/edaa-org/pySVModel/issues/%s', 'issue #'),
"ghpull": ('https://GitHub.com/edaa-org/pySVModel/pull/%s', 'pull request #'),
"ghsrc": ('https://GitHub.com/edaa-org/pySVModel/blob/main/%s?ts=2', ""),
"ghsrc": ('https://GitHub.com/edaa-org/pySVModel/blob/main/%s?ts=2', None),
}


Expand Down
216 changes: 157 additions & 59 deletions pySVModel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,54 +44,58 @@
__email__ = "[email protected]"
__copyright__ = "2021-2023, Patrick Lehmann"
__license__ = "Apache License, Version 2.0"
__version__ = "0.4.0"
__version__ = "0.4.1"


@export
@unique
class SystemVerilogVersion(Enum):
Any = -1
Any = -1

Verilog95 = 95
Verilog2001 = 1
Verilog2005 = 5
Verilog95 = 95
Verilog2001 = 1
Verilog2005 = 5

SystemVerilog2005 = 2005
SystemVerilog2009 = 2009
SystemVerilog2012 = 2012
SystemVerilog2017 = 2017
SystemVerilog2005 = 2005
SystemVerilog2009 = 2009
SystemVerilog2012 = 2012
SystemVerilog2017 = 2017

Latest = 10000

__VERSION_MAPPINGS__: Dict[Union[int, str], Enum] = {
-1: Any,
95: Verilog95,
1: Verilog2001,
5: Verilog2005,
# 5: SystemVerilog2005, # prefer Verilog on numbers below 2000
9: SystemVerilog2009,
12: SystemVerilog2012,
17: SystemVerilog2017,
1995: Verilog95,
2001: Verilog2001,
# 2005: Verilog2005, # prefer SystemVerilog on numbers above 2000
2005: SystemVerilog2005,
2009: SystemVerilog2009,
2012: SystemVerilog2012,
2017: SystemVerilog2017,
"Any": Any,
"95": Verilog95,
"01": Verilog2001,
"05": Verilog2005,
# "05": SystemVerilog2005, # prefer Verilog on numbers below 2000
"09": SystemVerilog2009,
"12": SystemVerilog2012,
"17": SystemVerilog2017,
"1995": Verilog95,
"2001": Verilog2001,
# "2005": Verilog2005, # prefer SystemVerilog on numbers above 2000
"2005": SystemVerilog2005,
"2009": SystemVerilog2009,
"2012": SystemVerilog2012,
"2017": SystemVerilog2017,
-1: Any,
95: Verilog95,
1: Verilog2001,
5: Verilog2005,
# 5: SystemVerilog2005, # prefer Verilog on numbers below 2000
9: SystemVerilog2009,
12: SystemVerilog2012,
17: SystemVerilog2017,
1995: Verilog95,
2001: Verilog2001,
# 2005: Verilog2005, # prefer SystemVerilog on numbers above 2000
2005: SystemVerilog2005,
2009: SystemVerilog2009,
2012: SystemVerilog2012,
2017: SystemVerilog2017,
10000: Latest,
"Any": Any,
"95": Verilog95,
"01": Verilog2001,
"05": Verilog2005,
# "05": SystemVerilog2005, # prefer Verilog on numbers below 2000
"09": SystemVerilog2009,
"12": SystemVerilog2012,
"17": SystemVerilog2017,
"1995": Verilog95,
"2001": Verilog2001,
# "2005": Verilog2005, # prefer SystemVerilog on numbers above 2000
"2005": SystemVerilog2005,
"2009": SystemVerilog2009,
"2012": SystemVerilog2012,
"2017": SystemVerilog2017,
"Latest": Latest
}

def __init__(self, *_):
Expand All @@ -107,37 +111,131 @@ def Parse(cls, value: Union[int, str]) -> "SystemVerilogVersion":
except KeyError:
raise ValueError("Value '{0!s}' cannot be parsed to member of {1}.".format(value, cls.__name__))

def __lt__(self, other) -> bool:
return self.value < other.value
def __lt__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is less than the second operand.
def __le__(self, other) -> bool:
return self.value <= other.value
:param other: Parameter to compare against.
:returns: True if version is less than the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
"""
if isinstance(other, SystemVerilogVersion):
return self.value < other.value
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

def __le__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is less or equal than the second operand.
:param other: Parameter to compare against.
:returns: True if version is less or equal than the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
"""
if isinstance(other, SystemVerilogVersion):
return self.value <= other.value
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

def __gt__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is greater than the second operand.
:param other: Parameter to compare against.
:returns: True if version is greater than the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
"""
if isinstance(other, SystemVerilogVersion):
return self.value > other.value
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

def __ge__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is greater or equal than the second operand.
:param other: Parameter to compare against.
:returns: True if version is greater or equal than the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
"""
if isinstance(other, SystemVerilogVersion):
return self.value >= other.value
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

def __ne__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is unequal to the second operand.
:param other: Parameter to compare against.
:returns: True if version is unequal to the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
"""
if isinstance(other, SystemVerilogVersion):
return self.value != other.value
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

def __eq__(self, other: Any) -> bool:
"""
Compare two (System)Verilog versions if the version is equal to the second operand.
:param other: Parameter to compare against.
:returns: True if version is equal to the second operand.
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
"""
if isinstance(other, SystemVerilogVersion):
if (self is self.__class__.Any) or (other is self.__class__.Any):
return True
else:
return self.value == other.value
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

def __gt__(self, other) -> bool:
return self.value > other.value
@property
def IsVerilog(self) -> bool:
"""
Checks if the version is a (classic) Verilog version.
def __ge__(self, other) -> bool:
return self.value >= other.value
:returns: True if version is a (classic) Verilog version.
"""
return self in (self.Verilog95, self.Verilog2001, self.Verilog2005)

def __ne__(self, other) -> bool:
return self.value != other.value
@property
def IsSystemVerilog(self) -> bool:
"""
Checks if the version is a SystemVerilog version.
def __eq__(self, other) -> bool:
if (self is self.__class__.Any) or (other is self.__class__.Any):
return True
else:
return self.value == other.value
:returns: True if version is a SystemVerilog version.
"""
return self in (self.SystemVerilog2005, self.SystemVerilog2009, self.SystemVerilog2012, self.SystemVerilog2017)

def __str__(self) -> str:
if self.value == -1:
"""
Formats the SystemVerilog version to pattern ``SV'xx`` or in case of classic Verilog to ``Verilog'xx``.
:return: Formatted (System)Verilog version.
"""
if self.value == self.Any.value:
return "SV'Any"
elif self.value < self.SystemVerilog2005.value:
return "Verilog'" + str(self.value)[-2:]
if self.value == self.Latest.value:
return "SV'Latest"

year = str(self.value)[-2:]
if self.value < self.SystemVerilog2005.value:
return f"Verilog'{year}"
else:
return "SV'" + str(self.value)[-2:]
return f"SV'{year}"

def __repr__(self) -> str:
if self.value == -1:
"""
Formats the (System)Verilog version to pattern ``xxxx``.
:return: Formatted (System)Verilog version.
"""
if self.value == self.Any.value:
return "Any"
elif self.value == self.Latest.value:
return "Latest"
else:
return str(self.value)
9 changes: 5 additions & 4 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
-r ../requirements.txt

# Coverage collection
Coverage>=7.0
Coverage >= 7.3

# Test Runner
pytest>=7.2.0
pytest-cov>=4.0.0
pytest >= 7.4.0
pytest-cov >= 4.1.0

# Static Type Checking
mypy >= 1.2
mypy >= 1.5
typing_extensions >= 4.7.1
lxml>=4.9

0 comments on commit a84b5f9

Please sign in to comment.