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.
- cocotb/{ANSI.py → _ANSI.py} +5 -25
- cocotb/__init__.py +76 -332
- cocotb/_base_triggers.py +513 -0
- cocotb/_bridge.py +187 -0
- cocotb/_decorators.py +515 -0
- cocotb/_deprecation.py +3 -3
- cocotb/_exceptions.py +7 -0
- cocotb/_extended_awaitables.py +419 -0
- cocotb/_gpi_triggers.py +382 -0
- cocotb/_init.py +295 -0
- cocotb/_outcomes.py +54 -0
- cocotb/_profiling.py +46 -0
- cocotb/_py_compat.py +100 -29
- cocotb/_scheduler.py +454 -0
- cocotb/_test.py +245 -0
- cocotb/_test_factory.py +309 -0
- cocotb/_test_functions.py +42 -0
- cocotb/_typing.py +7 -0
- cocotb/_utils.py +296 -0
- cocotb/_version.py +3 -7
- cocotb/_xunit_reporter.py +66 -0
- cocotb/clock.py +271 -108
- cocotb/handle.py +1342 -795
- 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/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/{log.py → logging.py} +105 -110
- cocotb/queue.py +103 -57
- cocotb/regression.py +667 -712
- cocotb/result.py +17 -188
- cocotb/share/def/aldec.exp +0 -0
- cocotb/share/def/aldec.lib +0 -0
- cocotb/share/def/ghdl.exp +0 -0
- cocotb/share/def/ghdl.lib +0 -0
- cocotb/share/def/icarus.exp +0 -0
- cocotb/share/def/icarus.lib +0 -0
- cocotb/share/def/modelsim.def +1 -0
- cocotb/share/def/modelsim.exp +0 -0
- cocotb/share/def/modelsim.lib +0 -0
- cocotb/share/include/cocotb_utils.h +6 -29
- cocotb/share/include/embed.h +5 -28
- cocotb/share/include/gpi.h +137 -92
- cocotb/share/include/gpi_logging.h +221 -142
- cocotb/share/include/py_gpi_logging.h +7 -4
- cocotb/share/include/vpi_user_ext.h +4 -26
- cocotb/share/lib/verilator/verilator.cpp +59 -54
- cocotb/simulator.cp311-win32.exp +0 -0
- cocotb/simulator.cp311-win32.lib +0 -0
- cocotb/simulator.cp311-win32.pyd +0 -0
- cocotb/simulator.pyi +107 -0
- cocotb/task.py +434 -212
- cocotb/triggers.py +55 -1092
- cocotb/types/__init__.py +25 -47
- cocotb/types/_abstract_array.py +151 -0
- cocotb/types/_array.py +264 -0
- cocotb/types/_logic.py +296 -0
- cocotb/types/_logic_array.py +834 -0
- cocotb/types/{range.py → _range.py} +36 -44
- cocotb/types/_resolve.py +76 -0
- cocotb/utils.py +119 -587
- cocotb-2.0.0b1.dist-info/METADATA +60 -0
- cocotb-2.0.0b1.dist-info/RECORD +143 -0
- {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/WHEEL +1 -1
- cocotb-2.0.0b1.dist-info/entry_points.txt +2 -0
- {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/top_level.txt +1 -0
- cocotb_tools/__init__.py +0 -0
- cocotb_tools/_coverage.py +33 -0
- cocotb_tools/_vendor/__init__.py +3 -0
- cocotb_tools/check_results.py +65 -0
- cocotb_tools/combine_results.py +152 -0
- cocotb_tools/config.py +241 -0
- {cocotb → cocotb_tools}/ipython_support.py +29 -22
- cocotb_tools/makefiles/Makefile.deprecations +27 -0
- {cocotb/share → cocotb_tools}/makefiles/Makefile.inc +82 -54
- {cocotb/share → cocotb_tools}/makefiles/Makefile.sim +8 -33
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.activehdl +9 -16
- cocotb_tools/makefiles/simulators/Makefile.cvc +61 -0
- cocotb_tools/makefiles/simulators/Makefile.dsim +39 -0
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.ghdl +13 -42
- 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/share/makefiles/simulators/Makefile.questa → cocotb_tools/makefiles/simulators/Makefile.questa-compat +26 -54
- cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun +149 -0
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.riviera +17 -56
- cocotb_tools/makefiles/simulators/Makefile.vcs +65 -0
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.verilator +15 -22
- {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.xcelium +20 -52
- cocotb_tools/py.typed +0 -0
- {cocotb → cocotb_tools}/runner.py +794 -361
- cocotb/_sim_versions.py → cocotb_tools/sim_versions.py +16 -21
- pygpi/entry.py +34 -17
- pygpi/py.typed +0 -0
- cocotb/binary.py +0 -858
- cocotb/config.py +0 -289
- cocotb/decorators.py +0 -332
- cocotb/memdebug.py +0 -35
- cocotb/outcomes.py +0 -56
- cocotb/scheduler.py +0 -1099
- cocotb/share/makefiles/Makefile.deprecations +0 -12
- cocotb/share/makefiles/simulators/Makefile.cvc +0 -94
- cocotb/share/makefiles/simulators/Makefile.icarus +0 -111
- cocotb/share/makefiles/simulators/Makefile.ius +0 -125
- cocotb/share/makefiles/simulators/Makefile.modelsim +0 -32
- cocotb/share/makefiles/simulators/Makefile.nvc +0 -64
- cocotb/share/makefiles/simulators/Makefile.vcs +0 -98
- cocotb/types/array.py +0 -309
- cocotb/types/logic.py +0 -292
- cocotb/types/logic_array.py +0 -298
- cocotb/wavedrom.py +0 -199
- cocotb/xunit_reporter.py +0 -80
- cocotb-1.9.2.dist-info/METADATA +0 -168
- cocotb-1.9.2.dist-info/RECORD +0 -121
- cocotb-1.9.2.dist-info/entry_points.txt +0 -2
- /cocotb/{_vendor/__init__.py → py.typed} +0 -0
- {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info/licenses}/LICENSE +0 -0
- {cocotb → cocotb_tools}/_vendor/distutils_version.py +0 -0
cocotb/config.py
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
###############################################################################
|
|
3
|
-
# Copyright (c) 2013 Potential Ventures Ltd
|
|
4
|
-
# Copyright (c) 2013 SolarFlare Communications Inc
|
|
5
|
-
# All rights reserved.
|
|
6
|
-
#
|
|
7
|
-
# Redistribution and use in source and binary forms, with or without
|
|
8
|
-
# modification, are permitted provided that the following conditions are met:
|
|
9
|
-
# * Redistributions of source code must retain the above copyright
|
|
10
|
-
# notice, this list of conditions and the following disclaimer.
|
|
11
|
-
# * Redistributions in binary form must reproduce the above copyright
|
|
12
|
-
# notice, this list of conditions and the following disclaimer in the
|
|
13
|
-
# documentation and/or other materials provided with the distribution.
|
|
14
|
-
# * Neither the name of Potential Ventures Ltd,
|
|
15
|
-
# SolarFlare Communications Inc nor the
|
|
16
|
-
# names of its contributors may be used to endorse or promote products
|
|
17
|
-
# derived from this software without specific prior written permission.
|
|
18
|
-
#
|
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
20
|
-
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
-
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
-
# DISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY
|
|
23
|
-
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
24
|
-
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
25
|
-
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
26
|
-
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
27
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
28
|
-
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
-
###############################################################################
|
|
30
|
-
|
|
31
|
-
"""
|
|
32
|
-
Module for querying the cocotb configuration
|
|
33
|
-
|
|
34
|
-
This module provides information in module global variables and through a
|
|
35
|
-
``main()`` function that is used in the cocotb-config script.
|
|
36
|
-
|
|
37
|
-
Global variables:
|
|
38
|
-
share_dir: str, path where the cocotb data is stored
|
|
39
|
-
makefiles_dir: str, path where the cocotb makefiles are installed
|
|
40
|
-
libs_dir: str, path where the cocotb interface libraries are located
|
|
41
|
-
"""
|
|
42
|
-
import argparse
|
|
43
|
-
import os
|
|
44
|
-
import sys
|
|
45
|
-
import textwrap
|
|
46
|
-
from pathlib import Path
|
|
47
|
-
|
|
48
|
-
import find_libpython
|
|
49
|
-
|
|
50
|
-
import cocotb
|
|
51
|
-
|
|
52
|
-
__all__ = ["share_dir", "makefiles_dir", "libs_dir"]
|
|
53
|
-
|
|
54
|
-
base_dir = Path(cocotb.__file__).parent.resolve()
|
|
55
|
-
share_dir = base_dir.joinpath("share").as_posix()
|
|
56
|
-
makefiles_dir = base_dir.joinpath("share").joinpath("makefiles").as_posix()
|
|
57
|
-
libs_dir = base_dir.joinpath("libs").as_posix()
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def help_vars_text():
|
|
61
|
-
if "dev" in cocotb.__version__:
|
|
62
|
-
doclink = "https://docs.cocotb.org/en/latest/building.html"
|
|
63
|
-
else:
|
|
64
|
-
doclink = f"https://docs.cocotb.org/en/v{cocotb.__version__}/building.html"
|
|
65
|
-
|
|
66
|
-
# NOTE: make sure to keep "helpmsg" aligned with documentation/source/building.rst
|
|
67
|
-
# Also keep it at 80 chars.
|
|
68
|
-
helpmsg = textwrap.dedent(
|
|
69
|
-
"""\
|
|
70
|
-
The following variables are environment variables:
|
|
71
|
-
|
|
72
|
-
Cocotb
|
|
73
|
-
------
|
|
74
|
-
TOPLEVEL Instance in the hierarchy to use as the DUT
|
|
75
|
-
RANDOM_SEED Random seed, to recreate a previous test stimulus
|
|
76
|
-
COCOTB_ANSI_OUTPUT Force cocotb to print or not print in color
|
|
77
|
-
COCOTB_REDUCED_LOG_FMT Display log lines shorter
|
|
78
|
-
COCOTB_ATTACH Pause time value in seconds before the simulator start
|
|
79
|
-
COCOTB_ENABLE_PROFILING Performance analysis of the Python portion of cocotb
|
|
80
|
-
COCOTB_LOG_LEVEL Default logging level (default INFO)
|
|
81
|
-
COCOTB_RESOLVE_X How to resolve X, Z, U, W on integer conversion
|
|
82
|
-
MEMCHECK HTTP port to use for debugging Python memory usage
|
|
83
|
-
LIBPYTHON_LOC Absolute path to libpython
|
|
84
|
-
|
|
85
|
-
Regression Manager
|
|
86
|
-
------------------
|
|
87
|
-
COCOTB_PDB_ON_EXCEPTION Drop into the Python debugger (pdb) on exception
|
|
88
|
-
MODULE Modules to search for test functions (comma-separated)
|
|
89
|
-
TESTCASE Test function(s) to run (comma-separated list)
|
|
90
|
-
COCOTB_RESULTS_FILE File name for xUnit XML tests results
|
|
91
|
-
COVERAGE Report Python coverage (also HDL for some simulators)
|
|
92
|
-
|
|
93
|
-
GPI
|
|
94
|
-
---
|
|
95
|
-
GPI_EXTRA Extra libraries to load at runtime (comma-separated)
|
|
96
|
-
|
|
97
|
-
Scheduler
|
|
98
|
-
---------
|
|
99
|
-
COCOTB_SCHEDULER_DEBUG Enable additional output of coroutine scheduler
|
|
100
|
-
|
|
101
|
-
For details, see {}"""
|
|
102
|
-
).format(doclink)
|
|
103
|
-
return helpmsg
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def lib_name(interface: str, simulator: str) -> str:
|
|
107
|
-
"""
|
|
108
|
-
Return the name of interface library for given interface (VPI/VHPI/FLI) and simulator.
|
|
109
|
-
"""
|
|
110
|
-
|
|
111
|
-
interface_name = interface.lower()
|
|
112
|
-
supported_interfaces = ["vpi", "vhpi", "fli"]
|
|
113
|
-
if interface_name not in supported_interfaces:
|
|
114
|
-
raise ValueError(
|
|
115
|
-
"Wrong interface used. Supported: " + ", ".join(supported_interfaces)
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
simulator_name = simulator.lower()
|
|
119
|
-
supported_sims = [
|
|
120
|
-
"icarus",
|
|
121
|
-
"questa",
|
|
122
|
-
"modelsim",
|
|
123
|
-
"ius",
|
|
124
|
-
"xcelium",
|
|
125
|
-
"vcs",
|
|
126
|
-
"ghdl",
|
|
127
|
-
"riviera",
|
|
128
|
-
"activehdl",
|
|
129
|
-
"cvc",
|
|
130
|
-
"nvc",
|
|
131
|
-
]
|
|
132
|
-
if simulator not in supported_sims:
|
|
133
|
-
raise ValueError(
|
|
134
|
-
"Wrong simulator name. Supported: " + ", ".join(supported_sims)
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
if simulator_name in ["questa", "cvc"]:
|
|
138
|
-
library_name = "modelsim"
|
|
139
|
-
elif simulator_name == "xcelium":
|
|
140
|
-
library_name = "ius"
|
|
141
|
-
elif simulator_name in ["riviera", "activehdl"]:
|
|
142
|
-
library_name = "aldec"
|
|
143
|
-
else:
|
|
144
|
-
library_name = simulator_name
|
|
145
|
-
|
|
146
|
-
if library_name == "icarus":
|
|
147
|
-
lib_ext = ""
|
|
148
|
-
elif os.name == "nt":
|
|
149
|
-
lib_ext = ".dll"
|
|
150
|
-
else:
|
|
151
|
-
lib_ext = ".so"
|
|
152
|
-
|
|
153
|
-
# check if compiled with msvc
|
|
154
|
-
if os.path.isfile(os.path.join(libs_dir, "cocotb.dll")):
|
|
155
|
-
lib_prefix = ""
|
|
156
|
-
else:
|
|
157
|
-
lib_prefix = "lib"
|
|
158
|
-
|
|
159
|
-
return lib_prefix + "cocotb" + interface_name + "_" + library_name + lib_ext
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
def lib_name_path(interface, simulator):
|
|
163
|
-
"""
|
|
164
|
-
Return the absolute path of interface library for given interface (VPI/VHPI/FLI) and simulator
|
|
165
|
-
"""
|
|
166
|
-
library_name_path = os.path.join(libs_dir, lib_name(interface, simulator))
|
|
167
|
-
|
|
168
|
-
return Path(library_name_path).as_posix()
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
def _findlibpython():
|
|
172
|
-
libpython_path = find_libpython.find_libpython()
|
|
173
|
-
if libpython_path is None:
|
|
174
|
-
sys.exit(1)
|
|
175
|
-
return Path(libpython_path).as_posix()
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
class PrintAction(argparse.Action):
|
|
179
|
-
def __init__(self, option_strings, dest, text=None, **kwargs):
|
|
180
|
-
super().__init__(option_strings, dest, nargs=0, **kwargs)
|
|
181
|
-
self.text = text
|
|
182
|
-
|
|
183
|
-
def __call__(self, parser, namespace, values, option_string=None):
|
|
184
|
-
print(self.text)
|
|
185
|
-
parser.exit()
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
class PrintFuncAction(argparse.Action):
|
|
189
|
-
def __init__(self, option_strings, dest, function=None, **kwargs):
|
|
190
|
-
super().__init__(option_strings, dest, **kwargs)
|
|
191
|
-
self.function = function
|
|
192
|
-
|
|
193
|
-
def __call__(self, parser, args, values, option_string=None):
|
|
194
|
-
try:
|
|
195
|
-
print(self.function(*values))
|
|
196
|
-
except ValueError as e:
|
|
197
|
-
parser.error(e)
|
|
198
|
-
parser.exit()
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
def get_parser():
|
|
202
|
-
prefix_dir = base_dir.parent.resolve().as_posix()
|
|
203
|
-
version = cocotb.__version__
|
|
204
|
-
python_bin = Path(sys.executable).as_posix()
|
|
205
|
-
|
|
206
|
-
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
|
|
207
|
-
parser.add_argument(
|
|
208
|
-
"--prefix",
|
|
209
|
-
help="echo the package-prefix of cocotb",
|
|
210
|
-
action=PrintAction,
|
|
211
|
-
text=prefix_dir,
|
|
212
|
-
)
|
|
213
|
-
parser.add_argument(
|
|
214
|
-
"--share",
|
|
215
|
-
help="echo the package-share of cocotb",
|
|
216
|
-
action=PrintAction,
|
|
217
|
-
text=share_dir,
|
|
218
|
-
)
|
|
219
|
-
parser.add_argument(
|
|
220
|
-
"--makefiles",
|
|
221
|
-
help="echo the package-makefiles of cocotb",
|
|
222
|
-
action=PrintAction,
|
|
223
|
-
text=makefiles_dir,
|
|
224
|
-
)
|
|
225
|
-
parser.add_argument(
|
|
226
|
-
"--python-bin",
|
|
227
|
-
help="echo the path to the Python binary cocotb is installed for",
|
|
228
|
-
action=PrintAction,
|
|
229
|
-
text=python_bin,
|
|
230
|
-
)
|
|
231
|
-
parser.add_argument(
|
|
232
|
-
"--help-vars",
|
|
233
|
-
help="show help about supported variables",
|
|
234
|
-
action=PrintAction,
|
|
235
|
-
text=help_vars_text(),
|
|
236
|
-
)
|
|
237
|
-
parser.add_argument(
|
|
238
|
-
"--libpython",
|
|
239
|
-
help="Print the absolute path to the libpython associated with the current Python installation",
|
|
240
|
-
nargs=0,
|
|
241
|
-
metavar=(),
|
|
242
|
-
action=PrintFuncAction,
|
|
243
|
-
function=_findlibpython,
|
|
244
|
-
)
|
|
245
|
-
parser.add_argument(
|
|
246
|
-
"--lib-dir",
|
|
247
|
-
help="Print the absolute path to the interface libraries location",
|
|
248
|
-
action=PrintAction,
|
|
249
|
-
text=libs_dir,
|
|
250
|
-
)
|
|
251
|
-
parser.add_argument(
|
|
252
|
-
"--lib-name",
|
|
253
|
-
help="Print the name of interface library for given interface (VPI/VHPI/FLI) and simulator",
|
|
254
|
-
nargs=2,
|
|
255
|
-
metavar=("INTERFACE", "SIMULATOR"),
|
|
256
|
-
action=PrintFuncAction,
|
|
257
|
-
function=lib_name,
|
|
258
|
-
)
|
|
259
|
-
parser.add_argument(
|
|
260
|
-
"--lib-name-path",
|
|
261
|
-
help="Print the absolute path of interface library for given interface (VPI/VHPI/FLI) and simulator",
|
|
262
|
-
nargs=2,
|
|
263
|
-
metavar=("INTERFACE", "SIMULATOR"),
|
|
264
|
-
action=PrintFuncAction,
|
|
265
|
-
function=lib_name_path,
|
|
266
|
-
)
|
|
267
|
-
parser.add_argument(
|
|
268
|
-
"-v",
|
|
269
|
-
"--version",
|
|
270
|
-
help="echo the version of cocotb",
|
|
271
|
-
action=PrintAction,
|
|
272
|
-
text=version,
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
return parser
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
def main():
|
|
279
|
-
parser = get_parser()
|
|
280
|
-
|
|
281
|
-
if len(sys.argv) == 1:
|
|
282
|
-
parser.print_help(sys.stderr)
|
|
283
|
-
sys.exit(1)
|
|
284
|
-
|
|
285
|
-
parser.parse_args()
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if __name__ == "__main__":
|
|
289
|
-
main()
|
cocotb/decorators.py
DELETED
|
@@ -1,332 +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 functools
|
|
29
|
-
import sys
|
|
30
|
-
import typing
|
|
31
|
-
import warnings
|
|
32
|
-
|
|
33
|
-
import cocotb
|
|
34
|
-
import cocotb.triggers
|
|
35
|
-
from cocotb.log import SimLog
|
|
36
|
-
from cocotb.task import Task as _Task # noqa: F401
|
|
37
|
-
from cocotb.task import _RunningCoroutine, _RunningTest
|
|
38
|
-
from cocotb.utils import lazy_property
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def public(f):
|
|
42
|
-
"""Use a decorator to avoid retyping function/class names.
|
|
43
|
-
|
|
44
|
-
* Based on an idea by Duncan Booth:
|
|
45
|
-
http://groups.google.com/group/comp.lang.python/msg/11cbb03e09611b8a
|
|
46
|
-
* Improved via a suggestion by Dave Angel:
|
|
47
|
-
http://groups.google.com/group/comp.lang.python/msg/3d400fb22d8a42e1
|
|
48
|
-
"""
|
|
49
|
-
all = sys.modules[f.__module__].__dict__.setdefault("__all__", [])
|
|
50
|
-
if f.__name__ not in all: # Prevent duplicates if run from an IDE.
|
|
51
|
-
all.append(f.__name__)
|
|
52
|
-
return f
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
public(public) # Emulate decorating ourself
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class coroutine:
|
|
59
|
-
"""Decorator class that allows us to provide common coroutine mechanisms:
|
|
60
|
-
|
|
61
|
-
``log`` methods will log to ``cocotb.coroutine.name``.
|
|
62
|
-
|
|
63
|
-
:meth:`~cocotb.task.Task.join` method returns an event which will fire when the coroutine exits.
|
|
64
|
-
|
|
65
|
-
Used as ``@cocotb.coroutine``.
|
|
66
|
-
"""
|
|
67
|
-
|
|
68
|
-
def __init__(self, func):
|
|
69
|
-
self._func = func
|
|
70
|
-
functools.update_wrapper(self, func)
|
|
71
|
-
|
|
72
|
-
@lazy_property
|
|
73
|
-
def log(self):
|
|
74
|
-
return SimLog(f"cocotb.coroutine.{self._func.__qualname__}.{id(self)}")
|
|
75
|
-
|
|
76
|
-
def __call__(self, *args, **kwargs):
|
|
77
|
-
return _RunningCoroutine(self._func(*args, **kwargs), self)
|
|
78
|
-
|
|
79
|
-
def __get__(self, obj, owner=None):
|
|
80
|
-
"""Permit the decorator to be used on class methods
|
|
81
|
-
and standalone functions"""
|
|
82
|
-
return type(self)(self._func.__get__(obj, owner))
|
|
83
|
-
|
|
84
|
-
def __iter__(self):
|
|
85
|
-
return self
|
|
86
|
-
|
|
87
|
-
def __str__(self):
|
|
88
|
-
return str(self._func.__qualname__)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
@public
|
|
92
|
-
class function:
|
|
93
|
-
"""Decorator class that allows a function to block.
|
|
94
|
-
|
|
95
|
-
This allows a coroutine that consumes simulation time
|
|
96
|
-
to be called by a thread started with :class:`cocotb.external`;
|
|
97
|
-
in other words, to internally block while externally
|
|
98
|
-
appear to yield.
|
|
99
|
-
"""
|
|
100
|
-
|
|
101
|
-
def __init__(self, func):
|
|
102
|
-
self._coro = cocotb.coroutine(func)
|
|
103
|
-
|
|
104
|
-
@lazy_property
|
|
105
|
-
def log(self):
|
|
106
|
-
return SimLog(f"cocotb.function.{self._coro.__qualname__}.{id(self)}")
|
|
107
|
-
|
|
108
|
-
def __call__(self, *args, **kwargs):
|
|
109
|
-
return cocotb.scheduler._queue_function(self._coro(*args, **kwargs))
|
|
110
|
-
|
|
111
|
-
def __get__(self, obj, owner=None):
|
|
112
|
-
"""Permit the decorator to be used on class methods
|
|
113
|
-
and standalone functions"""
|
|
114
|
-
return type(self)(self._coro._func.__get__(obj, owner))
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
@public
|
|
118
|
-
class external:
|
|
119
|
-
"""Decorator to apply to an external function to enable calling from cocotb.
|
|
120
|
-
|
|
121
|
-
This turns a normal function that isn't a coroutine into a blocking coroutine.
|
|
122
|
-
Currently, this creates a new execution thread for each function that is
|
|
123
|
-
called.
|
|
124
|
-
Scope for this to be streamlined to a queue in future.
|
|
125
|
-
"""
|
|
126
|
-
|
|
127
|
-
def __init__(self, func):
|
|
128
|
-
self._func = func
|
|
129
|
-
self._log = SimLog(f"cocotb.external.{self._func.__qualname__}.{id(self)}")
|
|
130
|
-
|
|
131
|
-
def __call__(self, *args, **kwargs):
|
|
132
|
-
return cocotb.scheduler._run_in_executor(self._func, *args, **kwargs)
|
|
133
|
-
|
|
134
|
-
def __get__(self, obj, owner=None):
|
|
135
|
-
"""Permit the decorator to be used on class methods
|
|
136
|
-
and standalone functions"""
|
|
137
|
-
return type(self)(self._func.__get__(obj, owner))
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
class _decorator_helper(type):
|
|
141
|
-
"""
|
|
142
|
-
Metaclass that allows a type to be constructed using decorator syntax,
|
|
143
|
-
passing the decorated function as the first argument. Supports
|
|
144
|
-
construction with or without having the type called.
|
|
145
|
-
|
|
146
|
-
So:
|
|
147
|
-
|
|
148
|
-
@MyClass(construction, args='go here')
|
|
149
|
-
def this_is_passed_as_f(...):
|
|
150
|
-
pass
|
|
151
|
-
|
|
152
|
-
ends up calling
|
|
153
|
-
|
|
154
|
-
MyClass.__init__(this_is_passed_as_f, construction, args='go here')
|
|
155
|
-
"""
|
|
156
|
-
|
|
157
|
-
def __call__(cls, *args, **kwargs):
|
|
158
|
-
if len(args) == 1 and callable(args[0]): # case without parenthesis
|
|
159
|
-
f = args[0]
|
|
160
|
-
return type.__call__(cls, f, **kwargs)
|
|
161
|
-
|
|
162
|
-
# case with parenthesis
|
|
163
|
-
def decorator(f):
|
|
164
|
-
# fall back to the normal way of constructing an object, now that
|
|
165
|
-
# we have all the arguments
|
|
166
|
-
return type.__call__(cls, f, *args, **kwargs)
|
|
167
|
-
|
|
168
|
-
return decorator
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
@public
|
|
172
|
-
class test(coroutine, metaclass=_decorator_helper):
|
|
173
|
-
"""
|
|
174
|
-
Decorator to mark a Callable which returns a Coroutine as a test.
|
|
175
|
-
|
|
176
|
-
The test decorator provides a test timeout, and allows us to mark tests as skipped
|
|
177
|
-
or expecting errors or failures.
|
|
178
|
-
Tests are evaluated in the order they are defined in a test module.
|
|
179
|
-
|
|
180
|
-
Used as ``@cocotb.test(...)``.
|
|
181
|
-
|
|
182
|
-
Args:
|
|
183
|
-
timeout_time (numbers.Real or decimal.Decimal, optional):
|
|
184
|
-
Simulation time duration before timeout occurs.
|
|
185
|
-
|
|
186
|
-
.. versionadded:: 1.3
|
|
187
|
-
|
|
188
|
-
.. note::
|
|
189
|
-
Test timeout is intended for protection against deadlock.
|
|
190
|
-
Users should use :class:`~cocotb.triggers.with_timeout` if they require a
|
|
191
|
-
more general-purpose timeout mechanism.
|
|
192
|
-
|
|
193
|
-
timeout_unit (str, optional):
|
|
194
|
-
Units of timeout_time, accepts any units that :class:`~cocotb.triggers.Timer` does.
|
|
195
|
-
|
|
196
|
-
.. versionadded:: 1.3
|
|
197
|
-
|
|
198
|
-
.. deprecated:: 1.5
|
|
199
|
-
Using ``None`` as the *timeout_unit* argument is deprecated, use ``'step'`` instead.
|
|
200
|
-
|
|
201
|
-
expect_fail (bool, optional):
|
|
202
|
-
If ``True`` and the test fails a functional check via an ``assert`` statement, :class:`pytest.raises`,
|
|
203
|
-
:class:`pytest.warns`, or :class:`pytest.deprecated_call` the test is considered to have passed.
|
|
204
|
-
If ``True`` and the test passes successfully, the test is considered to have failed.
|
|
205
|
-
|
|
206
|
-
expect_error (exception type or tuple of exception types, optional):
|
|
207
|
-
Mark the result as a pass only if one of the exception types is raised in the test.
|
|
208
|
-
This is primarily for cocotb internal regression use for when a simulator error is expected.
|
|
209
|
-
|
|
210
|
-
Users are encouraged to use the following idiom instead::
|
|
211
|
-
|
|
212
|
-
@cocotb.test()
|
|
213
|
-
async def my_test(dut):
|
|
214
|
-
try:
|
|
215
|
-
await thing_that_should_fail()
|
|
216
|
-
except ExceptionIExpect:
|
|
217
|
-
pass
|
|
218
|
-
else:
|
|
219
|
-
assert False, "Exception did not occur"
|
|
220
|
-
|
|
221
|
-
.. versionchanged:: 1.3
|
|
222
|
-
Specific exception types can be expected
|
|
223
|
-
|
|
224
|
-
.. deprecated:: 1.5
|
|
225
|
-
Passing a :class:`bool` value is now deprecated.
|
|
226
|
-
Pass a specific :class:`Exception` or a tuple of Exceptions instead.
|
|
227
|
-
|
|
228
|
-
skip (bool, optional):
|
|
229
|
-
Don't execute this test as part of the regression. Test can still be run
|
|
230
|
-
manually by setting :make:var:`TESTCASE`.
|
|
231
|
-
|
|
232
|
-
stage (int)
|
|
233
|
-
Order tests logically into stages, where multiple tests can share a stage.
|
|
234
|
-
Defaults to 0.
|
|
235
|
-
"""
|
|
236
|
-
|
|
237
|
-
_id_count = 0 # used by the RegressionManager to sort tests in definition order
|
|
238
|
-
|
|
239
|
-
def __init__(
|
|
240
|
-
self,
|
|
241
|
-
f,
|
|
242
|
-
timeout_time=None,
|
|
243
|
-
timeout_unit="step",
|
|
244
|
-
expect_fail=False,
|
|
245
|
-
expect_error=(),
|
|
246
|
-
skip=False,
|
|
247
|
-
stage=0,
|
|
248
|
-
):
|
|
249
|
-
|
|
250
|
-
if timeout_unit is None:
|
|
251
|
-
warnings.warn(
|
|
252
|
-
'Using timeout_unit=None is deprecated, use timeout_unit="step" instead.',
|
|
253
|
-
DeprecationWarning,
|
|
254
|
-
stacklevel=2,
|
|
255
|
-
)
|
|
256
|
-
timeout_unit = "step" # don't propagate deprecated value
|
|
257
|
-
self._id = self._id_count
|
|
258
|
-
type(self)._id_count += 1
|
|
259
|
-
|
|
260
|
-
if timeout_time is not None:
|
|
261
|
-
co = coroutine(f)
|
|
262
|
-
|
|
263
|
-
@functools.wraps(f)
|
|
264
|
-
async def f(*args, **kwargs):
|
|
265
|
-
running_co = co(*args, **kwargs)
|
|
266
|
-
|
|
267
|
-
try:
|
|
268
|
-
res = await cocotb.triggers.with_timeout(
|
|
269
|
-
running_co, self.timeout_time, self.timeout_unit
|
|
270
|
-
)
|
|
271
|
-
except cocotb.result.SimTimeoutError:
|
|
272
|
-
running_co.kill()
|
|
273
|
-
raise
|
|
274
|
-
else:
|
|
275
|
-
return res
|
|
276
|
-
|
|
277
|
-
super().__init__(f)
|
|
278
|
-
|
|
279
|
-
self.timeout_time = timeout_time
|
|
280
|
-
self.timeout_unit = timeout_unit
|
|
281
|
-
self.expect_fail = expect_fail
|
|
282
|
-
if isinstance(expect_error, bool):
|
|
283
|
-
warnings.warn(
|
|
284
|
-
"Passing bool values to `except_error` option of `cocotb.test` is deprecated. "
|
|
285
|
-
"Pass a specific Exception type instead",
|
|
286
|
-
DeprecationWarning,
|
|
287
|
-
stacklevel=2,
|
|
288
|
-
)
|
|
289
|
-
if expect_error is True:
|
|
290
|
-
expect_error = (BaseException,)
|
|
291
|
-
elif expect_error is False:
|
|
292
|
-
expect_error = ()
|
|
293
|
-
self.expect_error = expect_error
|
|
294
|
-
self.skip = skip
|
|
295
|
-
self.stage = stage
|
|
296
|
-
self.im_test = True # For auto-regressions
|
|
297
|
-
self.name = self._func.__name__
|
|
298
|
-
|
|
299
|
-
def __call__(self, *args, **kwargs):
|
|
300
|
-
inst = self._func(*args, **kwargs)
|
|
301
|
-
coro = _RunningTest(inst, self)
|
|
302
|
-
return coro
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if sys.version_info < (3, 7):
|
|
306
|
-
Task = _Task
|
|
307
|
-
RunningTask = _Task
|
|
308
|
-
RunningCoroutine = _RunningCoroutine
|
|
309
|
-
RunningTest = _RunningTest
|
|
310
|
-
else:
|
|
311
|
-
|
|
312
|
-
def __getattr__(attr: str) -> typing.Any:
|
|
313
|
-
if attr in ("Task", "RunningTask"):
|
|
314
|
-
warnings.warn(
|
|
315
|
-
f"The class {attr} has been renamed to cocotb.task.Task.",
|
|
316
|
-
DeprecationWarning,
|
|
317
|
-
stacklevel=2,
|
|
318
|
-
)
|
|
319
|
-
attr = "_Task"
|
|
320
|
-
elif attr in ("RunningCoroutine", "RunningTest"):
|
|
321
|
-
warnings.warn(
|
|
322
|
-
f"The class {attr} is now private. Update all uses to the parent class cocotb.task.Task.",
|
|
323
|
-
DeprecationWarning,
|
|
324
|
-
stacklevel=2,
|
|
325
|
-
)
|
|
326
|
-
attr = f"_{attr}"
|
|
327
|
-
try:
|
|
328
|
-
return globals()[attr]
|
|
329
|
-
except KeyError:
|
|
330
|
-
raise AttributeError(
|
|
331
|
-
f"module {__name__!r} has no attribute {attr!r}"
|
|
332
|
-
) from None
|
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()
|