cocotb 1.9.2__cp311-cp311-win32.whl → 2.0.0b1__cp311-cp311-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.cp311-win32.exp +0 -0
  84. cocotb/simulator.cp311-win32.lib +0 -0
  85. cocotb/simulator.cp311-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 +60 -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/licenses}/LICENSE +0 -0
  155. {cocotb → cocotb_tools}/_vendor/distutils_version.py +0 -0
@@ -1,12 +1,13 @@
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
+ from functools import lru_cache
5
+ from typing import Iterator, Sequence, Union, overload
5
6
 
6
- T = typing.TypeVar("T")
7
+ from cocotb._utils import cached_method
7
8
 
8
9
 
9
- class Range(typing.Sequence[int]):
10
+ class Range(Sequence[int]):
10
11
  r"""
11
12
  Variant of :class:`range` with inclusive right bound.
12
13
 
@@ -19,19 +20,19 @@ class Range(typing.Sequence[int]):
19
20
  left and right bounds.
20
21
  Not specifying directionality will cause the directionality to be inferred.
21
22
 
22
- .. code-block:: python3
23
+ .. code-block:: pycon3
23
24
 
24
25
  >>> r = Range(-2, 3)
25
26
  >>> r.left, r.right, len(r)
26
27
  (-2, 3, 6)
27
28
 
28
- >>> s = Range(8, 'downto', 1)
29
+ >>> s = Range(8, "downto", 1)
29
30
  >>> s.left, s.right, len(s)
30
31
  (8, 1, 8)
31
32
 
32
33
  :meth:`from_range` and :meth:`to_range` can be used to convert from and to :class:`range`.
33
34
 
34
- .. code-block:: python3
35
+ .. code-block:: pycon3
35
36
 
36
37
  >>> r = Range(-2, 3)
37
38
  >>> r.to_range()
@@ -41,9 +42,9 @@ class Range(typing.Sequence[int]):
41
42
  "null" ranges occur when a left bound cannot reach a right bound with the given direction.
42
43
  They have a length of 0, but the :attr:`left`, :attr:`right`, and :attr:`direction` values remain as given.
43
44
 
44
- .. code-block:: python3
45
+ .. code-block:: pycon3
45
46
 
46
- >>> r = Range(1, 'to', 0) # no way to count from 1 'to' 0
47
+ >>> r = Range(1, "to", 0) # no way to count from 1 'to' 0
47
48
  >>> r.left, r.direction, r.right
48
49
  (1, 'to', 0)
49
50
  >>> len(r)
@@ -65,25 +66,20 @@ class Range(typing.Sequence[int]):
65
66
  right: rightmost bound of range (inclusive)
66
67
  """
67
68
 
68
- __slots__ = ("_range",)
69
+ @overload
70
+ def __init__(self, left: int, direction: int) -> None: ...
69
71
 
70
- @typing.overload
71
- def __init__(self, left: int, direction: int) -> None:
72
- pass # pragma: no cover
72
+ @overload
73
+ def __init__(self, left: int, direction: str, right: int) -> None: ...
73
74
 
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
75
+ @overload
76
+ def __init__(self, left: int, *, right: int) -> None: ...
81
77
 
82
78
  def __init__(
83
79
  self,
84
80
  left: int,
85
- direction: typing.Union[int, str, None] = None,
86
- right: typing.Union[int, None] = None,
81
+ direction: Union[int, str, None] = None,
82
+ right: Union[int, None] = None,
87
83
  ) -> None:
88
84
  start = left
89
85
  stop: int
@@ -91,12 +87,12 @@ class Range(typing.Sequence[int]):
91
87
  if isinstance(direction, int) and right is None:
92
88
  step = _guess_step(left, direction)
93
89
  stop = direction + step
94
- elif direction is None and isinstance(right, int):
95
- step = _guess_step(left, right)
96
- stop = right + step
97
90
  elif isinstance(direction, str) and isinstance(right, int):
98
91
  step = _direction_to_step(direction)
99
92
  stop = right + step
93
+ elif direction is None and isinstance(right, int):
94
+ step = _guess_step(left, right)
95
+ stop = right + step
100
96
  else:
101
97
  raise TypeError("invalid arguments")
102
98
  self._range = range(start, stop, step)
@@ -111,51 +107,49 @@ class Range(typing.Sequence[int]):
111
107
  )
112
108
 
113
109
  def to_range(self) -> range:
114
- """Convert :class:`Range` to :class:`range`."""
110
+ """Convert Range to :class:`range`."""
115
111
  return self._range
116
112
 
117
113
  @property
118
114
  def left(self) -> int:
119
- """Leftmost value in a range."""
115
+ """Leftmost value in a Range."""
120
116
  return self._range.start
121
117
 
122
118
  @property
123
119
  def direction(self) -> str:
124
- """``'to'`` if values are meant to be ascending, ``'downto'`` otherwise."""
120
+ """``'to'`` if Range is ascending, ``'downto'`` otherwise."""
125
121
  return _step_to_direction(self._range.step)
126
122
 
127
123
  @property
128
124
  def right(self) -> int:
129
- """Rightmost value in a range."""
125
+ """Rightmost value in a Range."""
130
126
  return self._range.stop - self._range.step
131
127
 
132
128
  def __len__(self) -> int:
133
129
  return len(self._range)
134
130
 
135
- @typing.overload
136
- def __getitem__(self, item: int) -> int:
137
- pass # pragma: no cover
131
+ @overload
132
+ def __getitem__(self, item: int) -> int: ...
138
133
 
139
- @typing.overload
140
- def __getitem__(self, item: slice) -> "Range":
141
- pass # pragma: no cover
134
+ @overload
135
+ def __getitem__(self, item: slice) -> "Range": ...
142
136
 
143
- def __getitem__(self, item: typing.Union[int, slice]) -> typing.Union[int, "Range"]:
137
+ def __getitem__(self, item: Union[int, slice]) -> Union[int, "Range"]:
144
138
  if isinstance(item, int):
145
139
  return self._range[item]
146
140
  elif isinstance(item, slice):
147
141
  return type(self).from_range(self._range[item])
148
142
  raise TypeError(
149
- "indices must be integers or slices, not {}".format(type(item).__name__)
143
+ f"indices must be integers or slices, not {type(item).__name__}"
150
144
  )
151
145
 
152
146
  def __contains__(self, item: object) -> bool:
153
147
  return item in self._range
154
148
 
155
- def __iter__(self) -> typing.Iterator[int]:
149
+ def __iter__(self) -> Iterator[int]:
156
150
  return iter(self._range)
157
151
 
158
- def __reversed__(self) -> typing.Iterator[int]:
152
+ def __reversed__(self) -> Iterator[int]:
159
153
  return reversed(self._range)
160
154
 
161
155
  def __eq__(self, other: object) -> bool:
@@ -166,13 +160,10 @@ class Range(typing.Sequence[int]):
166
160
  def __hash__(self) -> int:
167
161
  return hash(self._range)
168
162
 
169
- def count(self, item: int) -> int:
170
- return self._range.count(item)
171
-
172
163
  def __repr__(self) -> str:
173
- return "{}({!r}, {!r}, {!r})".format(
174
- type(self).__qualname__, self.left, self.direction, self.right
175
- )
164
+ return f"{type(self).__qualname__}({self.left!r}, {self.direction!r}, {self.right!r})"
165
+
166
+ index = cached_method(Sequence.index)
176
167
 
177
168
 
178
169
  def _guess_step(left: int, right: int) -> int:
@@ -181,6 +172,7 @@ def _guess_step(left: int, right: int) -> int:
181
172
  return -1
182
173
 
183
174
 
175
+ @lru_cache(maxsize=None)
184
176
  def _direction_to_step(direction: str) -> int:
185
177
  direction = direction.lower()
186
178
  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()