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
cocotb/queue.py CHANGED
@@ -4,24 +4,42 @@
4
4
  import asyncio.queues
5
5
  import collections
6
6
  import heapq
7
- from typing import Generic, TypeVar
7
+ from abc import abstractmethod
8
+ from typing import (
9
+ Deque,
10
+ Generic,
11
+ List,
12
+ Tuple,
13
+ TypeVar,
14
+ )
8
15
 
9
16
  import cocotb
10
- from cocotb.triggers import Event, _pointer_str
17
+ from cocotb._utils import pointer_str
18
+ from cocotb.task import Task
19
+ from cocotb.triggers import Event
20
+
21
+ __all__ = (
22
+ "AbstractQueue",
23
+ "LifoQueue",
24
+ "PriorityQueue",
25
+ "Queue",
26
+ "QueueEmpty",
27
+ "QueueFull",
28
+ )
11
29
 
12
30
 
13
31
  class QueueFull(asyncio.queues.QueueFull):
14
- """Raised when the Queue.put_nowait() method is called on a full Queue."""
32
+ """Raised when the :meth:`Queue.put_nowait()` method is called on a full :class:`Queue`."""
15
33
 
16
34
 
17
35
  class QueueEmpty(asyncio.queues.QueueEmpty):
18
- """Raised when the Queue.get_nowait() method is called on a empty Queue."""
36
+ """Raised when the :meth:`Queue.get_nowait()` method is called on an empty :class:`Queue`."""
19
37
 
20
38
 
21
39
  T = TypeVar("T")
22
40
 
23
41
 
24
- class Queue(Generic[T]):
42
+ class AbstractQueue(Generic[T]):
25
43
  """A queue, useful for coordinating producer and consumer coroutines.
26
44
 
27
45
  If *maxsize* is less than or equal to 0, the queue size is infinite. If it
@@ -29,58 +47,53 @@ class Queue(Generic[T]):
29
47
  reaches *maxsize*, until an item is removed by :meth:`get`.
30
48
  """
31
49
 
32
- def __init__(self, maxsize: int = 0):
33
-
34
- self._maxsize = maxsize
35
-
36
- self._finished = Event()
37
- self._finished.set()
50
+ def __init__(self, maxsize: int = 0) -> None:
51
+ self._maxsize: int = maxsize
52
+ self._getters: Deque[Tuple[Event, Task[object]]] = collections.deque()
53
+ self._putters: Deque[Tuple[Event, Task[object]]] = collections.deque()
38
54
 
39
- self._getters = collections.deque()
40
- self._putters = collections.deque()
55
+ @abstractmethod
56
+ def _get(self) -> T:
57
+ """Remove and return the next element from the queue."""
41
58
 
42
- self._init(maxsize)
59
+ @abstractmethod
60
+ def _put(self, item: T) -> None:
61
+ """Place a new element on the queue."""
43
62
 
44
- def _init(self, maxsize):
45
- self._queue = collections.deque()
63
+ @abstractmethod
64
+ def _size(self) -> int:
65
+ """Return the number of elements in the queue."""
46
66
 
47
- def _put(self, item):
48
- self._queue.append(item)
49
-
50
- def _get(self):
51
- return self._queue.popleft()
67
+ @abstractmethod
68
+ def _repr(self) -> str:
69
+ """Return a string representation of the state of the queue."""
52
70
 
53
- def _wakeup_next(self, waiters):
71
+ def _wakeup_next(self, waiters: Deque[Tuple[Event, Task[object]]]) -> None:
54
72
  while waiters:
55
73
  event, task = waiters.popleft()
56
74
  if not task.done():
57
75
  event.set()
58
76
  break
59
77
 
60
- def __repr__(self):
61
- return "<{} {} at {}>".format(
62
- type(self).__name__, self._format(), _pointer_str(self)
63
- )
78
+ def __repr__(self) -> str:
79
+ return f"<{type(self).__name__} {self._format()} at {pointer_str(self)}>"
64
80
 
65
- def __str__(self):
66
- return "<{} {}>".format(type(self).__name__, self._format())
81
+ def __str__(self) -> str:
82
+ return f"<{type(self).__name__} {self._format()}>"
67
83
 
68
- def __class_getitem__(cls, type):
69
- return cls
70
-
71
- def _format(self):
72
- result = "maxsize={}".format(repr(self._maxsize))
84
+ def _format(self) -> str:
85
+ result = f"maxsize={self._maxsize!r}"
73
86
  if getattr(self, "_queue", None):
74
- result += " _queue={}".format(repr(list(self._queue)))
87
+ result += f" _queue={self._repr()}"
75
88
  if self._getters:
76
- result += " _getters[{}]".format(len(self._getters))
89
+ result += f" _getters[{len(self._getters)}]"
77
90
  if self._putters:
78
- result += " _putters[{}]".format(len(self._putters))
91
+ result += f" _putters[{len(self._putters)}]"
79
92
  return result
80
93
 
81
94
  def qsize(self) -> int:
82
95
  """Number of items in the queue."""
83
- return len(self._queue)
96
+ return self._size()
84
97
 
85
98
  @property
86
99
  def maxsize(self) -> int:
@@ -89,7 +102,7 @@ class Queue(Generic[T]):
89
102
 
90
103
  def empty(self) -> bool:
91
104
  """Return ``True`` if the queue is empty, ``False`` otherwise."""
92
- return not self._queue
105
+ return self._size() == 0
93
106
 
94
107
  def full(self) -> bool:
95
108
  """Return ``True`` if there are :meth:`maxsize` items in the queue.
@@ -110,20 +123,19 @@ class Queue(Generic[T]):
110
123
  slot is available before adding the item.
111
124
  """
112
125
  while self.full():
113
- event = Event("{} put".format(type(self).__name__))
114
- self._putters.append((event, cocotb.scheduler._current_task))
126
+ event = Event()
127
+ self._putters.append((event, cocotb.task.current_task()))
115
128
  await event.wait()
116
129
  self.put_nowait(item)
117
130
 
118
131
  def put_nowait(self, item: T) -> None:
119
132
  """Put an *item* into the queue without blocking.
120
133
 
121
- If no free slot is immediately available, raise :exc:`asyncio.QueueFull`.
134
+ If no free slot is immediately available, raise :exc:`~cocotb.queue.QueueFull`.
122
135
  """
123
136
  if self.full():
124
137
  raise QueueFull()
125
138
  self._put(item)
126
- self._finished.clear()
127
139
  self._wakeup_next(self._getters)
128
140
 
129
141
  async def get(self) -> T:
@@ -132,8 +144,8 @@ class Queue(Generic[T]):
132
144
  If the queue is empty, wait until an item is available.
133
145
  """
134
146
  while self.empty():
135
- event = Event("{} get".format(type(self).__name__))
136
- self._getters.append((event, cocotb.scheduler._current_task))
147
+ event = Event()
148
+ self._getters.append((event, cocotb.task.current_task()))
137
149
  await event.wait()
138
150
  return self.get_nowait()
139
151
 
@@ -141,7 +153,7 @@ class Queue(Generic[T]):
141
153
  """Remove and return an item from the queue.
142
154
 
143
155
  Return an item if one is immediately available, else raise
144
- :exc:`asyncio.QueueEmpty`.
156
+ :exc:`~cocotb.queue.QueueEmpty`.
145
157
  """
146
158
  if self.empty():
147
159
  raise QueueEmpty()
@@ -150,30 +162,64 @@ class Queue(Generic[T]):
150
162
  return item
151
163
 
152
164
 
153
- class PriorityQueue(Queue):
154
- r"""A subclass of :class:`Queue`; retrieves entries in priority order (smallest item first).
165
+ class Queue(AbstractQueue[T]):
166
+ """A subclass of :class:`AbstractQueue`; retrieves oldest entries first (FIFO)."""
167
+
168
+ def __init__(self, maxsize: int = 0) -> None:
169
+ super().__init__(maxsize)
170
+ self._queue: Deque[T] = collections.deque()
171
+
172
+ def _put(self, item: T) -> None:
173
+ self._queue.append(item)
174
+
175
+ def _get(self) -> T:
176
+ return self._queue.popleft()
177
+
178
+ def _size(self) -> int:
179
+ return len(self._queue)
180
+
181
+ def _repr(self) -> str:
182
+ return repr(self._queue)
183
+
184
+
185
+ class PriorityQueue(AbstractQueue[T]):
186
+ r"""A subclass of :class:`AbstractQueue`; retrieves entries in priority order (smallest item first).
155
187
 
156
188
  Entries are typically tuples of the form ``(priority number, data)``.
157
189
  """
158
190
 
159
- def _init(self, maxsize):
160
- self._queue = []
191
+ def __init__(self, maxsize: int = 0) -> None:
192
+ super().__init__(maxsize)
193
+ self._queue: List[T] = []
161
194
 
162
- def _put(self, item):
195
+ def _put(self, item: T) -> None:
163
196
  heapq.heappush(self._queue, item)
164
197
 
165
- def _get(self):
198
+ def _get(self) -> T:
166
199
  return heapq.heappop(self._queue)
167
200
 
201
+ def _size(self) -> int:
202
+ return len(self._queue)
203
+
204
+ def _repr(self) -> str:
205
+ return repr(self._queue)
206
+
168
207
 
169
- class LifoQueue(Queue):
170
- """A subclass of :class:`Queue`; retrieves most recently added entries first."""
208
+ class LifoQueue(AbstractQueue[T]):
209
+ """A subclass of :class:`AbstractQueue`; retrieves most recently added entries first (LIFO)."""
171
210
 
172
- def _init(self, maxsize):
173
- self._queue = collections.deque()
211
+ def __init__(self, maxsize: int = 0) -> None:
212
+ super().__init__(maxsize)
213
+ self._queue: Deque[T] = collections.deque()
174
214
 
175
- def _put(self, item):
215
+ def _put(self, item: T) -> None:
176
216
  self._queue.append(item)
177
217
 
178
- def _get(self):
218
+ def _get(self) -> T:
179
219
  return self._queue.pop()
220
+
221
+ def _size(self) -> int:
222
+ return len(self._queue)
223
+
224
+ def _repr(self) -> str:
225
+ return repr(self._queue)