44444545__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
5252class 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 )
0 commit comments