cocotb 1.9.2__cp38-cp38-win32.whl → 2.0.0b1__cp38-cp38-win32.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 (155) hide show
  1. cocotb/{ANSI.py → _ANSI.py} +5 -25
  2. cocotb/__init__.py +76 -332
  3. cocotb/_base_triggers.py +513 -0
  4. cocotb/_bridge.py +187 -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 +382 -0
  10. cocotb/_init.py +295 -0
  11. cocotb/_outcomes.py +54 -0
  12. cocotb/_profiling.py +46 -0
  13. cocotb/_py_compat.py +100 -29
  14. cocotb/_scheduler.py +454 -0
  15. cocotb/_test.py +245 -0
  16. cocotb/_test_factory.py +309 -0
  17. cocotb/_test_functions.py +42 -0
  18. cocotb/_typing.py +7 -0
  19. cocotb/_utils.py +296 -0
  20. cocotb/_version.py +3 -7
  21. cocotb/_xunit_reporter.py +66 -0
  22. cocotb/clock.py +271 -108
  23. cocotb/handle.py +1342 -795
  24. cocotb/libs/cocotb.dll +0 -0
  25. cocotb/libs/cocotb.exp +0 -0
  26. cocotb/libs/cocotb.lib +0 -0
  27. cocotb/libs/cocotbfli_modelsim.dll +0 -0
  28. cocotb/libs/cocotbfli_modelsim.exp +0 -0
  29. cocotb/libs/cocotbfli_modelsim.lib +0 -0
  30. cocotb/libs/cocotbutils.dll +0 -0
  31. cocotb/libs/cocotbutils.exp +0 -0
  32. cocotb/libs/cocotbutils.lib +0 -0
  33. cocotb/libs/cocotbvhpi_aldec.dll +0 -0
  34. cocotb/libs/cocotbvhpi_aldec.exp +0 -0
  35. cocotb/libs/cocotbvhpi_aldec.lib +0 -0
  36. cocotb/libs/cocotbvhpi_modelsim.dll +0 -0
  37. cocotb/libs/cocotbvhpi_modelsim.exp +0 -0
  38. cocotb/libs/cocotbvhpi_modelsim.lib +0 -0
  39. cocotb/libs/cocotbvpi_aldec.dll +0 -0
  40. cocotb/libs/cocotbvpi_aldec.exp +0 -0
  41. cocotb/libs/cocotbvpi_aldec.lib +0 -0
  42. cocotb/libs/cocotbvpi_ghdl.dll +0 -0
  43. cocotb/libs/cocotbvpi_ghdl.exp +0 -0
  44. cocotb/libs/cocotbvpi_ghdl.lib +0 -0
  45. cocotb/libs/cocotbvpi_icarus.exp +0 -0
  46. cocotb/libs/cocotbvpi_icarus.lib +0 -0
  47. cocotb/libs/cocotbvpi_icarus.vpl +0 -0
  48. cocotb/libs/cocotbvpi_modelsim.dll +0 -0
  49. cocotb/libs/cocotbvpi_modelsim.exp +0 -0
  50. cocotb/libs/cocotbvpi_modelsim.lib +0 -0
  51. cocotb/libs/embed.dll +0 -0
  52. cocotb/libs/embed.exp +0 -0
  53. cocotb/libs/embed.lib +0 -0
  54. cocotb/libs/gpi.dll +0 -0
  55. cocotb/libs/gpi.exp +0 -0
  56. cocotb/libs/gpi.lib +0 -0
  57. cocotb/libs/gpilog.dll +0 -0
  58. cocotb/libs/gpilog.exp +0 -0
  59. cocotb/libs/gpilog.lib +0 -0
  60. cocotb/libs/pygpilog.dll +0 -0
  61. cocotb/libs/pygpilog.exp +0 -0
  62. cocotb/libs/pygpilog.lib +0 -0
  63. cocotb/{log.py → logging.py} +105 -110
  64. cocotb/queue.py +103 -57
  65. cocotb/regression.py +667 -712
  66. cocotb/result.py +17 -188
  67. cocotb/share/def/aldec.exp +0 -0
  68. cocotb/share/def/aldec.lib +0 -0
  69. cocotb/share/def/ghdl.exp +0 -0
  70. cocotb/share/def/ghdl.lib +0 -0
  71. cocotb/share/def/icarus.exp +0 -0
  72. cocotb/share/def/icarus.lib +0 -0
  73. cocotb/share/def/modelsim.def +1 -0
  74. cocotb/share/def/modelsim.exp +0 -0
  75. cocotb/share/def/modelsim.lib +0 -0
  76. cocotb/share/include/cocotb_utils.h +6 -29
  77. cocotb/share/include/embed.h +5 -28
  78. cocotb/share/include/gpi.h +137 -92
  79. cocotb/share/include/gpi_logging.h +221 -142
  80. cocotb/share/include/py_gpi_logging.h +7 -4
  81. cocotb/share/include/vpi_user_ext.h +4 -26
  82. cocotb/share/lib/verilator/verilator.cpp +59 -54
  83. cocotb/simulator.cp38-win32.exp +0 -0
  84. cocotb/simulator.cp38-win32.lib +0 -0
  85. cocotb/simulator.cp38-win32.pyd +0 -0
  86. cocotb/simulator.pyi +107 -0
  87. cocotb/task.py +434 -212
  88. cocotb/triggers.py +55 -1092
  89. cocotb/types/__init__.py +25 -47
  90. cocotb/types/_abstract_array.py +151 -0
  91. cocotb/types/_array.py +264 -0
  92. cocotb/types/_logic.py +296 -0
  93. cocotb/types/_logic_array.py +834 -0
  94. cocotb/types/{range.py → _range.py} +36 -44
  95. cocotb/types/_resolve.py +76 -0
  96. cocotb/utils.py +119 -587
  97. cocotb-2.0.0b1.dist-info/METADATA +46 -0
  98. cocotb-2.0.0b1.dist-info/RECORD +143 -0
  99. {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/WHEEL +1 -1
  100. cocotb-2.0.0b1.dist-info/entry_points.txt +2 -0
  101. {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/top_level.txt +1 -0
  102. cocotb_tools/__init__.py +0 -0
  103. cocotb_tools/_coverage.py +33 -0
  104. cocotb_tools/_vendor/__init__.py +3 -0
  105. cocotb_tools/check_results.py +65 -0
  106. cocotb_tools/combine_results.py +152 -0
  107. cocotb_tools/config.py +241 -0
  108. {cocotb → cocotb_tools}/ipython_support.py +29 -22
  109. cocotb_tools/makefiles/Makefile.deprecations +27 -0
  110. {cocotb/share → cocotb_tools}/makefiles/Makefile.inc +82 -54
  111. {cocotb/share → cocotb_tools}/makefiles/Makefile.sim +8 -33
  112. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.activehdl +9 -16
  113. cocotb_tools/makefiles/simulators/Makefile.cvc +61 -0
  114. cocotb_tools/makefiles/simulators/Makefile.dsim +39 -0
  115. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.ghdl +13 -42
  116. cocotb_tools/makefiles/simulators/Makefile.icarus +80 -0
  117. cocotb_tools/makefiles/simulators/Makefile.ius +93 -0
  118. cocotb_tools/makefiles/simulators/Makefile.modelsim +9 -0
  119. cocotb_tools/makefiles/simulators/Makefile.nvc +60 -0
  120. cocotb_tools/makefiles/simulators/Makefile.questa +29 -0
  121. cocotb/share/makefiles/simulators/Makefile.questa → cocotb_tools/makefiles/simulators/Makefile.questa-compat +26 -54
  122. cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun +149 -0
  123. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.riviera +17 -56
  124. cocotb_tools/makefiles/simulators/Makefile.vcs +65 -0
  125. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.verilator +15 -22
  126. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.xcelium +20 -52
  127. cocotb_tools/py.typed +0 -0
  128. {cocotb → cocotb_tools}/runner.py +794 -361
  129. cocotb/_sim_versions.py → cocotb_tools/sim_versions.py +16 -21
  130. pygpi/entry.py +34 -17
  131. pygpi/py.typed +0 -0
  132. cocotb/binary.py +0 -858
  133. cocotb/config.py +0 -289
  134. cocotb/decorators.py +0 -332
  135. cocotb/memdebug.py +0 -35
  136. cocotb/outcomes.py +0 -56
  137. cocotb/scheduler.py +0 -1099
  138. cocotb/share/makefiles/Makefile.deprecations +0 -12
  139. cocotb/share/makefiles/simulators/Makefile.cvc +0 -94
  140. cocotb/share/makefiles/simulators/Makefile.icarus +0 -111
  141. cocotb/share/makefiles/simulators/Makefile.ius +0 -125
  142. cocotb/share/makefiles/simulators/Makefile.modelsim +0 -32
  143. cocotb/share/makefiles/simulators/Makefile.nvc +0 -64
  144. cocotb/share/makefiles/simulators/Makefile.vcs +0 -98
  145. cocotb/types/array.py +0 -309
  146. cocotb/types/logic.py +0 -292
  147. cocotb/types/logic_array.py +0 -298
  148. cocotb/wavedrom.py +0 -199
  149. cocotb/xunit_reporter.py +0 -80
  150. cocotb-1.9.2.dist-info/METADATA +0 -168
  151. cocotb-1.9.2.dist-info/RECORD +0 -121
  152. cocotb-1.9.2.dist-info/entry_points.txt +0 -2
  153. /cocotb/{_vendor/__init__.py → py.typed} +0 -0
  154. {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/LICENSE +0 -0
  155. {cocotb → cocotb_tools}/_vendor/distutils_version.py +0 -0
cocotb/types/_logic.py ADDED
@@ -0,0 +1,296 @@
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
+ Set,
8
+ Type,
9
+ Union,
10
+ )
11
+
12
+ from cocotb._deprecation import deprecated
13
+ from cocotb._py_compat import TypeAlias
14
+ from cocotb.types._resolve import RESOLVE_X, ResolverLiteral, get_str_resolver
15
+
16
+ LogicLiteralT: TypeAlias = Union[str, int, bool]
17
+ LogicConstructibleT: TypeAlias = Union[LogicLiteralT, "Logic"]
18
+
19
+
20
+ _U = 0
21
+ _X = 1
22
+ _0 = 2
23
+ _1 = 3
24
+ _Z = 4
25
+ _W = 5
26
+ _L = 6
27
+ _H = 7
28
+ _D = 8
29
+
30
+ _literal_repr: Dict[LogicLiteralT, int] = {
31
+ # unassigned
32
+ "U": _U,
33
+ "u": _U,
34
+ # unknown
35
+ "X": _X,
36
+ "x": _X,
37
+ # 0
38
+ 0: _0, # Also `False`
39
+ "0": _0,
40
+ # 1
41
+ 1: _1, # Also `True`
42
+ "1": _1,
43
+ # high impedance
44
+ "Z": _Z,
45
+ "z": _Z,
46
+ # weak unknown
47
+ "W": _W,
48
+ "w": _W,
49
+ # weak 0
50
+ "L": _L,
51
+ "l": _L,
52
+ # weak 1
53
+ "H": _H,
54
+ "h": _H,
55
+ # don't care
56
+ "-": _D,
57
+ }
58
+
59
+ _str_literals: Set[str] = {k for k in _literal_repr if isinstance(k, str)}
60
+
61
+
62
+ class Logic:
63
+ r"""
64
+ Model of a 9-value (``U``, ``X``, ``0``, ``1``, ``Z``, ``W``, ``L``, ``H``, ``-``) datatype commonly seen in VHDL.
65
+
66
+ .. currentmodule:: cocotb.types
67
+
68
+ This is modeled after VHDL's ``std_ulogic`` type.
69
+ (System)Verilog's 4-value ``logic`` type only utilizes ``X``, ``0``, ``1``, and ``Z`` values.
70
+
71
+ :class:`Logic` can be converted to and from :class:`int`, :class:`str`, and :class:`bool`.
72
+ The list of values convertible to :class:`Logic` includes
73
+ ``"U"``, ``"X"``, ``"0"``, ``"1"``, ``"Z"``, ``"W"``, ``"L"``, ``"H"``, ``"-"``, ``0``, ``1``, ``True``, and ``False``.
74
+
75
+ .. code-block:: pycon3
76
+
77
+ >>> Logic("X")
78
+ Logic('X')
79
+ >>> Logic(True)
80
+ Logic('1')
81
+ >>> Logic(1)
82
+ Logic('1')
83
+
84
+ >>> str(Logic("Z"))
85
+ 'Z'
86
+ >>> bool(Logic(0))
87
+ False
88
+ >>> int(Logic(1))
89
+ 1
90
+
91
+ .. note::
92
+
93
+ The :class:`int` and :class:`bool` conversions will raise :exc:`ValueError` if the value is not ``0``, ``1``, ``L``, or ``H``.
94
+
95
+ :class:`Logic` values are immutable and therefore hashable and can be placed in :class:`set`\ s and used as keys in :class:`dict`\ s.
96
+
97
+ :class:`Logic` supports the common logic operations ``&``, ``|``, ``^``, and ``~``.
98
+
99
+ .. code-block:: pycon3
100
+
101
+ >>> def full_adder(a: Logic, b: Logic, carry: Logic) -> Tuple[Logic, Logic]:
102
+ ... res = a ^ b ^ carry
103
+ ... carry_out = (a & b) | (b & carry) | (a & carry)
104
+ ... return res, carry_out
105
+
106
+ >>> full_adder(a=Logic("0"), b=Logic("1"), carry=Logic("1"))
107
+ (Logic('0'), Logic('1'))
108
+
109
+ Args:
110
+ value: value to construct into a :class:`Logic`.
111
+
112
+ Raises:
113
+ ValueError: If the value if of the correct type, but cannot be constructed into a :class:`Logic`.
114
+ TypeError: If the value is of a type that can't be constructed into a :class:`Logic`.
115
+ """
116
+
117
+ _repr: int
118
+
119
+ @classmethod
120
+ @lru_cache(maxsize=None)
121
+ def _singleton(cls: Type["Logic"], _repr: int) -> "Logic":
122
+ """Return the Logic object associated with the repr, enforcing singleton."""
123
+ self = object.__new__(cls)
124
+ self._repr = _repr
125
+ return self
126
+
127
+ @classmethod
128
+ @lru_cache(maxsize=None)
129
+ def _map_literal(
130
+ cls: Type["Logic"],
131
+ value: LogicLiteralT,
132
+ ) -> "Logic":
133
+ """Convert and cache all literals."""
134
+ try:
135
+ _repr = _literal_repr[value]
136
+ except KeyError:
137
+ raise ValueError(
138
+ f"{value!r} is not convertible to a {cls.__qualname__}"
139
+ ) from None
140
+ obj = cls._singleton(_repr)
141
+ return obj
142
+
143
+ def __new__(
144
+ cls: Type["Logic"],
145
+ value: LogicConstructibleT,
146
+ ) -> "Logic":
147
+ if isinstance(value, Logic):
148
+ return value
149
+ elif isinstance(value, (str, int)):
150
+ return cls._map_literal(value)
151
+ raise TypeError(f"Expected str, bool, or int, not {type(value).__qualname__}")
152
+
153
+ def __and__(self, other: "Logic") -> "Logic":
154
+ if not isinstance(other, Logic):
155
+ return NotImplemented
156
+ return Logic(
157
+ (
158
+ # -----------------------------------------------------
159
+ # U X 0 1 Z W L H - | |
160
+ # -----------------------------------------------------
161
+ ("U", "U", "0", "U", "U", "U", "0", "U", "U"), # | U |
162
+ ("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | X |
163
+ ("0", "0", "0", "0", "0", "0", "0", "0", "0"), # | 0 |
164
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | 1 |
165
+ ("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | Z |
166
+ ("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | W |
167
+ ("0", "0", "0", "0", "0", "0", "0", "0", "0"), # | L |
168
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | H |
169
+ ("U", "X", "0", "X", "X", "X", "0", "X", "X"), # | - |
170
+ )[self._repr][other._repr]
171
+ )
172
+
173
+ def __or__(self: "Logic", other: "Logic") -> "Logic":
174
+ if not isinstance(other, Logic):
175
+ return NotImplemented
176
+ return Logic(
177
+ (
178
+ # -----------------------------------------------------
179
+ # U X 0 1 Z W L H - | |
180
+ # -----------------------------------------------------
181
+ ("U", "U", "U", "1", "U", "U", "U", "1", "U"), # | U |
182
+ ("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | X |
183
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | 0 |
184
+ ("1", "1", "1", "1", "1", "1", "1", "1", "1"), # | 1 |
185
+ ("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | Z |
186
+ ("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | W |
187
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | L |
188
+ ("1", "1", "1", "1", "1", "1", "1", "1", "1"), # | H |
189
+ ("U", "X", "X", "1", "X", "X", "X", "1", "X"), # | - |
190
+ )[self._repr][other._repr]
191
+ )
192
+
193
+ def __xor__(self: "Logic", other: "Logic") -> "Logic":
194
+ if not isinstance(other, Logic):
195
+ return NotImplemented
196
+ return Logic(
197
+ (
198
+ # -----------------------------------------------------
199
+ # U X 0 1 Z W L H - | |
200
+ # -----------------------------------------------------
201
+ ("U", "U", "U", "U", "U", "U", "U", "U", "U"), # | U |
202
+ ("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | X |
203
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | 0 |
204
+ ("U", "X", "1", "0", "X", "X", "1", "0", "X"), # | 1 |
205
+ ("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | Z |
206
+ ("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | W |
207
+ ("U", "X", "0", "1", "X", "X", "0", "1", "X"), # | L |
208
+ ("U", "X", "1", "0", "X", "X", "1", "0", "X"), # | H |
209
+ ("U", "X", "X", "X", "X", "X", "X", "X", "X"), # | - |
210
+ )[self._repr][other._repr]
211
+ )
212
+
213
+ def __invert__(self: "Logic") -> "Logic":
214
+ return Logic(("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 is other
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
+ def __repr__(self) -> str:
229
+ return f"{type(self).__qualname__}({str(self)!r})"
230
+
231
+ def __str__(self) -> str:
232
+ return ("U", "X", "0", "1", "Z", "W", "L", "H", "-")[self._repr]
233
+
234
+ if RESOLVE_X is None:
235
+
236
+ def __bool__(self) -> bool:
237
+ if self._repr in (_0, _L):
238
+ return False
239
+ elif self._repr in (_1, _H):
240
+ return True
241
+ raise ValueError(f"Cannot convert {self!r} to bool")
242
+
243
+ def __int__(self) -> int:
244
+ if self._repr in (_0, _L):
245
+ return 0
246
+ elif self._repr in (_1, _H):
247
+ return 1
248
+ raise ValueError(f"Cannot convert {self!r} to int")
249
+
250
+ else:
251
+
252
+ def __bool__(self) -> bool:
253
+ return self._repr in (_1, _H)
254
+
255
+ def __int__(self) -> int:
256
+ s = str(self)
257
+ s = RESOLVE_X(s)
258
+ return int(s, 2)
259
+
260
+ def __index__(self) -> int:
261
+ return int(self)
262
+
263
+ def resolve(self, resolver: ResolverLiteral) -> "Logic":
264
+ """Resolves non-0/1 values to 0/1.
265
+
266
+ The possible values of the *resolver* argument are:
267
+
268
+ * ``"weak"``: Weak values are resolved to their strong-valued equivalents.
269
+
270
+ * ``"zeros"``:
271
+ ``L`` and ``H`` are resolved to ``0`` and ``1``, respectively.
272
+ Remaining non-``0``/``1`` values are resolved to ``0``.
273
+
274
+ * ``"ones"``:
275
+ ``L`` and ``H`` are resolved to ``0`` and ``1``, respectively.
276
+ Remaining non-``0``/``1`` values are resolved to ``1``.
277
+
278
+ * ``"random"``:
279
+ ``L`` and ``H`` are resolved to ``0`` and ``1``, respectively.
280
+ Remaining non-``0``/``1`` values are randomly resolved to either ``0`` or ``1``.
281
+
282
+ Args:
283
+ resolver: How to resolve non-``0``/``1`` values. See possible values above.
284
+
285
+ Returns:
286
+ The resolved Logic.
287
+
288
+ Raises:
289
+ ValueError: Invalid *resolver* value.
290
+ TypeError: Unsupported *value* type.
291
+ """
292
+ return Logic(get_str_resolver(resolver)(str(self)))
293
+
294
+ @deprecated('`len(logic)` is deprecated. A Logic\'s "length" is always 1.')
295
+ def __len__(self) -> int:
296
+ return 1