Coverage for pyVHDLModel/IEEE.py: 100%
152 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 22:15 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 22:15 +0000
1# ==================================================================================================================== #
2# __ ___ _ ____ _ __ __ _ _ #
3# _ __ _ \ \ / / | | | _ \| | | \/ | ___ __| | ___| | #
4# | '_ \| | | \ \ / /| |_| | | | | | | |\/| |/ _ \ / _` |/ _ \ | #
5# | |_) | |_| |\ V / | _ | |_| | |___| | | | (_) | (_| | __/ | #
6# | .__/ \__, | \_/ |_| |_|____/|_____|_| |_|\___/ \__,_|\___|_| #
7# |_| |___/ #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2017-2024 Patrick Lehmann - Boetzingen, Germany #
15# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany #
16# #
17# Licensed under the Apache License, Version 2.0 (the "License"); #
18# you may not use this file except in compliance with the License. #
19# You may obtain a copy of the License at #
20# #
21# http://www.apache.org/licenses/LICENSE-2.0 #
22# #
23# Unless required by applicable law or agreed to in writing, software #
24# distributed under the License is distributed on an "AS IS" BASIS, #
25# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
26# See the License for the specific language governing permissions and #
27# limitations under the License. #
28# #
29# SPDX-License-Identifier: Apache-2.0 #
30# ==================================================================================================================== #
31#
32"""This module contains library and package declarations for VHDL library ``IEEE``."""
33from pyTooling.Decorators import export
35from pyVHDLModel.Expression import EnumerationLiteral
36from pyVHDLModel.Name import SimpleName
37from pyVHDLModel.Predefined import PredefinedLibrary, PredefinedPackage, PredefinedPackageBody
38from pyVHDLModel.Symbol import SimpleSubtypeSymbol
39from pyVHDLModel.Type import EnumeratedType, ArrayType, Subtype
42@export
43class Ieee(PredefinedLibrary):
44 """
45 Predefined VHDL library ``ieee``.
47 The following predefined packages are in this library:
49 * Math
51 * :class:`~pyVHDLModel.IEEE.Math_Real`
52 * :class:`~pyVHDLModel.IEEE.Math_Complex`
54 * Std_logic
56 * :class:`~pyVHDLModel.IEEE.Std_Logic_1164`
57 * :class:`~pyVHDLModel.IEEE.Std_Logic_TextIO`
58 * :class:`~pyVHDLModel.IEEE.Std_Logic_Misc`
60 * Numeric
62 * :class:`~pyVHDLModel.IEEE.Numeric_Bit`
63 * :class:`~pyVHDLModel.IEEE.Numeric_Bit_Unsigned`
64 * :class:`~pyVHDLModel.IEEE.Numeric_Std`
65 * :class:`~pyVHDLModel.IEEE.Numeric_Std_Unsigned`
67 * Fixed/floating point
69 * :class:`~pyVHDLModel.IEEE.Fixed_Float_Types`
70 * :class:`~pyVHDLModel.IEEE.Fixed_Generic_Pkg`
71 * :class:`~pyVHDLModel.IEEE.Fixed_Pkg`
72 * :class:`~pyVHDLModel.IEEE.Float_Generic_Pkg`
73 * :class:`~pyVHDLModel.IEEE.Float_Pkg`
75 .. seealso::
77 Other predefined libraries:
78 * Library :class:`~pyVHDLModel.STD.Std`
79 """
81 def __init__(self) -> None:
82 super().__init__(PACKAGES)
84 def LoadSynopsysPackages(self) -> None:
85 self.AddPackages(PACKAGES_SYNOPSYS)
89@export
90class Math_Real(PredefinedPackage):
91 """
92 Predefined package ``ieee.math_real``.
93 """
96@export
97class Math_Real_Body(PredefinedPackageBody):
98 """
99 Predefined package body of package ``ieee.math_real``.
100 """
103@export
104class Math_Complex(PredefinedPackage):
105 """
106 Predefined package ``ieee.math_complex``.
107 """
109 def __init__(self) -> None:
110 super().__init__()
112 self._AddPackageClause(("work.math_real.all",))
115@export
116class Math_Complex_Body(PredefinedPackageBody):
117 """
118 Predefined package body of package ``ieee.math_complex``.
119 """
121 def __init__(self) -> None:
122 super().__init__()
124 self._AddPackageClause(("work.math_real.all",))
127@export
128class Std_logic_1164(PredefinedPackage):
129 """
130 Predefined package ``ieee.std_logic_1164``.
132 Predefined types:
134 * ``std_ulogic``, ``std_ulogic_vector``
135 * ``std_logic``, ``std_logic_vector``
136 """
138 def __init__(self) -> None:
139 super().__init__()
141 self._AddPackageClause(("STD.TEXTIO.all", ))
143 stdULogic = EnumeratedType("std_ulogic", (
144 EnumerationLiteral("U"),
145 EnumerationLiteral("X"),
146 EnumerationLiteral("0"),
147 EnumerationLiteral("1"),
148 EnumerationLiteral("Z"),
149 EnumerationLiteral("W"),
150 EnumerationLiteral("L"),
151 EnumerationLiteral("H"),
152 EnumerationLiteral("-"),
153 ), None)
154 self._types[stdULogic._normalizedIdentifier] = stdULogic
155 self._declaredItems.append(stdULogic)
157 stdULogicVector = ArrayType("std_ulogic_vector", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")), None)
158 self._types[stdULogicVector._normalizedIdentifier] = stdULogicVector
159 self._declaredItems.append(stdULogicVector)
161 stdLogic = Subtype("std_logic", SimpleSubtypeSymbol(SimpleName("std_ulogic")), None)
162 stdLogic._baseType = stdULogic
163 self._subtypes[stdLogic._normalizedIdentifier] = stdLogic
164 self._declaredItems.append(stdLogic)
166 stdLogicVector = Subtype("std_logic_vector", SimpleSubtypeSymbol(SimpleName("std_ulogic_vector")), None)
167 stdLogicVector._baseType = stdULogicVector
168 self._subtypes[stdLogicVector._normalizedIdentifier] = stdLogicVector
169 self._declaredItems.append(stdLogicVector)
172@export
173class Std_logic_1164_Body(PredefinedPackageBody):
174 """
175 Predefined package body of package ``ieee.std_logic_1164``.
176 """
179@export
180class std_logic_textio(PredefinedPackage):
181 """
182 Predefined package ``ieee.std_logic_textio``.
183 """
185 def __init__(self) -> None:
186 super().__init__()
188 self._AddPackageClause(("STD.TEXTIO.all", ))
189 self._AddLibraryClause(("IEEE", ))
190 self._AddPackageClause(("IEEE.std_logic_1164.all", ))
193@export
194class Std_logic_misc(PredefinedPackage):
195 """
196 Predefined package ``ieee.std_logic_misc``.
197 """
199 def __init__(self) -> None:
200 super().__init__()
202 self._AddLibraryClause(("IEEE", ))
203 self._AddPackageClause(("IEEE.std_logic_1164.all", ))
206@export
207class Std_logic_misc_Body(PredefinedPackageBody):
208 """
209 Predefined package body of package ``ieee.std_logic_misc``.
210 """
213@export
214class Numeric_Bit(PredefinedPackage):
215 """
216 Predefined package ``ieee.numeric_bit``.
217 """
219 def __init__(self) -> None:
220 super().__init__()
222 self._AddPackageClause(("STD.TEXTIO.all", ))
225@export
226class Numeric_Bit_Body(PredefinedPackageBody):
227 """
228 Predefined package body of package ``ieee.numeric_bit``.
229 """
232@export
233class Numeric_Bit_Unsigned(PredefinedPackage):
234 """
235 Predefined package ``ieee.numeric_bit_unsigned``.
236 """
239@export
240class Numeric_Bit_Unsigned_Body(PredefinedPackageBody):
241 """
242 Predefined package body of package ``ieee.numeric_bit_unsigned``.
243 """
245 def __init__(self) -> None:
246 super().__init__()
248 self._AddLibraryClause(("IEEE", ))
249 self._AddPackageClause(("IEEE.numeric_bit.all", ))
252@export
253class Numeric_Std(PredefinedPackage):
254 """
255 Predefined package ``ieee.numeric_std``.
257 Predefined types:
259 * ``unresolved_unsigned``, ``unsigned``
260 * ``unresolved_signed``, ``signed``
261 """
263 def __init__(self) -> None:
264 super().__init__()
266 self._AddPackageClause(("STD.TEXTIO.all", ))
267 self._AddLibraryClause(("IEEE", ))
268 self._AddPackageClause(("IEEE.std_logic_1164.all", ))
270 unresolvedUnsigned = ArrayType("unresolved_unsigned", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")), None)
271 self._types[unresolvedUnsigned._normalizedIdentifier] = unresolvedUnsigned
272 self._declaredItems.append(unresolvedUnsigned)
274 unsigned = Subtype("unsigned", SimpleSubtypeSymbol(SimpleName("unresolved_unsigned")), None)
275 unsigned._baseType = unresolvedUnsigned
276 self._subtypes[unsigned._normalizedIdentifier] = unsigned
277 self._declaredItems.append(unsigned)
279 unresolvedSigned = ArrayType("unresolved_signed", (SimpleSubtypeSymbol(SimpleName("natural")),), SimpleSubtypeSymbol(SimpleName("std_ulogic")), None)
280 self._types[unresolvedSigned._normalizedIdentifier] = unresolvedSigned
281 self._declaredItems.append(unresolvedSigned)
283 signed = Subtype("signed", SimpleSubtypeSymbol(SimpleName("unresolved_signed")), None)
284 signed._baseType = unresolvedSigned
285 self._subtypes[signed._normalizedIdentifier] = signed
286 self._declaredItems.append(signed)
289@export
290class Numeric_Std_Body(PredefinedPackageBody):
291 """
292 Predefined package body of package ``ieee.numeric_std``.
293 """
296@export
297class Numeric_Std_Unsigned(PredefinedPackage):
298 """
299 Predefined package ``ieee.numeric_std_unsigned``.
300 """
302 def __init__(self) -> None:
303 super().__init__()
305 self._AddLibraryClause(("IEEE", ))
306 self._AddPackageClause(("IEEE.std_logic_1164.all", ))
309@export
310class Numeric_Std_Unsigned_Body(PredefinedPackageBody):
311 """
312 Predefined package body of package ``ieee.numeric_std_unsigned``.
313 """
315 def __init__(self) -> None:
316 super().__init__()
318 self._AddLibraryClause(("IEEE", ))
319 self._AddPackageClause(("IEEE.numeric_std.all", ))
322@export
323class Fixed_Float_Types(PredefinedPackage):
324 """
325 Predefined package ``ieee.fixed_float_types``.
326 """
329@export
330class Fixed_Generic_Pkg(PredefinedPackage):
331 """
332 Predefined package ``ieee.fixed_generic_pkg``.
333 """
335 def __init__(self) -> None:
336 super().__init__()
338 self._AddPackageClause(("STD.TEXTIO.all", ))
339 self._AddLibraryClause(("IEEE", ))
340 self._AddPackageClause(("IEEE.STD_LOGIC_1164.all", ))
341 self._AddPackageClause(("IEEE.NUMERIC_STD.all", ))
342 self._AddPackageClause(("IEEE.fixed_float_types.all", ))
345@export
346class Fixed_Generic_Pkg_Body(PredefinedPackageBody):
347 """
348 Predefined package body of package ``ieee.fixed_generic_pkg``.
349 """
351 def __init__(self) -> None:
352 super().__init__()
354 self._AddLibraryClause(("IEEE", ))
355 self._AddPackageClause(("IEEE.MATH_REAL.all", ))
358@export
359class Fixed_Pkg(PredefinedPackage):
360 """
361 Predefined package ``ieee.fixed_pkg``.
362 """
363 def __init__(self) -> None:
364 super().__init__()
366 self._AddLibraryClause(("IEEE", ))
369@export
370class Float_Generic_Pkg(PredefinedPackage):
371 """
372 Predefined package ``ieee.float_generic_pkg``.
373 """
375 def __init__(self) -> None:
376 super().__init__()
378 self._AddPackageClause(("STD.TEXTIO.all", ))
379 self._AddLibraryClause(("IEEE", ))
380 self._AddPackageClause(("IEEE.STD_LOGIC_1164.all", ))
381 self._AddPackageClause(("IEEE.NUMERIC_STD.all", ))
382 self._AddPackageClause(("IEEE.fixed_float_types.all", ))
385@export
386class Float_Generic_Pkg_Body(PredefinedPackageBody):
387 """
388 Predefined package body of package ``ieee.float_generic_pkg``.
389 """
392@export
393class Float_Pkg(PredefinedPackage):
394 """
395 Predefined package ``ieee.float_pkg``.
396 """
398 def __init__(self) -> None:
399 super().__init__()
401 self._AddLibraryClause(("IEEE", ))
404PACKAGES = (
405 (Math_Real, Math_Real_Body),
406 (Math_Complex, Math_Complex_Body),
407 (Std_logic_1164, Std_logic_1164_Body),
408 (std_logic_textio, None),
409 (Numeric_Bit, Numeric_Bit_Body),
410 (Numeric_Bit_Unsigned, Numeric_Bit_Unsigned_Body),
411 (Numeric_Std, Numeric_Std_Body),
412 (Numeric_Std_Unsigned, Numeric_Std_Unsigned_Body),
413 (Fixed_Float_Types, None),
414 (Fixed_Generic_Pkg, Fixed_Generic_Pkg_Body),
415 (Fixed_Pkg, None),
416 (Float_Generic_Pkg, Float_Generic_Pkg_Body),
417 (Float_Pkg, None),
418)
420PACKAGES_SYNOPSYS = (
421 (Std_logic_misc, Std_logic_misc_Body),
422)