cocotb 1.9.2__cp39-cp39-win_amd64.whl → 2.0.0b1__cp39-cp39-win_amd64.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.cp39-win_amd64.exp +0 -0
  84. cocotb/simulator.cp39-win_amd64.lib +0 -0
  85. cocotb/simulator.cp39-win_amd64.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
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)