cocotb 1.9.2__cp37-cp37m-win_amd64.whl → 2.0.0rc2__cp37-cp37m-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 (157) 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.cp37-win_amd64.exp +0 -0
  86. cocotb/simulator.cp37-win_amd64.lib +0 -0
  87. cocotb/simulator.cp37-win_amd64.pyd +0 -0
  88. cocotb/task.py +478 -213
  89. cocotb/triggers.py +55 -1092
  90. cocotb/types/__init__.py +28 -47
  91. cocotb/types/_abstract_array.py +151 -0
  92. cocotb/types/_array.py +295 -0
  93. cocotb/types/_indexing.py +17 -0
  94. cocotb/types/_logic.py +333 -0
  95. cocotb/types/_logic_array.py +868 -0
  96. cocotb/types/{range.py → _range.py} +47 -48
  97. cocotb/types/_resolve.py +76 -0
  98. cocotb/utils.py +58 -646
  99. {cocotb-1.9.2.dist-info → cocotb-2.0.0rc2.dist-info}/LICENSE +1 -0
  100. cocotb-2.0.0rc2.dist-info/METADATA +46 -0
  101. cocotb-2.0.0rc2.dist-info/RECORD +142 -0
  102. cocotb-2.0.0rc2.dist-info/entry_points.txt +2 -0
  103. {cocotb-1.9.2.dist-info → cocotb-2.0.0rc2.dist-info}/top_level.txt +1 -0
  104. cocotb_tools/_coverage.py +33 -0
  105. cocotb_tools/_vendor/__init__.py +3 -0
  106. cocotb_tools/check_results.py +65 -0
  107. cocotb_tools/combine_results.py +152 -0
  108. cocotb_tools/config.py +241 -0
  109. {cocotb → cocotb_tools}/ipython_support.py +29 -22
  110. cocotb_tools/makefiles/Makefile.deprecations +27 -0
  111. {cocotb/share → cocotb_tools}/makefiles/Makefile.inc +77 -55
  112. {cocotb/share → cocotb_tools}/makefiles/Makefile.sim +16 -33
  113. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.activehdl +9 -16
  114. cocotb_tools/makefiles/simulators/Makefile.cvc +61 -0
  115. cocotb_tools/makefiles/simulators/Makefile.dsim +39 -0
  116. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.ghdl +13 -42
  117. cocotb_tools/makefiles/simulators/Makefile.icarus +80 -0
  118. cocotb_tools/makefiles/simulators/Makefile.ius +93 -0
  119. cocotb_tools/makefiles/simulators/Makefile.modelsim +9 -0
  120. cocotb_tools/makefiles/simulators/Makefile.nvc +60 -0
  121. cocotb_tools/makefiles/simulators/Makefile.questa +29 -0
  122. cocotb/share/makefiles/simulators/Makefile.questa → cocotb_tools/makefiles/simulators/Makefile.questa-compat +26 -54
  123. cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun +149 -0
  124. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.riviera +17 -56
  125. cocotb_tools/makefiles/simulators/Makefile.vcs +65 -0
  126. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.verilator +15 -22
  127. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.xcelium +20 -52
  128. cocotb_tools/runner.py +1868 -0
  129. cocotb/_sim_versions.py → cocotb_tools/sim_versions.py +16 -21
  130. pygpi/entry.py +34 -18
  131. cocotb/ANSI.py +0 -92
  132. cocotb/binary.py +0 -858
  133. cocotb/config.py +0 -289
  134. cocotb/decorators.py +0 -332
  135. cocotb/log.py +0 -303
  136. cocotb/memdebug.py +0 -35
  137. cocotb/outcomes.py +0 -56
  138. cocotb/runner.py +0 -1400
  139. cocotb/scheduler.py +0 -1099
  140. cocotb/share/makefiles/Makefile.deprecations +0 -12
  141. cocotb/share/makefiles/simulators/Makefile.cvc +0 -94
  142. cocotb/share/makefiles/simulators/Makefile.icarus +0 -111
  143. cocotb/share/makefiles/simulators/Makefile.ius +0 -125
  144. cocotb/share/makefiles/simulators/Makefile.modelsim +0 -32
  145. cocotb/share/makefiles/simulators/Makefile.nvc +0 -64
  146. cocotb/share/makefiles/simulators/Makefile.vcs +0 -98
  147. cocotb/types/array.py +0 -309
  148. cocotb/types/logic.py +0 -292
  149. cocotb/types/logic_array.py +0 -298
  150. cocotb/wavedrom.py +0 -199
  151. cocotb/xunit_reporter.py +0 -80
  152. cocotb-1.9.2.dist-info/METADATA +0 -168
  153. cocotb-1.9.2.dist-info/RECORD +0 -121
  154. cocotb-1.9.2.dist-info/entry_points.txt +0 -2
  155. {cocotb-1.9.2.dist-info → cocotb-2.0.0rc2.dist-info}/WHEEL +0 -0
  156. {cocotb/_vendor → cocotb_tools}/__init__.py +0 -0
  157. {cocotb → cocotb_tools}/_vendor/distutils_version.py +0 -0
cocotb/log.py DELETED
@@ -1,303 +0,0 @@
1
- # Copyright (c) 2013, 2018 Potential Ventures Ltd
2
- # Copyright (c) 2013 SolarFlare Communications Inc
3
- # All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without
6
- # modification, are permitted provided that the following conditions are met:
7
- # * Redistributions of source code must retain the above copyright
8
- # notice, this list of conditions and the following disclaimer.
9
- # * Redistributions in binary form must reproduce the above copyright
10
- # notice, this list of conditions and the following disclaimer in the
11
- # documentation and/or other materials provided with the distribution.
12
- # * Neither the name of Potential Ventures Ltd,
13
- # SolarFlare Communications Inc nor the
14
- # names of its contributors may be used to endorse or promote products
15
- # derived from this software without specific prior written permission.
16
- #
17
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- # DISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY
21
- # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
- # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
- # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
- # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
-
28
- """
29
- Everything related to logging
30
- """
31
-
32
- import logging
33
- import os
34
- import sys
35
- import typing
36
- import warnings
37
-
38
- import cocotb.ANSI as ANSI
39
- from cocotb import simulator
40
- from cocotb.utils import get_sim_time, get_time_from_sim_steps, want_color_output
41
-
42
- try:
43
- _suppress = int(os.environ.get("COCOTB_REDUCED_LOG_FMT", "1"))
44
- except ValueError:
45
- _suppress = 1
46
-
47
- # Column alignment
48
- _LEVEL_CHARS = len("CRITICAL")
49
- _RECORD_CHARS = 34
50
- _FILENAME_CHARS = 20
51
- _LINENO_CHARS = 4
52
- _FUNCNAME_CHARS = 31
53
-
54
- # Custom log level
55
- logging.TRACE = 5
56
- logging.addLevelName(5, "TRACE")
57
-
58
- # Default log level if not overwritten by the user.
59
- _COCOTB_LOG_LEVEL_DEFAULT = "INFO"
60
-
61
-
62
- def default_config():
63
- """Apply the default cocotb log formatting to the root logger.
64
-
65
- This hooks up the logger to write to stdout, using either
66
- :class:`SimColourLogFormatter` or :class:`SimLogFormatter` depending
67
- on whether colored output is requested. It also adds a
68
- :class:`SimTimeContextFilter` filter so that
69
- :attr:`~logging.LogRecord.created_sim_time` is available to the formatter.
70
-
71
- The logging level for cocotb logs is set based on the
72
- :envvar:`COCOTB_LOG_LEVEL` environment variable, which defaults to ``INFO``.
73
-
74
- If desired, this logging configuration can be overwritten by calling
75
- ``logging.basicConfig(..., force=True)`` (in Python 3.8 onwards), or by
76
- manually resetting the root logger instance.
77
- An example of this can be found in the section on :ref:`rotating-logger`.
78
-
79
- .. versionadded:: 1.4
80
- """
81
- # construct an appropriate handler
82
- hdlr = logging.StreamHandler(sys.stdout)
83
- hdlr.addFilter(SimTimeContextFilter())
84
- if want_color_output():
85
- hdlr.setFormatter(SimColourLogFormatter())
86
- else:
87
- hdlr.setFormatter(SimLogFormatter())
88
-
89
- logging.setLoggerClass(SimBaseLog) # For backwards compatibility
90
- logging.basicConfig()
91
- logging.getLogger().handlers = [hdlr] # overwrite default handlers
92
-
93
- # apply level settings for cocotb
94
- log = logging.getLogger("cocotb")
95
-
96
- try:
97
- # All log levels are upper case, convert the user input for convenience.
98
- level = os.environ["COCOTB_LOG_LEVEL"].upper()
99
- except KeyError:
100
- level = _COCOTB_LOG_LEVEL_DEFAULT
101
-
102
- try:
103
- log.setLevel(level)
104
- except ValueError:
105
- valid_levels = ("CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "TRACE")
106
- raise ValueError(
107
- "Invalid log level %r passed through the "
108
- "COCOTB_LOG_LEVEL environment variable. Valid log "
109
- "levels: %s" % (level, ", ".join(valid_levels))
110
- )
111
-
112
- # Notify GPI of log level, which it uses as an optimization to avoid
113
- # calling into Python.
114
- logging.getLogger("gpi").setLevel(level)
115
-
116
-
117
- class SimBaseLog(logging.getLoggerClass()):
118
- """This class only exists for backwards compatibility"""
119
-
120
- @property
121
- def logger(self):
122
- warnings.warn(
123
- "the .logger attribute should not be used now that `SimLog` "
124
- "returns a native logger instance directly.",
125
- DeprecationWarning,
126
- stacklevel=2,
127
- )
128
- return self
129
-
130
- @property
131
- def colour(self):
132
- warnings.warn(
133
- "the .colour attribute may be removed in future, use the "
134
- "equivalent `cocotb.utils.want_color_output()` instead",
135
- DeprecationWarning,
136
- stacklevel=2,
137
- )
138
- return want_color_output()
139
-
140
- def setLevel(self, level: typing.Union[int, str]) -> None:
141
- super().setLevel(level)
142
- if self.name == "gpi":
143
- simulator.log_level(self.getEffectiveLevel())
144
-
145
-
146
- # this used to be a class, hence the unusual capitalization
147
- def SimLog(name, ident=None):
148
- """Like logging.getLogger, but append a numeric identifier to the name"""
149
- if ident is not None:
150
- name = f"{name}.0x{ident:x}"
151
- return logging.getLogger(name)
152
-
153
-
154
- class SimTimeContextFilter(logging.Filter):
155
- """
156
- A filter to inject simulator times into the log records.
157
-
158
- This uses the approach described in the :ref:`Python logging cookbook <python:filters-contextual>`.
159
-
160
- This adds the :attr:`~logging.LogRecord.created_sim_time` attribute.
161
-
162
- .. versionadded:: 1.4
163
- """
164
-
165
- # needed to make our docs render well
166
- def __init__(self):
167
- """"""
168
- super().__init__()
169
-
170
- def filter(self, record):
171
- try:
172
- record.created_sim_time = get_sim_time()
173
- except RecursionError:
174
- # get_sim_time may try to log - if that happens, we can't
175
- # attach a simulator time to this message.
176
- record.created_sim_time = None
177
- return True
178
-
179
-
180
- class SimLogFormatter(logging.Formatter):
181
- """Log formatter to provide consistent log message handling.
182
-
183
- This will only add simulator timestamps if the handler object this
184
- formatter is attached to has a :class:`SimTimeContextFilter` filter
185
- attached, which cocotb ensures by default.
186
- """
187
-
188
- # Removes the arguments from the base class. Docstring needed to make
189
- # sphinx happy.
190
- def __init__(self):
191
- """Takes no arguments."""
192
- super().__init__()
193
-
194
- # Justify and truncate
195
- @staticmethod
196
- def ljust(string, chars):
197
- if len(string) > chars:
198
- return ".." + string[(chars - 2) * -1 :]
199
- return string.ljust(chars)
200
-
201
- @staticmethod
202
- def rjust(string, chars):
203
- if len(string) > chars:
204
- return ".." + string[(chars - 2) * -1 :]
205
- return string.rjust(chars)
206
-
207
- def _format(self, level, record, msg, coloured=False):
208
- sim_time = getattr(record, "created_sim_time", None)
209
- if sim_time is None:
210
- sim_time_str = " -.--ns"
211
- else:
212
- time_ns = get_time_from_sim_steps(sim_time, "ns")
213
- sim_time_str = f"{time_ns:6.2f}ns"
214
- prefix = (
215
- sim_time_str.rjust(11)
216
- + " "
217
- + level
218
- + " "
219
- + self.ljust(record.name, _RECORD_CHARS)
220
- + " "
221
- )
222
- if not _suppress:
223
- prefix += (
224
- self.rjust(os.path.split(record.filename)[1], _FILENAME_CHARS)
225
- + ":"
226
- + self.ljust(str(record.lineno), _LINENO_CHARS)
227
- + " in "
228
- + self.ljust(str(record.funcName), _FUNCNAME_CHARS)
229
- + " "
230
- )
231
-
232
- # these lines are copied from the builtin logger
233
- if record.exc_info:
234
- # Cache the traceback text to avoid converting it multiple times
235
- # (it's constant anyway)
236
- if not record.exc_text:
237
- record.exc_text = self.formatException(record.exc_info)
238
- if record.exc_text:
239
- if msg[-1:] != "\n":
240
- msg = msg + "\n"
241
- msg = msg + record.exc_text
242
-
243
- prefix_len = len(prefix)
244
- if coloured:
245
- prefix_len -= len(level) - _LEVEL_CHARS
246
- pad = "\n" + " " * (prefix_len)
247
- return prefix + pad.join(msg.split("\n"))
248
-
249
- def format(self, record):
250
- """Prettify the log output, annotate with simulation time"""
251
-
252
- msg = record.getMessage()
253
- level = record.levelname.ljust(_LEVEL_CHARS)
254
-
255
- return self._format(level, record, msg)
256
-
257
-
258
- class SimColourLogFormatter(SimLogFormatter):
259
- """Log formatter to provide consistent log message handling."""
260
-
261
- loglevel2colour = {
262
- logging.TRACE: "%s",
263
- logging.DEBUG: "%s",
264
- logging.INFO: "%s",
265
- logging.WARNING: ANSI.COLOR_WARNING + "%s" + ANSI.COLOR_DEFAULT,
266
- logging.ERROR: ANSI.COLOR_ERROR + "%s" + ANSI.COLOR_DEFAULT,
267
- logging.CRITICAL: ANSI.COLOR_CRITICAL + "%s" + ANSI.COLOR_DEFAULT,
268
- }
269
-
270
- def format(self, record):
271
- """Prettify the log output, annotate with simulation time"""
272
-
273
- msg = record.getMessage()
274
-
275
- # Need to colour each line in case coloring is applied in the message
276
- msg = "\n".join(
277
- [
278
- SimColourLogFormatter.loglevel2colour.get(record.levelno, "%s") % line
279
- for line in msg.split("\n")
280
- ]
281
- )
282
- level = SimColourLogFormatter.loglevel2colour.get(
283
- record.levelno, "%s"
284
- ) % record.levelname.ljust(_LEVEL_CHARS)
285
-
286
- return self._format(level, record, msg, coloured=True)
287
-
288
-
289
- def _filter_from_c(logger_name, level):
290
- return logging.getLogger(logger_name).isEnabledFor(level)
291
-
292
-
293
- def _log_from_c(logger_name, level, filename, lineno, msg, function_name):
294
- """
295
- This is for use from the C world, and allows us to insert C stack
296
- information.
297
- """
298
- logger = logging.getLogger(logger_name)
299
- if logger.isEnabledFor(level):
300
- record = logger.makeRecord(
301
- logger.name, level, filename, lineno, msg, None, None, function_name
302
- )
303
- logger.handle(record)
cocotb/memdebug.py DELETED
@@ -1,35 +0,0 @@
1
- # Copyright (c) 2013 Potential Ventures Ltd
2
- # Copyright (c) 2013 SolarFlare Communications Inc
3
- # All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without
6
- # modification, are permitted provided that the following conditions are met:
7
- # * Redistributions of source code must retain the above copyright
8
- # notice, this list of conditions and the following disclaimer.
9
- # * Redistributions in binary form must reproduce the above copyright
10
- # notice, this list of conditions and the following disclaimer in the
11
- # documentation and/or other materials provided with the distribution.
12
- # * Neither the name of Potential Ventures Ltd,
13
- # SolarFlare Communications Inc nor the
14
- # names of its contributors may be used to endorse or promote products
15
- # derived from this software without specific prior written permission.
16
- #
17
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- # DISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY
21
- # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
- # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
- # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
- # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
-
28
- import cherrypy
29
- import dowser
30
-
31
-
32
- def start(port):
33
- cherrypy.tree.mount(dowser.Root())
34
- cherrypy.config.update({"environment": "embedded", "server.socket_port": port})
35
- cherrypy.engine.start()
cocotb/outcomes.py DELETED
@@ -1,56 +0,0 @@
1
- """
2
- Inspired by https://github.com/python-trio/outcome
3
-
4
- An outcome is similar to the builtin `concurrent.futures.Future`
5
- or `asyncio.Future`, but without being tied to a particular task model.
6
- """
7
- import abc
8
-
9
- from cocotb.utils import remove_traceback_frames
10
-
11
-
12
- def capture(fn, *args, **kwargs):
13
- """Obtain an `Outcome` representing the result of a function call"""
14
- try:
15
- return Value(fn(*args, **kwargs))
16
- except BaseException as e:
17
- e = remove_traceback_frames(e, ["capture"])
18
- return Error(e)
19
-
20
-
21
- class Outcome(metaclass=abc.ABCMeta):
22
- @abc.abstractmethod
23
- def send(self, gen):
24
- """Send or throw this outcome into a generator"""
25
-
26
- @abc.abstractmethod
27
- def get(self, gen):
28
- """Get the value of this outcome, or throw its exception"""
29
-
30
-
31
- class Value(Outcome):
32
- def __init__(self, value):
33
- self.value = value
34
-
35
- def send(self, gen):
36
- return gen.send(self.value)
37
-
38
- def get(self):
39
- return self.value
40
-
41
- def __repr__(self):
42
- return f"Value({self.value!r})"
43
-
44
-
45
- class Error(Outcome):
46
- def __init__(self, error):
47
- self.error = error
48
-
49
- def send(self, gen):
50
- return gen.throw(self.error)
51
-
52
- def get(self):
53
- raise self.error
54
-
55
- def __repr__(self):
56
- return f"Error({self.error!r})"