Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.4.1 #27

Merged
merged 3 commits into from
Aug 15, 2023
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
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__ = "Paebbels@gmail.com"
__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 @@
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

Check warning on line 123 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L123

Added line #L123 was not covered by tests
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

Check warning on line 125 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L125

Added line #L125 was not covered by tests

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

Check warning on line 136 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L136

Added line #L136 was not covered by tests
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

Check warning on line 138 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L138

Added line #L138 was not covered by tests

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

Check warning on line 149 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L149

Added line #L149 was not covered by tests
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

Check warning on line 151 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L151

Added line #L151 was not covered by tests

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

Check warning on line 162 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L162

Added line #L162 was not covered by tests
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

Check warning on line 164 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L164

Added line #L164 was not covered by tests

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

Check warning on line 175 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L175

Added line #L175 was not covered by tests
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

Check warning on line 177 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L177

Added line #L177 was not covered by tests

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

Check warning on line 189 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L189

Added line #L189 was not covered by tests
else:
return self.value == other.value

Check warning on line 191 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L191

Added line #L191 was not covered by tests
else:
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")

Check warning on line 193 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L193

Added line #L193 was not covered by tests

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)

Check warning on line 202 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L202

Added line #L202 was not covered by tests

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)

Check warning on line 211 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L211

Added line #L211 was not covered by tests

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"

Check warning on line 222 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L222

Added line #L222 was not covered by tests

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"

Check warning on line 239 in pySVModel/__init__.py

View check run for this annotation

Codecov / codecov/patch

pySVModel/__init__.py#L239

Added line #L239 was not covered by tests
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
Loading