44444545__copyright__ = "2023-2023, Patrick Lehmann"
4646__license__ = "Apache License, Version 2.0"
47- __version__ = "0.2.1 "
47+ __version__ = "0.2.2 "
4848
4949
5050@export
5151@unique
5252class SystemRDLVersion (Enum ):
53- Any = - 1
54- SystemRDL2005 = 2005
55- SystemRDL2009 = 2009
56- SystemRDL2012 = 2012
57- SystemRDL2017 = 2017
53+ Any = - 1
54+
55+ SystemRDL2005 = 2005
56+ SystemRDL2009 = 2009
57+ SystemRDL2012 = 2012
58+ SystemRDL2017 = 2017
59+
60+ Latest = 10000
5861
5962 __VERSION_MAPPINGS__ : Dict [Union [int , str ], Enum ] = {
60- - 1 : Any ,
61- 5 : SystemRDL2005 ,
62- 9 : SystemRDL2009 ,
63- 12 : SystemRDL2012 ,
64- 17 : SystemRDL2017 ,
65- 2005 : SystemRDL2005 ,
66- 2009 : SystemRDL2009 ,
67- 2012 : SystemRDL2012 ,
68- 2017 : SystemRDL2017 ,
69- "Any" : Any ,
70- "05" : SystemRDL2005 ,
71- "09" : SystemRDL2009 ,
72- "12" : SystemRDL2012 ,
73- "17" : SystemRDL2017 ,
74- "2005" : SystemRDL2005 ,
75- "2009" : SystemRDL2009 ,
76- "2012" : SystemRDL2012 ,
77- "2017" : SystemRDL2017 ,
63+ - 1 : Any ,
64+ 5 : SystemRDL2005 ,
65+ 9 : SystemRDL2009 ,
66+ 12 : SystemRDL2012 ,
67+ 17 : SystemRDL2017 ,
68+ 2005 : SystemRDL2005 ,
69+ 2009 : SystemRDL2009 ,
70+ 2012 : SystemRDL2012 ,
71+ 2017 : SystemRDL2017 ,
72+ 10000 : Latest ,
73+ "Any" : Any ,
74+ "05" : SystemRDL2005 ,
75+ "09" : SystemRDL2009 ,
76+ "12" : SystemRDL2012 ,
77+ "17" : SystemRDL2017 ,
78+ "2005" : SystemRDL2005 ,
79+ "2009" : SystemRDL2009 ,
80+ "2012" : SystemRDL2012 ,
81+ "2017" : SystemRDL2017 ,
82+ "Latest" : SystemRDL2017 ,
7883 }
7984
8085 def __init__ (self , * _ ):
@@ -91,35 +96,110 @@ def Parse(cls, value: Union[int, str]) -> "SystemRDLVersion":
9196 except KeyError :
9297 raise ValueError (f"Value '{ value !s} ' cannot be parsed to member of { cls .__name__ } ." )
9398
94- def __lt__ (self , other ):
95- return self .value < other .value
96-
97- def __le__ (self , other ):
98- return self .value <= other .value
99-
100- def __gt__ (self , other ):
101- return self .value > other .value
99+ def __lt__ (self , other : Any ) -> bool :
100+ """
101+ Compare two (System)Verilog versions if the version is less than the second operand.
102102
103- def __ge__ (self , other ):
104- return self .value >= other .value
105-
106- def __ne__ (self , other ):
107- return self .value != other .value
108-
109- def __eq__ (self , other ):
110- if (self is self .__class__ .Any ) or (other is self .__class__ .Any ):
111- return True
103+ :param other: Parameter to compare against.
104+ :returns: True if version is less than the second operand.
105+ :raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
106+ """
107+ if isinstance (other , SystemRDLVersion ):
108+ return self .value < other .value
109+ else :
110+ raise TypeError ("Second operand is not of type 'SystemRDLVersion'." )
111+
112+ def __le__ (self , other : Any ) -> bool :
113+ """
114+ Compare two (System)Verilog versions if the version is less or equal than the second operand.
115+
116+ :param other: Parameter to compare against.
117+ :returns: True if version is less or equal than the second operand.
118+ :raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
119+ """
120+ if isinstance (other , SystemRDLVersion ):
121+ return self .value <= other .value
122+ else :
123+ raise TypeError ("Second operand is not of type 'SystemRDLVersion'." )
124+
125+ def __gt__ (self , other : Any ) -> bool :
126+ """
127+ Compare two (System)Verilog versions if the version is greater than the second operand.
128+
129+ :param other: Parameter to compare against.
130+ :returns: True if version is greater than the second operand.
131+ :raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
132+ """
133+ if isinstance (other , SystemRDLVersion ):
134+ return self .value > other .value
112135 else :
113- return self .value == other .value
136+ raise TypeError ("Second operand is not of type 'SystemRDLVersion'." )
137+
138+ def __ge__ (self , other : Any ) -> bool :
139+ """
140+ Compare two (System)Verilog versions if the version is greater or equal than the second operand.
141+
142+ :param other: Parameter to compare against.
143+ :returns: True if version is greater or equal than the second operand.
144+ :raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
145+ """
146+ if isinstance (other , SystemRDLVersion ):
147+ return self .value >= other .value
148+ else :
149+ raise TypeError ("Second operand is not of type 'SystemRDLVersion'." )
150+
151+ def __ne__ (self , other : Any ) -> bool :
152+ """
153+ Compare two (System)Verilog versions if the version is unequal to the second operand.
154+
155+ :param other: Parameter to compare against.
156+ :returns: True if version is unequal to the second operand.
157+ :raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
158+ """
159+ if isinstance (other , SystemRDLVersion ):
160+ return self .value != other .value
161+ else :
162+ raise TypeError ("Second operand is not of type 'SystemRDLVersion'." )
163+
164+ def __eq__ (self , other : Any ) -> bool :
165+ """
166+ Compare two (System)Verilog versions if the version is equal to the second operand.
167+
168+ :param other: Parameter to compare against.
169+ :returns: True if version is equal to the second operand.
170+ :raises TypeError: If parameter ``other`` is not of type :class:`SystemRDLVersion`.
171+ """
172+ if isinstance (other , SystemRDLVersion ):
173+ if (self is self .__class__ .Any ) or (other is self .__class__ .Any ):
174+ return True
175+ else :
176+ return self .value == other .value
177+ else :
178+ raise TypeError ("Second operand is not of type 'SystemRDLVersion'." )
114179
115180 def __str__ (self ) -> str :
116- if self .value == - 1 :
181+ """
182+ Formats the SystemRDLVersion version to pattern ``SystemRDL'xx``.
183+
184+ :return: Formatted SystemRDL version.
185+ """
186+ if self .value == self .Any .value :
117187 return "SystemRDL'Any"
118- else :
119- return f"SystemRDL'{ str (self .value )[- 2 :]} "
188+ if self .value == self .Latest .value :
189+ return "SystemRDL'Latest"
190+
191+ year = str (self .value )[- 2 :]
192+ return f"SystemRDL'{ year } "
120193
121194 def __repr__ (self ) -> str :
122- if self .value == - 1 :
195+ """
196+ Formats the SystemRDL version to pattern ``xxxx``.
197+
198+ :return: Formatted SystemRDL version.
199+ """
200+ if self .value == self .Any .value :
123201 return "Any"
202+ elif self .value == self .Latest .value :
203+ return "Latest"
124204 else :
125205 return str (self .value )
0 commit comments