cocotb 2.0.1__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.
- cocotb/_ANSI.py +65 -0
- cocotb/__init__.py +127 -0
- cocotb/_base_triggers.py +515 -0
- cocotb/_bridge.py +186 -0
- cocotb/_decorators.py +515 -0
- cocotb/_deprecation.py +36 -0
- cocotb/_exceptions.py +7 -0
- cocotb/_extended_awaitables.py +419 -0
- cocotb/_gpi_triggers.py +385 -0
- cocotb/_init.py +301 -0
- cocotb/_outcomes.py +54 -0
- cocotb/_profiling.py +46 -0
- cocotb/_py_compat.py +150 -0
- cocotb/_scheduler.py +448 -0
- cocotb/_test.py +248 -0
- cocotb/_test_factory.py +312 -0
- cocotb/_test_functions.py +42 -0
- cocotb/_typing.py +7 -0
- cocotb/_utils.py +274 -0
- cocotb/_version.py +4 -0
- cocotb/_xunit_reporter.py +103 -0
- cocotb/clock.py +419 -0
- cocotb/debug.py +24 -0
- cocotb/handle.py +1752 -0
- cocotb/libs/cocotb.dll +0 -0
- cocotb/libs/cocotb.exp +0 -0
- cocotb/libs/cocotb.lib +0 -0
- cocotb/libs/cocotbfli_modelsim.dll +0 -0
- cocotb/libs/cocotbfli_modelsim.exp +0 -0
- cocotb/libs/cocotbfli_modelsim.lib +0 -0
- cocotb/libs/cocotbutils.dll +0 -0
- cocotb/libs/cocotbutils.exp +0 -0
- cocotb/libs/cocotbutils.lib +0 -0
- cocotb/libs/cocotbvhpi_aldec.dll +0 -0
- cocotb/libs/cocotbvhpi_aldec.exp +0 -0
- cocotb/libs/cocotbvhpi_aldec.lib +0 -0
- cocotb/libs/cocotbvhpi_modelsim.dll +0 -0
- cocotb/libs/cocotbvhpi_modelsim.exp +0 -0
- cocotb/libs/cocotbvhpi_modelsim.lib +0 -0
- cocotb/libs/cocotbvhpi_nvc.dll +0 -0
- cocotb/libs/cocotbvhpi_nvc.exp +0 -0
- cocotb/libs/cocotbvhpi_nvc.lib +0 -0
- cocotb/libs/cocotbvpi_aldec.dll +0 -0
- cocotb/libs/cocotbvpi_aldec.exp +0 -0
- cocotb/libs/cocotbvpi_aldec.lib +0 -0
- cocotb/libs/cocotbvpi_ghdl.dll +0 -0
- cocotb/libs/cocotbvpi_ghdl.exp +0 -0
- cocotb/libs/cocotbvpi_ghdl.lib +0 -0
- cocotb/libs/cocotbvpi_icarus.exp +0 -0
- cocotb/libs/cocotbvpi_icarus.lib +0 -0
- cocotb/libs/cocotbvpi_icarus.vpl +0 -0
- cocotb/libs/cocotbvpi_modelsim.dll +0 -0
- cocotb/libs/cocotbvpi_modelsim.exp +0 -0
- cocotb/libs/cocotbvpi_modelsim.lib +0 -0
- cocotb/libs/embed.dll +0 -0
- cocotb/libs/embed.exp +0 -0
- cocotb/libs/embed.lib +0 -0
- cocotb/libs/gpi.dll +0 -0
- cocotb/libs/gpi.exp +0 -0
- cocotb/libs/gpi.lib +0 -0
- cocotb/libs/gpilog.dll +0 -0
- cocotb/libs/gpilog.exp +0 -0
- cocotb/libs/gpilog.lib +0 -0
- cocotb/libs/pygpilog.dll +0 -0
- cocotb/libs/pygpilog.exp +0 -0
- cocotb/libs/pygpilog.lib +0 -0
- cocotb/logging.py +417 -0
- cocotb/py.typed +0 -0
- cocotb/queue.py +235 -0
- cocotb/regression.py +900 -0
- cocotb/result.py +38 -0
- cocotb/share/def/.gitignore +2 -0
- cocotb/share/def/README.md +4 -0
- cocotb/share/def/aldec.def +61 -0
- cocotb/share/def/aldec.exp +0 -0
- cocotb/share/def/aldec.lib +0 -0
- cocotb/share/def/ghdl.def +43 -0
- cocotb/share/def/ghdl.exp +0 -0
- cocotb/share/def/ghdl.lib +0 -0
- cocotb/share/def/icarus.def +43 -0
- cocotb/share/def/icarus.exp +0 -0
- cocotb/share/def/icarus.lib +0 -0
- cocotb/share/def/modelsim.def +138 -0
- cocotb/share/def/modelsim.exp +0 -0
- cocotb/share/def/modelsim.lib +0 -0
- cocotb/share/def/nvcvhpi.def +18 -0
- cocotb/share/def/nvcvhpi.exp +0 -0
- cocotb/share/def/nvcvhpi.lib +0 -0
- cocotb/share/include/cocotb_utils.h +70 -0
- cocotb/share/include/embed.h +33 -0
- cocotb/share/include/exports.h +20 -0
- cocotb/share/include/gpi.h +459 -0
- cocotb/share/include/gpi_logging.h +291 -0
- cocotb/share/include/py_gpi_logging.h +33 -0
- cocotb/share/include/vhpi_user_ext.h +26 -0
- cocotb/share/include/vpi_user_ext.h +33 -0
- cocotb/share/lib/verilator/verilator.cpp +209 -0
- cocotb/simtime.py +238 -0
- cocotb/simulator.cp38-win32.exp +0 -0
- cocotb/simulator.cp38-win32.lib +0 -0
- cocotb/simulator.cp38-win32.pyd +0 -0
- cocotb/simulator.cp38-win32.pyd.2.config +8 -0
- cocotb/simulator.pyi +107 -0
- cocotb/task.py +590 -0
- cocotb/triggers.py +67 -0
- cocotb/types/__init__.py +31 -0
- cocotb/types/_abstract_array.py +151 -0
- cocotb/types/_array.py +297 -0
- cocotb/types/_indexing.py +17 -0
- cocotb/types/_logic.py +333 -0
- cocotb/types/_logic_array.py +884 -0
- cocotb/types/_range.py +197 -0
- cocotb/types/_resolve.py +76 -0
- cocotb/utils.py +110 -0
- cocotb-2.0.1.dist-info/LICENSE +29 -0
- cocotb-2.0.1.dist-info/METADATA +44 -0
- cocotb-2.0.1.dist-info/RECORD +152 -0
- cocotb-2.0.1.dist-info/WHEEL +5 -0
- cocotb-2.0.1.dist-info/entry_points.txt +2 -0
- cocotb-2.0.1.dist-info/top_level.txt +18 -0
- cocotb_tools/__init__.py +0 -0
- cocotb_tools/_coverage.py +33 -0
- cocotb_tools/_vendor/__init__.py +3 -0
- cocotb_tools/_vendor/distutils_version.py +346 -0
- cocotb_tools/check_results.py +65 -0
- cocotb_tools/combine_results.py +152 -0
- cocotb_tools/config.py +242 -0
- cocotb_tools/ipython_support.py +99 -0
- cocotb_tools/makefiles/Makefile.deprecations +27 -0
- cocotb_tools/makefiles/Makefile.inc +198 -0
- cocotb_tools/makefiles/Makefile.sim +96 -0
- cocotb_tools/makefiles/simulators/Makefile.activehdl +72 -0
- cocotb_tools/makefiles/simulators/Makefile.cvc +61 -0
- cocotb_tools/makefiles/simulators/Makefile.dsim +39 -0
- cocotb_tools/makefiles/simulators/Makefile.ghdl +84 -0
- cocotb_tools/makefiles/simulators/Makefile.icarus +80 -0
- cocotb_tools/makefiles/simulators/Makefile.ius +93 -0
- cocotb_tools/makefiles/simulators/Makefile.modelsim +9 -0
- cocotb_tools/makefiles/simulators/Makefile.nvc +60 -0
- cocotb_tools/makefiles/simulators/Makefile.questa +29 -0
- cocotb_tools/makefiles/simulators/Makefile.questa-compat +143 -0
- cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun +149 -0
- cocotb_tools/makefiles/simulators/Makefile.riviera +144 -0
- cocotb_tools/makefiles/simulators/Makefile.vcs +65 -0
- cocotb_tools/makefiles/simulators/Makefile.verilator +79 -0
- cocotb_tools/makefiles/simulators/Makefile.xcelium +104 -0
- cocotb_tools/py.typed +0 -0
- cocotb_tools/runner.py +2001 -0
- cocotb_tools/sim_versions.py +140 -0
- pygpi/__init__.py +0 -0
- pygpi/entry.py +42 -0
- pygpi/py.typed +0 -0
cocotb/queue.py
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Copyright cocotb contributors
|
|
2
|
+
# Licensed under the Revised BSD License, see LICENSE for details.
|
|
3
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
import asyncio.queues
|
|
5
|
+
import collections
|
|
6
|
+
import heapq
|
|
7
|
+
from abc import abstractmethod
|
|
8
|
+
from typing import TYPE_CHECKING, Deque, Generic, List, Tuple, TypeVar
|
|
9
|
+
|
|
10
|
+
import cocotb
|
|
11
|
+
from cocotb._utils import pointer_str
|
|
12
|
+
from cocotb.task import Task
|
|
13
|
+
from cocotb.triggers import Event
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from typing import Protocol, Self
|
|
17
|
+
|
|
18
|
+
class SupportsRichComparison(Protocol):
|
|
19
|
+
def __eq__(self, other: object) -> bool: ...
|
|
20
|
+
def __lt__(self, other: Self) -> bool: ...
|
|
21
|
+
def __le__(self, other: Self) -> bool: ...
|
|
22
|
+
def __gt__(self, other: Self) -> bool: ...
|
|
23
|
+
def __ge__(self, other: Self) -> bool: ...
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
__all__ = (
|
|
27
|
+
"AbstractQueue",
|
|
28
|
+
"LifoQueue",
|
|
29
|
+
"PriorityQueue",
|
|
30
|
+
"Queue",
|
|
31
|
+
"QueueEmpty",
|
|
32
|
+
"QueueFull",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class QueueFull(asyncio.queues.QueueFull):
|
|
37
|
+
"""Raised when the :meth:`Queue.put_nowait()` method is called on a full :class:`Queue`."""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class QueueEmpty(asyncio.queues.QueueEmpty):
|
|
41
|
+
"""Raised when the :meth:`Queue.get_nowait()` method is called on an empty :class:`Queue`."""
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
T = TypeVar("T")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class AbstractQueue(Generic[T]):
|
|
48
|
+
"""A queue, useful for coordinating producer and consumer coroutines.
|
|
49
|
+
|
|
50
|
+
If *maxsize* is less than or equal to 0, the queue size is infinite. If it
|
|
51
|
+
is an integer greater than 0, then :meth:`put` will block when the queue
|
|
52
|
+
reaches *maxsize*, until an item is removed by :meth:`get`.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def __init__(self, maxsize: int = 0) -> None:
|
|
56
|
+
self._maxsize: int = maxsize
|
|
57
|
+
self._getters: Deque[Tuple[Event, Task[object]]] = collections.deque()
|
|
58
|
+
self._putters: Deque[Tuple[Event, Task[object]]] = collections.deque()
|
|
59
|
+
|
|
60
|
+
@abstractmethod
|
|
61
|
+
def _get(self) -> T:
|
|
62
|
+
"""Remove and return the next element from the queue."""
|
|
63
|
+
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def _put(self, item: T) -> None:
|
|
66
|
+
"""Place a new element on the queue."""
|
|
67
|
+
|
|
68
|
+
@abstractmethod
|
|
69
|
+
def _size(self) -> int:
|
|
70
|
+
"""Return the number of elements in the queue."""
|
|
71
|
+
|
|
72
|
+
@abstractmethod
|
|
73
|
+
def _repr(self) -> str:
|
|
74
|
+
"""Return a string representation of the state of the queue."""
|
|
75
|
+
|
|
76
|
+
def _wakeup_next(self, waiters: Deque[Tuple[Event, Task[object]]]) -> None:
|
|
77
|
+
while waiters:
|
|
78
|
+
event, task = waiters.popleft()
|
|
79
|
+
if not task.done():
|
|
80
|
+
event.set()
|
|
81
|
+
break
|
|
82
|
+
|
|
83
|
+
def __repr__(self) -> str:
|
|
84
|
+
return f"<{type(self).__name__} {self._format()} at {pointer_str(self)}>"
|
|
85
|
+
|
|
86
|
+
def __str__(self) -> str:
|
|
87
|
+
return f"<{type(self).__name__} {self._format()}>"
|
|
88
|
+
|
|
89
|
+
def _format(self) -> str:
|
|
90
|
+
result = f"maxsize={self._maxsize!r}"
|
|
91
|
+
if getattr(self, "_queue", None):
|
|
92
|
+
result += f" _queue={self._repr()}"
|
|
93
|
+
if self._getters:
|
|
94
|
+
result += f" _getters[{len(self._getters)}]"
|
|
95
|
+
if self._putters:
|
|
96
|
+
result += f" _putters[{len(self._putters)}]"
|
|
97
|
+
return result
|
|
98
|
+
|
|
99
|
+
def qsize(self) -> int:
|
|
100
|
+
"""Number of items in the queue."""
|
|
101
|
+
return self._size()
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def maxsize(self) -> int:
|
|
105
|
+
"""Number of items allowed in the queue."""
|
|
106
|
+
return self._maxsize
|
|
107
|
+
|
|
108
|
+
def empty(self) -> bool:
|
|
109
|
+
"""Return ``True`` if the queue is empty, ``False`` otherwise."""
|
|
110
|
+
return self._size() == 0
|
|
111
|
+
|
|
112
|
+
def full(self) -> bool:
|
|
113
|
+
"""Return ``True`` if there are :meth:`maxsize` items in the queue.
|
|
114
|
+
|
|
115
|
+
.. note::
|
|
116
|
+
If the Queue was initialized with ``maxsize=0`` (the default), then
|
|
117
|
+
:meth:`full` is never ``True``.
|
|
118
|
+
"""
|
|
119
|
+
if self._maxsize <= 0:
|
|
120
|
+
return False
|
|
121
|
+
else:
|
|
122
|
+
return self.qsize() >= self._maxsize
|
|
123
|
+
|
|
124
|
+
async def put(self, item: T) -> None:
|
|
125
|
+
"""Put an *item* into the queue.
|
|
126
|
+
|
|
127
|
+
If the queue is full, wait until a free
|
|
128
|
+
slot is available before adding the item.
|
|
129
|
+
"""
|
|
130
|
+
while self.full():
|
|
131
|
+
event = Event()
|
|
132
|
+
self._putters.append((event, cocotb.task.current_task()))
|
|
133
|
+
await event.wait()
|
|
134
|
+
self.put_nowait(item)
|
|
135
|
+
|
|
136
|
+
def put_nowait(self, item: T) -> None:
|
|
137
|
+
"""Put an *item* into the queue without blocking.
|
|
138
|
+
|
|
139
|
+
If no free slot is immediately available, raise :exc:`~cocotb.queue.QueueFull`.
|
|
140
|
+
"""
|
|
141
|
+
if self.full():
|
|
142
|
+
raise QueueFull()
|
|
143
|
+
self._put(item)
|
|
144
|
+
self._wakeup_next(self._getters)
|
|
145
|
+
|
|
146
|
+
async def get(self) -> T:
|
|
147
|
+
"""Remove and return an item from the queue.
|
|
148
|
+
|
|
149
|
+
If the queue is empty, wait until an item is available.
|
|
150
|
+
"""
|
|
151
|
+
while self.empty():
|
|
152
|
+
event = Event()
|
|
153
|
+
self._getters.append((event, cocotb.task.current_task()))
|
|
154
|
+
await event.wait()
|
|
155
|
+
return self.get_nowait()
|
|
156
|
+
|
|
157
|
+
def get_nowait(self) -> T:
|
|
158
|
+
"""Remove and return an item from the queue.
|
|
159
|
+
|
|
160
|
+
Return an item if one is immediately available, else raise
|
|
161
|
+
:exc:`~cocotb.queue.QueueEmpty`.
|
|
162
|
+
"""
|
|
163
|
+
if self.empty():
|
|
164
|
+
raise QueueEmpty()
|
|
165
|
+
item = self._get()
|
|
166
|
+
self._wakeup_next(self._putters)
|
|
167
|
+
return item
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class Queue(AbstractQueue[T]):
|
|
171
|
+
"""A subclass of :class:`AbstractQueue`; retrieves oldest entries first (FIFO)."""
|
|
172
|
+
|
|
173
|
+
def __init__(self, maxsize: int = 0) -> None:
|
|
174
|
+
super().__init__(maxsize)
|
|
175
|
+
self._queue: Deque[T] = collections.deque()
|
|
176
|
+
|
|
177
|
+
def _put(self, item: T) -> None:
|
|
178
|
+
self._queue.append(item)
|
|
179
|
+
|
|
180
|
+
def _get(self) -> T:
|
|
181
|
+
return self._queue.popleft()
|
|
182
|
+
|
|
183
|
+
def _size(self) -> int:
|
|
184
|
+
return len(self._queue)
|
|
185
|
+
|
|
186
|
+
def _repr(self) -> str:
|
|
187
|
+
return repr(self._queue)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
SupportsRichComparisonT = TypeVar(
|
|
191
|
+
"SupportsRichComparisonT", bound="SupportsRichComparison"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class PriorityQueue(AbstractQueue[SupportsRichComparisonT]):
|
|
196
|
+
r"""A subclass of :class:`AbstractQueue`; retrieves entries in priority order (smallest item first).
|
|
197
|
+
|
|
198
|
+
Entries are typically tuples of the form ``(priority number, data)``.
|
|
199
|
+
"""
|
|
200
|
+
|
|
201
|
+
def __init__(self, maxsize: int = 0) -> None:
|
|
202
|
+
super().__init__(maxsize)
|
|
203
|
+
self._queue: List[SupportsRichComparisonT] = []
|
|
204
|
+
|
|
205
|
+
def _put(self, item: SupportsRichComparisonT) -> None:
|
|
206
|
+
heapq.heappush(self._queue, item)
|
|
207
|
+
|
|
208
|
+
def _get(self) -> SupportsRichComparisonT:
|
|
209
|
+
return heapq.heappop(self._queue)
|
|
210
|
+
|
|
211
|
+
def _size(self) -> int:
|
|
212
|
+
return len(self._queue)
|
|
213
|
+
|
|
214
|
+
def _repr(self) -> str:
|
|
215
|
+
return repr(self._queue)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
class LifoQueue(AbstractQueue[T]):
|
|
219
|
+
"""A subclass of :class:`AbstractQueue`; retrieves most recently added entries first (LIFO)."""
|
|
220
|
+
|
|
221
|
+
def __init__(self, maxsize: int = 0) -> None:
|
|
222
|
+
super().__init__(maxsize)
|
|
223
|
+
self._queue: Deque[T] = collections.deque()
|
|
224
|
+
|
|
225
|
+
def _put(self, item: T) -> None:
|
|
226
|
+
self._queue.append(item)
|
|
227
|
+
|
|
228
|
+
def _get(self) -> T:
|
|
229
|
+
return self._queue.pop()
|
|
230
|
+
|
|
231
|
+
def _size(self) -> int:
|
|
232
|
+
return len(self._queue)
|
|
233
|
+
|
|
234
|
+
def _repr(self) -> str:
|
|
235
|
+
return repr(self._queue)
|