cocotb 1.9.2__cp312-cp312-win32.whl → 2.0.0rc2__cp312-cp312-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 (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.cp312-win32.exp +0 -0
  86. cocotb/simulator.cp312-win32.lib +0 -0
  87. cocotb/simulator.cp312-win32.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
@@ -1,12 +1,14 @@
1
1
  # Copyright cocotb contributors
2
2
  # Licensed under the Revised BSD License, see LICENSE for details.
3
3
  # SPDX-License-Identifier: BSD-3-Clause
4
- import typing
4
+ import copy
5
+ from functools import lru_cache
6
+ from typing import Any, Dict, Iterator, Sequence, Union, overload
5
7
 
6
- T = typing.TypeVar("T")
8
+ from cocotb._utils import cached_method
7
9
 
8
10
 
9
- class Range(typing.Sequence[int]):
11
+ class Range(Sequence[int]):
10
12
  r"""
11
13
  Variant of :class:`range` with inclusive right bound.
12
14
 
@@ -19,19 +21,19 @@ class Range(typing.Sequence[int]):
19
21
  left and right bounds.
20
22
  Not specifying directionality will cause the directionality to be inferred.
21
23
 
22
- .. code-block:: python3
24
+ .. code-block:: pycon3
23
25
 
24
26
  >>> r = Range(-2, 3)
25
27
  >>> r.left, r.right, len(r)
26
28
  (-2, 3, 6)
27
29
 
28
- >>> s = Range(8, 'downto', 1)
30
+ >>> s = Range(8, "downto", 1)
29
31
  >>> s.left, s.right, len(s)
30
32
  (8, 1, 8)
31
33
 
32
34
  :meth:`from_range` and :meth:`to_range` can be used to convert from and to :class:`range`.
33
35
 
34
- .. code-block:: python3
36
+ .. code-block:: pycon3
35
37
 
36
38
  >>> r = Range(-2, 3)
37
39
  >>> r.to_range()
@@ -39,11 +41,11 @@ class Range(typing.Sequence[int]):
39
41
 
40
42
  :class:`Range` supports "null" ranges as seen in VHDL.
41
43
  "null" ranges occur when a left bound cannot reach a right bound with the given direction.
42
- They have a length of 0, but the :attr:`left`, :attr:`right`, and :attr:`direction` values remain as given.
44
+ They have a length of ``0``, but the :attr:`left`, :attr:`right`, and :attr:`direction` values remain as given.
43
45
 
44
- .. code-block:: python3
46
+ .. code-block:: pycon3
45
47
 
46
- >>> r = Range(1, 'to', 0) # no way to count from 1 'to' 0
48
+ >>> r = Range(1, "to", 0) # no way to count from 1 'to' 0
47
49
  >>> r.left, r.direction, r.right
48
50
  (1, 'to', 0)
49
51
  >>> len(r)
@@ -60,30 +62,25 @@ class Range(typing.Sequence[int]):
60
62
  The typical use case of this type is in conjunction with :class:`~cocotb.types.Array`.
61
63
 
62
64
  Args:
63
- left: leftmost bound of range
64
- direction: ``'to'`` if values are ascending, ``'downto'`` if descending
65
- right: rightmost bound of range (inclusive)
65
+ left: Leftmost bound of range.
66
+ direction: ``'to'`` if values are ascending, ``'downto'`` if descending.
67
+ right: Rightmost bound of range (inclusive).
66
68
  """
67
69
 
68
- __slots__ = ("_range",)
70
+ @overload
71
+ def __init__(self, left: int, direction: int) -> None: ...
69
72
 
70
- @typing.overload
71
- def __init__(self, left: int, direction: int) -> None:
72
- pass # pragma: no cover
73
+ @overload
74
+ def __init__(self, left: int, direction: str, right: int) -> None: ...
73
75
 
74
- @typing.overload
75
- def __init__(self, left: int, direction: str, right: int) -> None:
76
- pass # pragma: no cover
77
-
78
- @typing.overload
79
- def __init__(self, left: int, *, right: int) -> None:
80
- pass # pragma: no cover
76
+ @overload
77
+ def __init__(self, left: int, *, right: int) -> None: ...
81
78
 
82
79
  def __init__(
83
80
  self,
84
81
  left: int,
85
- direction: typing.Union[int, str, None] = None,
86
- right: typing.Union[int, None] = None,
82
+ direction: Union[int, str, None] = None,
83
+ right: Union[int, None] = None,
87
84
  ) -> None:
88
85
  start = left
89
86
  stop: int
@@ -91,12 +88,12 @@ class Range(typing.Sequence[int]):
91
88
  if isinstance(direction, int) and right is None:
92
89
  step = _guess_step(left, direction)
93
90
  stop = direction + step
94
- elif direction is None and isinstance(right, int):
95
- step = _guess_step(left, right)
96
- stop = right + step
97
91
  elif isinstance(direction, str) and isinstance(right, int):
98
92
  step = _direction_to_step(direction)
99
93
  stop = right + step
94
+ elif direction is None and isinstance(right, int):
95
+ step = _guess_step(left, right)
96
+ stop = right + step
100
97
  else:
101
98
  raise TypeError("invalid arguments")
102
99
  self._range = range(start, stop, step)
@@ -111,51 +108,49 @@ class Range(typing.Sequence[int]):
111
108
  )
112
109
 
113
110
  def to_range(self) -> range:
114
- """Convert :class:`Range` to :class:`range`."""
111
+ """Convert Range to :class:`range`."""
115
112
  return self._range
116
113
 
117
114
  @property
118
115
  def left(self) -> int:
119
- """Leftmost value in a range."""
116
+ """Leftmost value in a Range."""
120
117
  return self._range.start
121
118
 
122
119
  @property
123
120
  def direction(self) -> str:
124
- """``'to'`` if values are meant to be ascending, ``'downto'`` otherwise."""
121
+ """``'to'`` if Range is ascending, ``'downto'`` otherwise."""
125
122
  return _step_to_direction(self._range.step)
126
123
 
127
124
  @property
128
125
  def right(self) -> int:
129
- """Rightmost value in a range."""
126
+ """Rightmost value in a Range."""
130
127
  return self._range.stop - self._range.step
131
128
 
132
129
  def __len__(self) -> int:
133
130
  return len(self._range)
134
131
 
135
- @typing.overload
136
- def __getitem__(self, item: int) -> int:
137
- pass # pragma: no cover
132
+ @overload
133
+ def __getitem__(self, item: int) -> int: ...
138
134
 
139
- @typing.overload
140
- def __getitem__(self, item: slice) -> "Range":
141
- pass # pragma: no cover
135
+ @overload
136
+ def __getitem__(self, item: slice) -> "Range": ...
142
137
 
143
- def __getitem__(self, item: typing.Union[int, slice]) -> typing.Union[int, "Range"]:
138
+ def __getitem__(self, item: Union[int, slice]) -> Union[int, "Range"]:
144
139
  if isinstance(item, int):
145
140
  return self._range[item]
146
141
  elif isinstance(item, slice):
147
142
  return type(self).from_range(self._range[item])
148
143
  raise TypeError(
149
- "indices must be integers or slices, not {}".format(type(item).__name__)
144
+ f"indices must be integers or slices, not {type(item).__name__}"
150
145
  )
151
146
 
152
147
  def __contains__(self, item: object) -> bool:
153
148
  return item in self._range
154
149
 
155
- def __iter__(self) -> typing.Iterator[int]:
150
+ def __iter__(self) -> Iterator[int]:
156
151
  return iter(self._range)
157
152
 
158
- def __reversed__(self) -> typing.Iterator[int]:
153
+ def __reversed__(self) -> Iterator[int]:
159
154
  return reversed(self._range)
160
155
 
161
156
  def __eq__(self, other: object) -> bool:
@@ -166,13 +161,16 @@ class Range(typing.Sequence[int]):
166
161
  def __hash__(self) -> int:
167
162
  return hash(self._range)
168
163
 
169
- def count(self, item: int) -> int:
170
- return self._range.count(item)
171
-
172
164
  def __repr__(self) -> str:
173
- return "{}({!r}, {!r}, {!r})".format(
174
- type(self).__qualname__, self.left, self.direction, self.right
175
- )
165
+ return f"{type(self).__qualname__}({self.left!r}, {self.direction!r}, {self.right!r})"
166
+
167
+ index = cached_method(Sequence.index)
168
+
169
+ def __copy__(self) -> "Range":
170
+ return Range.from_range(self._range)
171
+
172
+ def __deepcopy__(self, memo: Dict[int, Any]) -> "Range":
173
+ return Range.from_range(copy.deepcopy(self._range, memo=memo))
176
174
 
177
175
 
178
176
  def _guess_step(left: int, right: int) -> int:
@@ -181,6 +179,7 @@ def _guess_step(left: int, right: int) -> int:
181
179
  return -1
182
180
 
183
181
 
182
+ @lru_cache(maxsize=None)
184
183
  def _direction_to_step(direction: str) -> int:
185
184
  direction = direction.lower()
186
185
  if direction == "to":
@@ -0,0 +1,76 @@
1
+ # Copyright cocotb contributors
2
+ # Licensed under the Revised BSD License, see LICENSE for details.
3
+ # SPDX-License-Identifier: BSD-3-Clause
4
+ import os
5
+ from functools import lru_cache
6
+ from random import getrandbits
7
+ from typing import Callable, Dict, Union
8
+
9
+ from cocotb._py_compat import Final, Literal, TypeAlias
10
+
11
+ ResolverLiteral: TypeAlias = Literal["weak", "zeros", "ones", "random"]
12
+
13
+
14
+ _ord_0 = ord("0")
15
+
16
+
17
+ class _random_resolve_table(Dict[int, int]):
18
+ def __init__(self) -> None:
19
+ self[ord("0")] = ord("0")
20
+ self[ord("1")] = ord("1")
21
+ self[ord("L")] = ord("0")
22
+ self[ord("H")] = ord("1")
23
+
24
+ def __missing__(self, _: str) -> int:
25
+ return getrandbits(1) + _ord_0
26
+
27
+
28
+ _resolve_tables: Dict[str, Dict[int, int]] = {
29
+ "error": {},
30
+ "weak": str.maketrans("LHW", "01X"),
31
+ "zeros": str.maketrans("LHUXZW-", "0100000"),
32
+ "ones": str.maketrans("LHUXZW-", "0111111"),
33
+ "random": _random_resolve_table(),
34
+ }
35
+
36
+ _VALID_RESOLVERS = ("error", "weak", "zeros", "ones", "random")
37
+ _VALID_RESOLVERS_ERR_MSG = (
38
+ "Valid values are 'error', 'weak', 'zeros', 'ones', or 'random'"
39
+ )
40
+
41
+
42
+ @lru_cache(maxsize=None)
43
+ def get_str_resolver(resolver: ResolverLiteral) -> Callable[[str], str]:
44
+ if resolver not in _VALID_RESOLVERS:
45
+ raise ValueError(f"Invalid resolver: {resolver!r}. {_VALID_RESOLVERS_ERR_MSG}")
46
+
47
+ resolve_table = _resolve_tables[resolver]
48
+
49
+ def resolve_func(value: str) -> str:
50
+ return value.translate(resolve_table)
51
+
52
+ return resolve_func
53
+
54
+
55
+ def _init() -> Union[Callable[[str], str], None]:
56
+ _envvar = os.getenv("COCOTB_RESOLVE_X", None)
57
+
58
+ # no resolver
59
+ if _envvar is None:
60
+ return None
61
+
62
+ # backwards compatibility
63
+ resolver = _envvar.strip().lower()
64
+ if resolver == "value_error":
65
+ resolver = "error"
66
+
67
+ # get resolver
68
+ try:
69
+ return get_str_resolver(resolver)
70
+ except ValueError:
71
+ raise ValueError(
72
+ f"Invalid COCOTB_RESOLVE_X value: {_envvar!r}. {_VALID_RESOLVERS_ERR_MSG}"
73
+ ) from None
74
+
75
+
76
+ RESOLVE_X: Final = _init()