cocotb 1.9.2__cp313-cp313-win_amd64.whl → 2.0.0rc2__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cocotb might be problematic. Click here for more details.

Files changed (161) hide show
  1. cocotb/_ANSI.py +65 -0
  2. cocotb/__init__.py +81 -327
  3. cocotb/_base_triggers.py +515 -0
  4. cocotb/_bridge.py +186 -0
  5. cocotb/_decorators.py +515 -0
  6. cocotb/_deprecation.py +3 -3
  7. cocotb/_exceptions.py +7 -0
  8. cocotb/_extended_awaitables.py +419 -0
  9. cocotb/_gpi_triggers.py +385 -0
  10. cocotb/_init.py +301 -0
  11. cocotb/_outcomes.py +54 -0
  12. cocotb/_profiling.py +46 -0
  13. cocotb/_py_compat.py +114 -29
  14. cocotb/_scheduler.py +448 -0
  15. cocotb/_test.py +248 -0
  16. cocotb/_test_factory.py +312 -0
  17. cocotb/_test_functions.py +42 -0
  18. cocotb/_typing.py +7 -0
  19. cocotb/_utils.py +274 -0
  20. cocotb/_version.py +3 -7
  21. cocotb/_xunit_reporter.py +66 -0
  22. cocotb/clock.py +353 -108
  23. cocotb/debug.py +24 -0
  24. cocotb/handle.py +1370 -793
  25. cocotb/libs/cocotb.dll +0 -0
  26. cocotb/libs/cocotb.exp +0 -0
  27. cocotb/libs/cocotb.lib +0 -0
  28. cocotb/libs/cocotbfli_modelsim.dll +0 -0
  29. cocotb/libs/cocotbfli_modelsim.exp +0 -0
  30. cocotb/libs/cocotbfli_modelsim.lib +0 -0
  31. cocotb/libs/cocotbutils.dll +0 -0
  32. cocotb/libs/cocotbutils.exp +0 -0
  33. cocotb/libs/cocotbutils.lib +0 -0
  34. cocotb/libs/cocotbvhpi_aldec.dll +0 -0
  35. cocotb/libs/cocotbvhpi_aldec.exp +0 -0
  36. cocotb/libs/cocotbvhpi_aldec.lib +0 -0
  37. cocotb/libs/cocotbvhpi_modelsim.dll +0 -0
  38. cocotb/libs/cocotbvhpi_modelsim.exp +0 -0
  39. cocotb/libs/cocotbvhpi_modelsim.lib +0 -0
  40. cocotb/libs/cocotbvpi_aldec.dll +0 -0
  41. cocotb/libs/cocotbvpi_aldec.exp +0 -0
  42. cocotb/libs/cocotbvpi_aldec.lib +0 -0
  43. cocotb/libs/cocotbvpi_ghdl.dll +0 -0
  44. cocotb/libs/cocotbvpi_ghdl.exp +0 -0
  45. cocotb/libs/cocotbvpi_ghdl.lib +0 -0
  46. cocotb/libs/cocotbvpi_icarus.exp +0 -0
  47. cocotb/libs/cocotbvpi_icarus.lib +0 -0
  48. cocotb/libs/cocotbvpi_icarus.vpl +0 -0
  49. cocotb/libs/cocotbvpi_modelsim.dll +0 -0
  50. cocotb/libs/cocotbvpi_modelsim.exp +0 -0
  51. cocotb/libs/cocotbvpi_modelsim.lib +0 -0
  52. cocotb/libs/embed.dll +0 -0
  53. cocotb/libs/embed.exp +0 -0
  54. cocotb/libs/embed.lib +0 -0
  55. cocotb/libs/gpi.dll +0 -0
  56. cocotb/libs/gpi.exp +0 -0
  57. cocotb/libs/gpi.lib +0 -0
  58. cocotb/libs/gpilog.dll +0 -0
  59. cocotb/libs/gpilog.exp +0 -0
  60. cocotb/libs/gpilog.lib +0 -0
  61. cocotb/libs/pygpilog.dll +0 -0
  62. cocotb/libs/pygpilog.exp +0 -0
  63. cocotb/libs/pygpilog.lib +0 -0
  64. cocotb/logging.py +424 -0
  65. cocotb/queue.py +103 -57
  66. cocotb/regression.py +680 -717
  67. cocotb/result.py +17 -188
  68. cocotb/share/def/aldec.exp +0 -0
  69. cocotb/share/def/aldec.lib +0 -0
  70. cocotb/share/def/ghdl.exp +0 -0
  71. cocotb/share/def/ghdl.lib +0 -0
  72. cocotb/share/def/icarus.exp +0 -0
  73. cocotb/share/def/icarus.lib +0 -0
  74. cocotb/share/def/modelsim.def +1 -0
  75. cocotb/share/def/modelsim.exp +0 -0
  76. cocotb/share/def/modelsim.lib +0 -0
  77. cocotb/share/include/cocotb_utils.h +9 -32
  78. cocotb/share/include/embed.h +7 -30
  79. cocotb/share/include/gpi.h +331 -137
  80. cocotb/share/include/gpi_logging.h +221 -142
  81. cocotb/share/include/py_gpi_logging.h +8 -5
  82. cocotb/share/include/vpi_user_ext.h +4 -26
  83. cocotb/share/lib/verilator/verilator.cpp +80 -67
  84. cocotb/simtime.py +230 -0
  85. cocotb/simulator.cp313-win_amd64.exp +0 -0
  86. cocotb/simulator.cp313-win_amd64.lib +0 -0
  87. cocotb/simulator.cp313-win_amd64.pyd +0 -0
  88. cocotb/simulator.pyi +107 -0
  89. cocotb/task.py +478 -213
  90. cocotb/triggers.py +55 -1092
  91. cocotb/types/__init__.py +28 -47
  92. cocotb/types/_abstract_array.py +151 -0
  93. cocotb/types/_array.py +295 -0
  94. cocotb/types/_indexing.py +17 -0
  95. cocotb/types/_logic.py +333 -0
  96. cocotb/types/_logic_array.py +868 -0
  97. cocotb/types/{range.py → _range.py} +47 -48
  98. cocotb/types/_resolve.py +76 -0
  99. cocotb/utils.py +58 -646
  100. cocotb-2.0.0rc2.dist-info/METADATA +60 -0
  101. cocotb-2.0.0rc2.dist-info/RECORD +146 -0
  102. {cocotb-1.9.2.dist-info → cocotb-2.0.0rc2.dist-info}/WHEEL +1 -1
  103. cocotb-2.0.0rc2.dist-info/entry_points.txt +2 -0
  104. {cocotb-1.9.2.dist-info → cocotb-2.0.0rc2.dist-info/licenses}/LICENSE +1 -0
  105. {cocotb-1.9.2.dist-info → cocotb-2.0.0rc2.dist-info}/top_level.txt +1 -0
  106. cocotb_tools/__init__.py +0 -0
  107. cocotb_tools/_coverage.py +33 -0
  108. cocotb_tools/_vendor/__init__.py +3 -0
  109. cocotb_tools/check_results.py +65 -0
  110. cocotb_tools/combine_results.py +152 -0
  111. cocotb_tools/config.py +241 -0
  112. {cocotb → cocotb_tools}/ipython_support.py +29 -22
  113. cocotb_tools/makefiles/Makefile.deprecations +27 -0
  114. {cocotb/share → cocotb_tools}/makefiles/Makefile.inc +77 -55
  115. {cocotb/share → cocotb_tools}/makefiles/Makefile.sim +16 -33
  116. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.activehdl +9 -16
  117. cocotb_tools/makefiles/simulators/Makefile.cvc +61 -0
  118. cocotb_tools/makefiles/simulators/Makefile.dsim +39 -0
  119. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.ghdl +13 -42
  120. cocotb_tools/makefiles/simulators/Makefile.icarus +80 -0
  121. cocotb_tools/makefiles/simulators/Makefile.ius +93 -0
  122. cocotb_tools/makefiles/simulators/Makefile.modelsim +9 -0
  123. cocotb_tools/makefiles/simulators/Makefile.nvc +60 -0
  124. cocotb_tools/makefiles/simulators/Makefile.questa +29 -0
  125. cocotb/share/makefiles/simulators/Makefile.questa → cocotb_tools/makefiles/simulators/Makefile.questa-compat +26 -54
  126. cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun +149 -0
  127. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.riviera +17 -56
  128. cocotb_tools/makefiles/simulators/Makefile.vcs +65 -0
  129. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.verilator +15 -22
  130. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.xcelium +20 -52
  131. cocotb_tools/py.typed +0 -0
  132. cocotb_tools/runner.py +1868 -0
  133. cocotb/_sim_versions.py → cocotb_tools/sim_versions.py +16 -21
  134. pygpi/entry.py +34 -18
  135. pygpi/py.typed +0 -0
  136. cocotb/ANSI.py +0 -92
  137. cocotb/binary.py +0 -858
  138. cocotb/config.py +0 -289
  139. cocotb/decorators.py +0 -332
  140. cocotb/log.py +0 -303
  141. cocotb/memdebug.py +0 -35
  142. cocotb/outcomes.py +0 -56
  143. cocotb/runner.py +0 -1400
  144. cocotb/scheduler.py +0 -1099
  145. cocotb/share/makefiles/Makefile.deprecations +0 -12
  146. cocotb/share/makefiles/simulators/Makefile.cvc +0 -94
  147. cocotb/share/makefiles/simulators/Makefile.icarus +0 -111
  148. cocotb/share/makefiles/simulators/Makefile.ius +0 -125
  149. cocotb/share/makefiles/simulators/Makefile.modelsim +0 -32
  150. cocotb/share/makefiles/simulators/Makefile.nvc +0 -64
  151. cocotb/share/makefiles/simulators/Makefile.vcs +0 -98
  152. cocotb/types/array.py +0 -309
  153. cocotb/types/logic.py +0 -292
  154. cocotb/types/logic_array.py +0 -298
  155. cocotb/wavedrom.py +0 -199
  156. cocotb/xunit_reporter.py +0 -80
  157. cocotb-1.9.2.dist-info/METADATA +0 -168
  158. cocotb-1.9.2.dist-info/RECORD +0 -121
  159. cocotb-1.9.2.dist-info/entry_points.txt +0 -2
  160. /cocotb/{_vendor/__init__.py → py.typed} +0 -0
  161. {cocotb → cocotb_tools}/_vendor/distutils_version.py +0 -0
cocotb/types/_logic.py ADDED
@@ -0,0 +1,333 @@
1
+ # Copyright cocotb contributors
2
+ # Licensed under the Revised BSD License, see LICENSE for details.
3
+ # SPDX-License-Identifier: BSD-3-Clause
4
+ from functools import lru_cache
5
+ from typing import (
6
+ Dict,
7
+ Union,
8
+ )
9
+
10
+ from cocotb._py_compat import Self, TypeAlias
11
+ from cocotb.types._resolve import RESOLVE_X, ResolverLiteral, get_str_resolver
12
+
13
+ LogicLiteralT: TypeAlias = Union[str, int, bool]
14
+ LogicConstructibleT: TypeAlias = Union[LogicLiteralT, "Logic"]
15
+
16
+
17
+ _U = 0
18
+ _X = 1
19
+ _0 = 2
20
+ _1 = 3
21
+ _Z = 4
22
+ _W = 5
23
+ _L = 6
24
+ _H = 7
25
+ _D = 8
26
+
27
+ _literal_repr: Dict[LogicLiteralT, int] = {
28
+ # unassigned
29
+ "U": _U,
30
+ "u": _U,
31
+ # unknown
32
+ "X": _X,
33
+ "x": _X,
34
+ # 0
35
+ 0: _0, # Also `False`
36
+ "0": _0,
37
+ # 1
38
+ 1: _1, # Also `True`
39
+ "1": _1,
40
+ # high impedance
41
+ "Z": _Z,
42
+ "z": _Z,
43
+ # weak unknown
44
+ "W": _W,
45
+ "w": _W,
46
+ # weak 0
47
+ "L": _L,
48
+ "l": _L,
49
+ # weak 1
50
+ "H": _H,
51
+ "h": _H,
52
+ # don't care
53
+ "-": _D,
54
+ }
55
+
56
+
57
+ class Logic:
58
+ r"""9-state digital signal value type.
59
+
60
+ This type is modeled after VHDL's ``std_ulogic`` type.
61
+ It can represent the values (``U``, ``X``, ``0``, ``1``, ``Z``, ``W``, ``L``, ``H``, ``-``).
62
+ (System)Verilog's 4-state ``logic`` type is a subset which only utilizes the ``X``, ``0``, ``1``, and ``Z`` values.
63
+
64
+ :class:`!Logic` can be converted to and from :class:`int`, :class:`str`, :class:`bool` and :class:`Bit`.
65
+ String literals include ``"U"``, ``"X"``, ``"0"``, ``"1"``, ``"Z"``, ``"W"``, ``"L"``, ``"H"``, ``"-"``, and their lowercase values.
66
+
67
+ .. code-block:: pycon3
68
+
69
+ >>> Logic("X")
70
+ Logic('X')
71
+ >>> Logic(True)
72
+ Logic('1')
73
+ >>> Logic(1)
74
+ Logic('1')
75
+
76
+ >>> str(Logic("Z"))
77
+ 'Z'
78
+ >>> bool(Logic(0))
79
+ False
80
+ >>> int(Logic(1))
81
+ 1
82
+
83
+ .. note::
84
+
85
+ The :class:`int` and :class:`bool` conversions will raise :exc:`ValueError` if the value is not ``0``, ``1``, ``L``, or ``H``.
86
+
87
+ :class:`Logic` supports the common logic operations ``&``, ``|``, ``^``, and ``~``.
88
+
89
+ .. code-block:: pycon3
90
+
91
+ >>> def full_adder(a: Logic, b: Logic, carry: Logic) -> Tuple[Logic, Logic]:
92
+ ... res = a ^ b ^ carry
93
+ ... carry_out = (a & b) | (b & carry) | (a & carry)
94
+ ... return res, carry_out
95
+
96
+ >>> full_adder(a=Logic("0"), b=Logic("1"), carry=Logic("1"))
97
+ (Logic('0'), Logic('1'))
98
+
99
+ Args:
100
+ value: value to construct into a :class:`!Logic`.
101
+
102
+ Raises:
103
+ ValueError: If the value if of the correct type, but cannot be constructed into a :class:`!Logic`.
104
+ TypeError: If the value is of a type that can't be constructed into a :class:`!Logic`.
105
+ """
106
+
107
+ _values = {_U, _X, _0, _1, _Z, _W, _L, _H, _D}
108
+
109
+ _repr: int
110
+
111
+ __slots__ = ("_repr",)
112
+
113
+ @classmethod
114
+ @lru_cache(maxsize=None)
115
+ def _singleton(cls, _repr: int) -> Self:
116
+ """Return the Logic object associated with the repr, enforcing singleton."""
117
+ self = object.__new__(cls)
118
+ self._repr = _repr
119
+ return self
120
+
121
+ def __new__(
122
+ cls,
123
+ value: LogicConstructibleT,
124
+ ) -> Self:
125
+ if isinstance(value, Logic):
126
+ _repr = value._repr
127
+ elif isinstance(value, (str, int)):
128
+ try:
129
+ _repr = _literal_repr[value]
130
+ except KeyError:
131
+ raise ValueError(
132
+ f"{value!r} is not convertible to {cls.__qualname__}"
133
+ ) from None
134
+ else:
135
+ raise TypeError(
136
+ f"Expected str, bool, or int, not {type(value).__qualname__}"
137
+ )
138
+
139
+ if _repr not in cls._values:
140
+ raise ValueError(f"{value!r} is not a valid {cls.__qualname__}")
141
+
142
+ return cls._singleton(_repr)
143
+
144
+ def __and__(self, other: Self) -> Self:
145
+ if not isinstance(other, type(self)):
146
+ return NotImplemented
147
+ return type(self)(
148
+ (
149
+ # -----------------------------------------------------
150
+ # U X 0 1 Z W L H - | |
151
+ # -----------------------------------------------------
152
+ ("U", "U", "0", "U", "U", "U", "0", "U", "U"), # | U |
153
+ ("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | X |
154
+ ("0", "0", "0", "0", "0", "0", "0", "0", "0"), # | 0 |
155
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | 1 |
156
+ ("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | Z |
157
+ ("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | W |
158
+ ("0", "0", "0", "0", "0", "0", "0", "0", "0"), # | L |
159
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | H |
160
+ ("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | - |
161
+ )[self._repr][other._repr]
162
+ )
163
+
164
+ def __rand__(self, other: Self) -> Self:
165
+ return self & other
166
+
167
+ def __or__(self, other: Self) -> Self:
168
+ if not isinstance(other, type(self)):
169
+ return NotImplemented
170
+ return type(self)(
171
+ (
172
+ # -----------------------------------------------------
173
+ # U X 0 1 Z W L H - | |
174
+ # -----------------------------------------------------
175
+ ("U", "U", "U", "1", "U", "U", "U", "1", "U"), # | U |
176
+ ("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | X |
177
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | 0 |
178
+ ("1", "1", "1", "1", "1", "1", "1", "1", "1"), # | 1 |
179
+ ("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | Z |
180
+ ("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | W |
181
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | L |
182
+ ("1", "1", "1", "1", "1", "1", "1", "1", "1"), # | H |
183
+ ("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | - |
184
+ )[self._repr][other._repr]
185
+ )
186
+
187
+ def __ror__(self, other: Self) -> Self:
188
+ return self | other
189
+
190
+ def __xor__(self, other: Self) -> Self:
191
+ if not isinstance(other, type(self)):
192
+ return NotImplemented
193
+ return type(self)(
194
+ (
195
+ # -----------------------------------------------------
196
+ # U X 0 1 Z W L H - | |
197
+ # -----------------------------------------------------
198
+ ("U", "U", "U", "U", "U", "U", "U", "U", "U"), # | U |
199
+ ("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | X |
200
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | 0 |
201
+ ("U", "X", "1", "0", "X", "X", "1", "0", "X"), # | 1 |
202
+ ("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | Z |
203
+ ("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | W |
204
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | L |
205
+ ("U", "X", "1", "0", "X", "X", "1", "0", "X"), # | H |
206
+ ("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | - |
207
+ )[self._repr][other._repr]
208
+ )
209
+
210
+ def __rxor__(self, other: Self) -> Self:
211
+ return self ^ other
212
+
213
+ def __invert__(self) -> Self:
214
+ return type(self)(("U", "X", "1", "0", "X", "X", "1", "0", "X")[self._repr])
215
+
216
+ def __eq__(self, other: object) -> bool:
217
+ if isinstance(other, Logic):
218
+ return self._repr == other._repr
219
+ elif isinstance(other, (int, str, bool)):
220
+ try:
221
+ other = Logic(other)
222
+ except ValueError:
223
+ return False
224
+ return self == other
225
+ else:
226
+ return NotImplemented
227
+
228
+ __hash__: None # type: ignore[assignment]
229
+
230
+ def __repr__(self) -> str:
231
+ return f"{type(self).__qualname__}({str(self)!r})"
232
+
233
+ def __str__(self) -> str:
234
+ return ("U", "X", "0", "1", "Z", "W", "L", "H", "-")[self._repr]
235
+
236
+ if RESOLVE_X is None:
237
+
238
+ def __bool__(self) -> bool:
239
+ if self._repr in (_0, _L):
240
+ return False
241
+ elif self._repr in (_1, _H):
242
+ return True
243
+ raise ValueError(f"Cannot convert {self!r} to bool")
244
+
245
+ def __int__(self) -> int:
246
+ if self._repr in (_0, _L):
247
+ return 0
248
+ elif self._repr in (_1, _H):
249
+ return 1
250
+ raise ValueError(f"Cannot convert {self!r} to int")
251
+
252
+ else:
253
+
254
+ def __bool__(self) -> bool:
255
+ return self._repr in (_1, _H)
256
+
257
+ def __int__(self) -> int:
258
+ s = str(self)
259
+ s = RESOLVE_X(s)
260
+ return int(s, 2)
261
+
262
+ def __index__(self) -> int:
263
+ return int(self)
264
+
265
+ def resolve(self, resolver: ResolverLiteral) -> Self:
266
+ """Resolve non-``0``/``1`` values to ``0``/``1``.
267
+
268
+ The possible values of the *resolver* argument are:
269
+
270
+ * ``"weak"``:
271
+ Weak values are resolved to their strong-valued equivalents.
272
+
273
+ * ``"zeros"``:
274
+ ``L`` and ``H`` are resolved to ``0`` and ``1``, respectively.
275
+ Remaining non-``0``/``1`` values are resolved to ``0``.
276
+
277
+ * ``"ones"``:
278
+ ``L`` and ``H`` are resolved to ``0`` and ``1``, respectively.
279
+ Remaining non-``0``/``1`` values are resolved to ``1``.
280
+
281
+ * ``"random"``:
282
+ ``L`` and ``H`` are resolved to ``0`` and ``1``, respectively.
283
+ Remaining non-``0``/``1`` values are randomly resolved to either ``0`` or ``1``.
284
+
285
+ Args:
286
+ resolver: How to resolve non-``0``/``1`` values. See possible values above.
287
+
288
+ Returns:
289
+ The resolved Logic.
290
+
291
+ Raises:
292
+ ValueError: Invalid *resolver* value.
293
+ TypeError: Unsupported *value* type.
294
+ """
295
+ return type(self)(get_str_resolver(resolver)(str(self)))
296
+
297
+ def __len__(self) -> int:
298
+ return 1
299
+
300
+ @property
301
+ def is_resolvable(self) -> bool:
302
+ """``True`` if value is ``0``, ``1``, ``L``, ``H``.
303
+
304
+ .. versionadded:: 2.0
305
+ """
306
+ return (False, False, True, True, False, False, True, True, False)[self._repr]
307
+
308
+ def __copy__(self) -> "Logic":
309
+ return self
310
+
311
+ def __deepcopy__(self, memo: Dict[int, object]) -> "Logic":
312
+ return self
313
+
314
+
315
+ class Bit(Logic):
316
+ """2-state digital signal value type.
317
+
318
+ This is modeled after (System)Verilog's and VHDL's ``bit`` type.
319
+ It can represent only the values ``0`` and ``1``.
320
+ It can be converted to and from :class:`int`, :class:`str`, :class:`bool`, or :class:`Logic` values.
321
+
322
+ As a subtype of :class:`!Logic`, it supports all of the same operations
323
+ and can be used in operations interchangeably with :class:`!Logic`.
324
+
325
+ Args:
326
+ value: value to construct into a :class:`!Bit`.
327
+
328
+ Raises:
329
+ ValueError: If the value if of the correct type, but cannot be constructed into a :class:`!Bit`.
330
+ TypeError: If the value is of a type that can't be constructed into a :class:`!Bit`.
331
+ """
332
+
333
+ _values = {_0, _1}