Skip to content

Commit a84b5f9

Browse files
authored
v0.4.1
2 parents 1a1a278 + 113c1ac commit a84b5f9

File tree

4 files changed

+178
-77
lines changed

4 files changed

+178
-77
lines changed

doc/Dependency.rst

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ the mandatory dependencies too.
5454
5555
.. rubric:: Dependency List
5656

57-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
58-
| **Package** | **Version** | **License** | **Dependencies** |
59-
+===========================================================+=============+========================================================================================+======================+
60-
| `pytest <https://github.com/pytest-dev/pytest>`__ | ≥7.2.0 | `MIT <https://github.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
61-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
62-
| `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.* |
63-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
64-
| `Coverage <https://github.com/nedbat/coveragepy>`__ | ≥7.0 | `Apache License, 2.0 <https://github.com/nedbat/coveragepy/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
65-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
66-
| `mypy <https://github.com/python/mypy>`__ | ≥1.2 | `MIT <https://github.com/python/mypy/blob/master/LICENSE>`__ | *Not yet evaluated.* |
67-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
68-
| `lxml <https://github.com/lxml/lxml>`__ | ≥4.9 | `BSD 3-Clause <https://github.com/lxml/lxml/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
69-
+-----------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
57+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
58+
| **Package** | **Version** | **License** | **Dependencies** |
59+
+=====================================================================+=============+========================================================================================+======================+
60+
| `pytest <https://github.com/pytest-dev/pytest>`__ | ≥7.4.0 | `MIT <https://github.com/pytest-dev/pytest/blob/master/LICENSE>`__ | *Not yet evaluated.* |
61+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
62+
| `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.* |
63+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
64+
| `Coverage <https://github.com/nedbat/coveragepy>`__ | ≥7.3 | `Apache License, 2.0 <https://github.com/nedbat/coveragepy/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
65+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
66+
| `mypy <https://github.com/python/mypy>`__ | ≥1.5 | `MIT <https://github.com/python/mypy/blob/master/LICENSE>`__ | *Not yet evaluated.* |
67+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
68+
| `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.* |
69+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
70+
| `lxml <https://github.com/lxml/lxml>`__ | ≥4.9 | `BSD 3-Clause <https://github.com/lxml/lxml/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
71+
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
7072

7173

7274
.. _dependency-documentation:

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
extlinks = {
207207
"ghissue": ('https://github.com/edaa-org/pySVModel/issues/%s', 'issue #'),
208208
"ghpull": ('https://github.com/edaa-org/pySVModel/pull/%s', 'pull request #'),
209-
"ghsrc": ('https://github.com/edaa-org/pySVModel/blob/main/%s?ts=2', ""),
209+
"ghsrc": ('https://github.com/edaa-org/pySVModel/blob/main/%s?ts=2', None),
210210
}
211211

212212

pySVModel/__init__.py

Lines changed: 157 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -44,54 +44,58 @@
4444
__email__ = "Paebbels@gmail.com"
4545
__copyright__ = "2021-2023, Patrick Lehmann"
4646
__license__ = "Apache License, Version 2.0"
47-
__version__ = "0.4.0"
47+
__version__ = "0.4.1"
4848

4949

5050
@export
5151
@unique
5252
class SystemVerilogVersion(Enum):
53-
Any = -1
53+
Any = -1
5454

55-
Verilog95 = 95
56-
Verilog2001 = 1
57-
Verilog2005 = 5
55+
Verilog95 = 95
56+
Verilog2001 = 1
57+
Verilog2005 = 5
5858

59-
SystemVerilog2005 = 2005
60-
SystemVerilog2009 = 2009
61-
SystemVerilog2012 = 2012
62-
SystemVerilog2017 = 2017
59+
SystemVerilog2005 = 2005
60+
SystemVerilog2009 = 2009
61+
SystemVerilog2012 = 2012
62+
SystemVerilog2017 = 2017
63+
64+
Latest = 10000
6365

6466
__VERSION_MAPPINGS__: Dict[Union[int, str], Enum] = {
65-
-1: Any,
66-
95: Verilog95,
67-
1: Verilog2001,
68-
5: Verilog2005,
69-
# 5: SystemVerilog2005, # prefer Verilog on numbers below 2000
70-
9: SystemVerilog2009,
71-
12: SystemVerilog2012,
72-
17: SystemVerilog2017,
73-
1995: Verilog95,
74-
2001: Verilog2001,
75-
# 2005: Verilog2005, # prefer SystemVerilog on numbers above 2000
76-
2005: SystemVerilog2005,
77-
2009: SystemVerilog2009,
78-
2012: SystemVerilog2012,
79-
2017: SystemVerilog2017,
80-
"Any": Any,
81-
"95": Verilog95,
82-
"01": Verilog2001,
83-
"05": Verilog2005,
84-
# "05": SystemVerilog2005, # prefer Verilog on numbers below 2000
85-
"09": SystemVerilog2009,
86-
"12": SystemVerilog2012,
87-
"17": SystemVerilog2017,
88-
"1995": Verilog95,
89-
"2001": Verilog2001,
90-
# "2005": Verilog2005, # prefer SystemVerilog on numbers above 2000
91-
"2005": SystemVerilog2005,
92-
"2009": SystemVerilog2009,
93-
"2012": SystemVerilog2012,
94-
"2017": SystemVerilog2017,
67+
-1: Any,
68+
95: Verilog95,
69+
1: Verilog2001,
70+
5: Verilog2005,
71+
# 5: SystemVerilog2005, # prefer Verilog on numbers below 2000
72+
9: SystemVerilog2009,
73+
12: SystemVerilog2012,
74+
17: SystemVerilog2017,
75+
1995: Verilog95,
76+
2001: Verilog2001,
77+
# 2005: Verilog2005, # prefer SystemVerilog on numbers above 2000
78+
2005: SystemVerilog2005,
79+
2009: SystemVerilog2009,
80+
2012: SystemVerilog2012,
81+
2017: SystemVerilog2017,
82+
10000: Latest,
83+
"Any": Any,
84+
"95": Verilog95,
85+
"01": Verilog2001,
86+
"05": Verilog2005,
87+
# "05": SystemVerilog2005, # prefer Verilog on numbers below 2000
88+
"09": SystemVerilog2009,
89+
"12": SystemVerilog2012,
90+
"17": SystemVerilog2017,
91+
"1995": Verilog95,
92+
"2001": Verilog2001,
93+
# "2005": Verilog2005, # prefer SystemVerilog on numbers above 2000
94+
"2005": SystemVerilog2005,
95+
"2009": SystemVerilog2009,
96+
"2012": SystemVerilog2012,
97+
"2017": SystemVerilog2017,
98+
"Latest": Latest
9599
}
96100

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

110-
def __lt__(self, other) -> bool:
111-
return self.value < other.value
114+
def __lt__(self, other: Any) -> bool:
115+
"""
116+
Compare two (System)Verilog versions if the version is less than the second operand.
112117
113-
def __le__(self, other) -> bool:
114-
return self.value <= other.value
118+
:param other: Parameter to compare against.
119+
:returns: True if version is less than the second operand.
120+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
121+
"""
122+
if isinstance(other, SystemVerilogVersion):
123+
return self.value < other.value
124+
else:
125+
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")
126+
127+
def __le__(self, other: Any) -> bool:
128+
"""
129+
Compare two (System)Verilog versions if the version is less or equal than the second operand.
130+
131+
:param other: Parameter to compare against.
132+
:returns: True if version is less or equal than the second operand.
133+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
134+
"""
135+
if isinstance(other, SystemVerilogVersion):
136+
return self.value <= other.value
137+
else:
138+
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")
139+
140+
def __gt__(self, other: Any) -> bool:
141+
"""
142+
Compare two (System)Verilog versions if the version is greater than the second operand.
143+
144+
:param other: Parameter to compare against.
145+
:returns: True if version is greater than the second operand.
146+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
147+
"""
148+
if isinstance(other, SystemVerilogVersion):
149+
return self.value > other.value
150+
else:
151+
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")
152+
153+
def __ge__(self, other: Any) -> bool:
154+
"""
155+
Compare two (System)Verilog versions if the version is greater or equal than the second operand.
156+
157+
:param other: Parameter to compare against.
158+
:returns: True if version is greater or equal than the second operand.
159+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
160+
"""
161+
if isinstance(other, SystemVerilogVersion):
162+
return self.value >= other.value
163+
else:
164+
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")
165+
166+
def __ne__(self, other: Any) -> bool:
167+
"""
168+
Compare two (System)Verilog versions if the version is unequal to the second operand.
169+
170+
:param other: Parameter to compare against.
171+
:returns: True if version is unequal to the second operand.
172+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
173+
"""
174+
if isinstance(other, SystemVerilogVersion):
175+
return self.value != other.value
176+
else:
177+
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")
178+
179+
def __eq__(self, other: Any) -> bool:
180+
"""
181+
Compare two (System)Verilog versions if the version is equal to the second operand.
182+
183+
:param other: Parameter to compare against.
184+
:returns: True if version is equal to the second operand.
185+
:raises TypeError: If parameter ``other`` is not of type :class:`SystemVerilogVersion`.
186+
"""
187+
if isinstance(other, SystemVerilogVersion):
188+
if (self is self.__class__.Any) or (other is self.__class__.Any):
189+
return True
190+
else:
191+
return self.value == other.value
192+
else:
193+
raise TypeError("Second operand is not of type 'SystemVerilogVersion'.")
115194

116-
def __gt__(self, other) -> bool:
117-
return self.value > other.value
195+
@property
196+
def IsVerilog(self) -> bool:
197+
"""
198+
Checks if the version is a (classic) Verilog version.
118199
119-
def __ge__(self, other) -> bool:
120-
return self.value >= other.value
200+
:returns: True if version is a (classic) Verilog version.
201+
"""
202+
return self in (self.Verilog95, self.Verilog2001, self.Verilog2005)
121203

122-
def __ne__(self, other) -> bool:
123-
return self.value != other.value
204+
@property
205+
def IsSystemVerilog(self) -> bool:
206+
"""
207+
Checks if the version is a SystemVerilog version.
124208
125-
def __eq__(self, other) -> bool:
126-
if (self is self.__class__.Any) or (other is self.__class__.Any):
127-
return True
128-
else:
129-
return self.value == other.value
209+
:returns: True if version is a SystemVerilog version.
210+
"""
211+
return self in (self.SystemVerilog2005, self.SystemVerilog2009, self.SystemVerilog2012, self.SystemVerilog2017)
130212

131213
def __str__(self) -> str:
132-
if self.value == -1:
214+
"""
215+
Formats the SystemVerilog version to pattern ``SV'xx`` or in case of classic Verilog to ``Verilog'xx``.
216+
217+
:return: Formatted (System)Verilog version.
218+
"""
219+
if self.value == self.Any.value:
133220
return "SV'Any"
134-
elif self.value < self.SystemVerilog2005.value:
135-
return "Verilog'" + str(self.value)[-2:]
221+
if self.value == self.Latest.value:
222+
return "SV'Latest"
223+
224+
year = str(self.value)[-2:]
225+
if self.value < self.SystemVerilog2005.value:
226+
return f"Verilog'{year}"
136227
else:
137-
return "SV'" + str(self.value)[-2:]
228+
return f"SV'{year}"
138229

139230
def __repr__(self) -> str:
140-
if self.value == -1:
231+
"""
232+
Formats the (System)Verilog version to pattern ``xxxx``.
233+
234+
:return: Formatted (System)Verilog version.
235+
"""
236+
if self.value == self.Any.value:
141237
return "Any"
238+
elif self.value == self.Latest.value:
239+
return "Latest"
142240
else:
143241
return str(self.value)

tests/requirements.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
-r ../requirements.txt
22

33
# Coverage collection
4-
Coverage>=7.0
4+
Coverage >= 7.3
55

66
# Test Runner
7-
pytest>=7.2.0
8-
pytest-cov>=4.0.0
7+
pytest >= 7.4.0
8+
pytest-cov >= 4.1.0
99

1010
# Static Type Checking
11-
mypy >= 1.2
11+
mypy >= 1.5
12+
typing_extensions >= 4.7.1
1213
lxml>=4.9

0 commit comments

Comments
 (0)