cocotb 1.9.2__cp310-cp310-win32.whl → 2.0.0rc2__cp310-cp310-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.cp310-win32.exp +0 -0
  86. cocotb/simulator.cp310-win32.lib +0 -0
  87. cocotb/simulator.cp310-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_tools/config.py ADDED
@@ -0,0 +1,241 @@
1
+ #!/usr/bin/env python
2
+ # Copyright cocotb contributors
3
+ # Copyright (c) 2013 Potential Ventures Ltd
4
+ # Copyright (c) 2013 SolarFlare Communications Inc
5
+ # Licensed under the Revised BSD License, see LICENSE for details.
6
+ # SPDX-License-Identifier: BSD-3-Clause
7
+
8
+ """
9
+ Module for querying the cocotb configuration
10
+
11
+ This module provides information in module global variables and through a
12
+ ``main()`` function that is used in the cocotb-config script.
13
+
14
+ Global variables:
15
+ share_dir: str, path where the cocotb data is stored
16
+ makefiles_dir: str, path where the cocotb makefiles are installed
17
+ libs_dir: str, path where the cocotb interface libraries are located
18
+ """
19
+
20
+ import argparse
21
+ import os
22
+ import sys
23
+ import textwrap
24
+ from pathlib import Path
25
+
26
+ import find_libpython
27
+
28
+ import cocotb_tools
29
+
30
+ base_tools_dir = Path(cocotb_tools.__file__).parent.resolve()
31
+ base_cocotb_dir = (base_tools_dir.parent / "cocotb").resolve()
32
+ if not (base_cocotb_dir.exists() and (base_cocotb_dir / "libs").exists()):
33
+ import cocotb
34
+
35
+ base_cocotb_dir = Path(cocotb.__file__).parent.resolve()
36
+
37
+ share_dir = base_cocotb_dir.joinpath("share")
38
+ libs_dir = base_cocotb_dir.joinpath("libs")
39
+ makefiles_dir = base_tools_dir.joinpath("makefiles")
40
+
41
+
42
+ def _get_version() -> str:
43
+ import cocotb # noqa: PLC0415
44
+
45
+ return cocotb.__version__
46
+
47
+
48
+ def _help_vars_text() -> str:
49
+ if "dev" in _get_version():
50
+ doclink = "https://docs.cocotb.org/en/development/library_reference.html"
51
+ else:
52
+ doclink = f"https://docs.cocotb.org/en/v{_get_version()}/library_reference.html"
53
+
54
+ # NOTE: make sure to keep "helpmsg" aligned with docs/source/library_reference.rst
55
+ helpmsg = textwrap.dedent(
56
+ """\
57
+ The following variables are environment variables:
58
+
59
+ cocotb
60
+ ------
61
+ COCOTB_TOPLEVEL Instance in the hierarchy to use as the DUT
62
+ COCOTB_RANDOM_SEED Random seed, to recreate a previous test stimulus
63
+ COCOTB_ANSI_OUTPUT Force cocotb to print or not print in color
64
+ COCOTB_REDUCED_LOG_FMT Display log lines shorter
65
+ COCOTB_ATTACH Pause time value in seconds before the simulator start
66
+ COCOTB_ENABLE_PROFILING Performance analysis of the Python portion of cocotb
67
+ COCOTB_LOG_LEVEL Default logging level (default INFO)
68
+ COCOTB_RESOLVE_X How to resolve X, Z, U, W, - on integer conversion
69
+ LIBPYTHON_LOC Absolute path to libpython
70
+
71
+ Regression Manager
72
+ ------------------
73
+ COCOTB_PDB_ON_EXCEPTION Drop into the Python debugger (pdb) on exception
74
+ COCOTB_TEST_MODULES Module(s) to search for test functions (comma-separated)
75
+ COCOTB_TESTCASE Test function(s) to run (comma-separated list)
76
+ COCOTB_RESULTS_FILE File name for xUnit XML tests results
77
+ COCOTB_USER_COVERAGE Collect Python user coverage (HDL for some simulators)
78
+ COVERAGE_RCFILE Configuration for user code coverage
79
+
80
+ GPI
81
+ ---
82
+ GPI_EXTRA Extra libraries to load at runtime (comma-separated)
83
+
84
+ Scheduler
85
+ ---------
86
+ COCOTB_SCHEDULER_DEBUG Enable additional output of coroutine scheduler
87
+ COCOTB_TRUST_INERTIAL_WRITES Trust inertial writes rather than mock them using scheduler
88
+
89
+ For details, see {}"""
90
+ ).format(doclink)
91
+ return helpmsg
92
+
93
+
94
+ def lib_name(interface: str, simulator: str) -> str:
95
+ """
96
+ Return the name of interface library for given interface (VPI/VHPI/FLI) and simulator.
97
+ """
98
+
99
+ interface_name = interface.lower()
100
+ supported_interfaces = ["vpi", "vhpi", "fli"]
101
+ if interface_name not in supported_interfaces:
102
+ raise ValueError(
103
+ "Wrong interface used. Supported: " + ", ".join(supported_interfaces)
104
+ )
105
+
106
+ simulator_name = simulator.lower()
107
+ supported_sims = [
108
+ "icarus",
109
+ "questa",
110
+ "modelsim",
111
+ "ius",
112
+ "xcelium",
113
+ "vcs",
114
+ "ghdl",
115
+ "riviera",
116
+ "activehdl",
117
+ "cvc",
118
+ "nvc",
119
+ "dsim",
120
+ ]
121
+ if simulator not in supported_sims:
122
+ raise ValueError(
123
+ "Wrong simulator name. Supported: " + ", ".join(supported_sims)
124
+ )
125
+
126
+ if simulator_name in ["questa", "cvc"]:
127
+ library_name = "modelsim"
128
+ elif simulator_name == "xcelium":
129
+ library_name = "ius"
130
+ elif simulator_name in ["riviera", "activehdl"]:
131
+ library_name = "aldec"
132
+ else:
133
+ library_name = simulator_name
134
+
135
+ if library_name == "icarus":
136
+ lib_ext = ""
137
+ elif os.name == "nt":
138
+ lib_ext = ".dll"
139
+ else:
140
+ lib_ext = ".so"
141
+
142
+ # check if compiled with msvc
143
+ if (libs_dir / "cocotb.dll").is_file():
144
+ lib_prefix = ""
145
+ else:
146
+ lib_prefix = "lib"
147
+
148
+ return lib_prefix + "cocotb" + interface_name + "_" + library_name + lib_ext
149
+
150
+
151
+ def lib_name_path(interface: str, simulator: str) -> Path:
152
+ """
153
+ Return the absolute path of interface library for given interface (VPI/VHPI/FLI) and simulator
154
+ """
155
+ return libs_dir / lib_name(interface, simulator)
156
+
157
+
158
+ def _get_parser() -> argparse.ArgumentParser:
159
+ parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
160
+
161
+ group = parser.add_mutually_exclusive_group()
162
+ group.add_argument(
163
+ "--share",
164
+ action="store_true",
165
+ help="Print the path to cocotb's share directory",
166
+ )
167
+ group.add_argument(
168
+ "--makefiles",
169
+ action="store_true",
170
+ help="Print the path to cocotb's makefile directory",
171
+ )
172
+ group.add_argument(
173
+ "--python-bin",
174
+ action="store_true",
175
+ help="Print the path to the Python executable associated with the environment that cocotb is installed in.",
176
+ )
177
+ group.add_argument(
178
+ "--help-vars",
179
+ action="store_true",
180
+ help="Print help about supported Makefile variables",
181
+ )
182
+ group.add_argument(
183
+ "--libpython",
184
+ action="store_true",
185
+ help="Print the absolute path to the libpython associated with the current Python installation",
186
+ )
187
+ group.add_argument(
188
+ "--lib-dir",
189
+ action="store_true",
190
+ help="Print the absolute path to the interface libraries location",
191
+ )
192
+ group.add_argument(
193
+ "--lib-name",
194
+ help="Print the name of interface library for given interface (VPI/VHPI/FLI) and simulator",
195
+ nargs=2,
196
+ metavar=("INTERFACE", "SIMULATOR"),
197
+ )
198
+ group.add_argument(
199
+ "--lib-name-path",
200
+ help="Print the absolute path of interface library for given interface (VPI/VHPI/FLI) and simulator",
201
+ nargs=2,
202
+ metavar=("INTERFACE", "SIMULATOR"),
203
+ )
204
+ group.add_argument(
205
+ "--version",
206
+ action="store_true",
207
+ help="Print the version of cocotb",
208
+ )
209
+
210
+ return parser
211
+
212
+
213
+ def main() -> None:
214
+ parser = _get_parser()
215
+ args = parser.parse_args()
216
+
217
+ if args.share:
218
+ print(share_dir.as_posix())
219
+ elif args.makefiles:
220
+ print(makefiles_dir.as_posix())
221
+ elif args.python_bin:
222
+ print(Path(sys.executable).as_posix())
223
+ elif args.help_vars:
224
+ print(_help_vars_text())
225
+ elif args.libpython:
226
+ libpython_path = find_libpython.find_libpython()
227
+ if libpython_path is None:
228
+ sys.exit(1)
229
+ print(Path(libpython_path).as_posix())
230
+ elif args.lib_dir:
231
+ print(libs_dir.as_posix())
232
+ elif args.lib_name:
233
+ print(lib_name(*args.lib_name))
234
+ elif args.lib_name_path:
235
+ print(lib_name_path(*args.lib_name_path).as_posix())
236
+ elif args.version:
237
+ print(_get_version())
238
+
239
+
240
+ if __name__ == "__main__":
241
+ main()
@@ -1,11 +1,18 @@
1
1
  # Copyright cocotb contributors
2
2
  # Licensed under the Revised BSD License, see LICENSE for details.
3
3
  # SPDX-License-Identifier: BSD-3-Clause
4
+ from typing import Any, Dict, TypeVar
5
+
4
6
  import IPython
5
7
  from IPython.terminal.ipapp import load_default_config
6
- from IPython.terminal.prompts import Prompts, Token
8
+ from IPython.terminal.prompts import Prompts
9
+ from pygments.token import Token
7
10
 
8
11
  import cocotb
12
+ from cocotb.task import bridge
13
+ from cocotb.utils import get_sim_time
14
+
15
+ T = TypeVar("T")
9
16
 
10
17
 
11
18
  class SimTimePrompt(Prompts):
@@ -13,24 +20,18 @@ class SimTimePrompt(Prompts):
13
20
 
14
21
  _show_time = 1
15
22
 
16
- def in_prompt_tokens(self, cli=None):
23
+ def in_prompt_tokens(self):
17
24
  tokens = super().in_prompt_tokens()
18
25
  if self._show_time == self.shell.execution_count:
19
26
  tokens = [
20
- (Token.Comment, f"sim time: {cocotb.utils.get_sim_time()}"),
27
+ (Token.Comment, f"sim time: {get_sim_time()}"),
21
28
  (Token.Text, "\n"),
22
- ] + tokens
29
+ *tokens,
30
+ ]
23
31
  return tokens
24
32
 
25
33
 
26
- def _runner(shell, x):
27
- """Handler for async functions"""
28
- ret = cocotb.scheduler._queue_function(x)
29
- shell.prompts._show_time = shell.execution_count
30
- return ret
31
-
32
-
33
- async def embed(user_ns: dict = {}):
34
+ async def embed(user_ns: Dict[str, Any] = {}) -> None:
34
35
  """
35
36
  Start an IPython shell in the current coroutine.
36
37
 
@@ -46,22 +47,28 @@ async def embed(user_ns: dict = {}):
46
47
  Passing ``locals()`` is often a good idea.
47
48
  ``cocotb`` will automatically be included.
48
49
 
49
- Notes:
50
-
50
+ .. note::
51
51
  If your simulator does not provide an appropriate ``stdin``, you may
52
52
  find you cannot type in the resulting shell. Using simulators in batch
53
53
  or non-GUI mode may resolve this. This feature is experimental, and
54
54
  not all simulators are supported.
55
55
  """
56
56
  # ensure cocotb is in the namespace, for convenience
57
- default_ns = dict(cocotb=cocotb)
57
+ default_ns = {"cocotb": cocotb}
58
58
  default_ns.update(user_ns)
59
59
 
60
+ def _runner(x):
61
+ """Handler for async functions"""
62
+ nonlocal shell
63
+ ret = cocotb._scheduler_inst._queue_function(x)
64
+ shell.prompts._show_time = shell.execution_count
65
+ return ret
66
+
60
67
  # build the config to enable `await`
61
68
  c = load_default_config()
62
- c.TerminalInteractiveShell.loop_runner = lambda x: _runner(shell, x)
69
+ c.TerminalInteractiveShell.loop_runner = _runner
63
70
  c.TerminalInteractiveShell.autoawait = True
64
- # Python3 checks SQLite DB accesses to ensure process ID matches the one that opened the DB and is not propogated
71
+ # Python3 checks SQLite DB accesses to ensure process ID matches the one that opened the DB and is not propagated
65
72
  # because we launch IPython in a different process, this will cause unnecessary warnings, so disable the PID check
66
73
  c.HistoryAccessor.connection_options = {"check_same_thread": False}
67
74
  # create a shell with access to the dut, and cocotb pre-imported
@@ -74,19 +81,19 @@ async def embed(user_ns: dict = {}):
74
81
  shell.prompts = SimTimePrompt(shell)
75
82
 
76
83
  # start the shell in a background thread
77
- @cocotb.external
78
- def run_shell():
84
+ @bridge
85
+ def run_shell() -> None:
79
86
  shell()
80
87
 
81
88
  await run_shell()
82
89
 
83
90
 
84
91
  @cocotb.test()
85
- async def run_ipython(dut):
92
+ async def run_ipython(dut: Any) -> None:
86
93
  """A test that launches an interactive Python shell.
87
94
 
88
- Do not call this directly - use this as ``make MODULE=cocotb.ipython_support``.
95
+ Do not call this directly - use this as ``make COCOTB_TEST_MODULES=cocotb.ipython_support``.
89
96
 
90
97
  Within the shell, a global ``dut`` variable pointing to the design will be present.
91
98
  """
92
- await embed(user_ns=dict(dut=dut))
99
+ await embed(user_ns={"dut": dut})
@@ -0,0 +1,27 @@
1
+ # Copyright cocotb contributors
2
+ # Licensed under the Revised BSD License, see LICENSE for details.
3
+ # SPDX-License-Identifier: BSD-3-Clause
4
+
5
+ ifdef VERILATOR_TRACE
6
+ $(warning VERILATOR_TRACE is deprecated, see the "Simulator Support" section in the documentation.)
7
+ endif
8
+
9
+ ifeq ($(SIM_LOWERCASE),aldec)
10
+ $(warning Using SIM=aldec is deprecated, please use SIM=riviera instead.)
11
+ SIM_LOWERCASE := riviera
12
+ endif
13
+
14
+ # Use this function to warn users about deprecated environment variables
15
+ deprecate = $(if $($(1)),$(if $(filter $($(2)),$($(1))),$($(2)),$(warning Using $(1) is deprecated, please use $(2) instead.)$($(1))),$($(2)))
16
+
17
+ ifneq ($(COCOTB_TOPLEVEL),$(TOPLEVEL))
18
+ ifneq ($(TOPLEVEL),)
19
+ COCOTB_TOPLEVEL := $(TOPLEVEL)
20
+ endif
21
+ endif
22
+
23
+ ifneq ($(COCOTB_USER_COVERAGE),$(COVERAGE))
24
+ ifneq ($(COVERAGE),)
25
+ COCOTB_USER_COVERAGE := $(COVERAGE)
26
+ endif
27
+ endif
@@ -1,31 +1,8 @@
1
- ###############################################################################
1
+ # Copyright cocotb contributors
2
2
  # Copyright (c) 2013 Potential Ventures Ltd
3
3
  # Copyright (c) 2013 SolarFlare Communications Inc
4
- # All rights reserved.
5
- #
6
- # Redistribution and use in source and binary forms, with or without
7
- # modification, are permitted provided that the following conditions are met:
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above copyright
11
- # notice, this list of conditions and the following disclaimer in the
12
- # documentation and/or other materials provided with the distribution.
13
- # * Neither the name of Potential Ventures Ltd,
14
- # SolarFlare Communications Inc nor the
15
- # names of its contributors may be used to endorse or promote products
16
- # derived from this software without specific prior written permission.
17
- #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- # DISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY
22
- # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
- # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
- # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- ##############################################################################
4
+ # Licensed under the Revised BSD License, see LICENSE for details.
5
+ # SPDX-License-Identifier: BSD-3-Clause
29
6
 
30
7
  # Common makefile included by everything
31
8
 
@@ -42,13 +19,6 @@ sim:
42
19
  # Make sure to use bash for the pipefail option used in many simulator Makefiles
43
20
  SHELL := bash
44
21
 
45
- # Directory containing the cocotb Python module
46
- COCOTB_PY_DIR := $(shell cocotb-config --prefix)
47
-
48
- # Directory containing all support files required to build cocotb-based
49
- # simulations: Makefile fragments, and the simulator libraries.
50
- COCOTB_SHARE_DIR := $(COCOTB_PY_DIR)/cocotb/share
51
-
52
22
  OS=$(shell uname)
53
23
  ifneq (, $(findstring MINGW, $(OS)))
54
24
  OS := Msys
@@ -57,28 +27,18 @@ else ifneq (, $(findstring MSYS, $(OS)))
57
27
  endif
58
28
  export OS
59
29
 
60
- # Detects if Python is running in a virtual environment
61
- # https://docs.python.org/3/library/venv.html
62
- IS_VENV=$(shell $(shell cocotb-config --python-bin) -c 'import sys; print(sys.prefix != sys.base_prefix)')
30
+ export PYGPI_PYTHON_BIN := $(shell $(PYTHON_BIN) -m cocotb_tools.config --python-bin)
63
31
 
64
- # this ensures we use the same python as the one cocotb was installed into
65
- PYTHON_BIN ?= $(shell cocotb-config --python-bin)
32
+ # Directory containing the cocotb Makefiles
33
+ COCOTB_MAKEFILES_DIR := $(shell $(PYTHON_BIN) -m cocotb_tools.config --makefiles)
66
34
 
67
- include $(COCOTB_SHARE_DIR)/makefiles/Makefile.deprecations
68
-
69
- LIB_DIR=$(COCOTB_PY_DIR)/cocotb/libs
35
+ include $(COCOTB_MAKEFILES_DIR)/Makefile.deprecations
70
36
 
71
37
  PYTHON_ARCH := $(shell $(PYTHON_BIN) -c 'from platform import architecture; print(architecture()[0])')
72
38
  ifeq ($(filter $(PYTHON_ARCH),64bit 32bit),)
73
39
  $(error Unknown Python architecture: $(PYTHON_ARCH))
74
40
  endif
75
41
 
76
- # Changing PYTHONHOME confuses virtual environments, so only set it when not using a venv
77
- ifeq ($(IS_VENV),False)
78
- # Set PYTHONHOME to properly populate sys.path in embedded python interpreter
79
- export PYTHONHOME := $(shell $(PYTHON_BIN) -c 'import sys; print(sys.prefix)')
80
- endif
81
-
82
42
  ifeq ($(OS),Msys)
83
43
  to_tcl_path = $(shell cygpath -m $(1) )
84
44
  else
@@ -90,6 +50,11 @@ define check_for_results_file
90
50
  @test -f $(COCOTB_RESULTS_FILE) || (echo "ERROR: $(COCOTB_RESULTS_FILE) was not written by the simulation!" >&2 && exit 1)
91
51
  endef
92
52
 
53
+ # Check that the COCOTB_RESULTS_FILE was created and has no failures
54
+ define check_results
55
+ @$(PYTHON_BIN) -m cocotb_tools.check_results $(COCOTB_RESULTS_FILE)
56
+ endef
57
+
93
58
  SIM_BUILD ?= sim_build
94
59
  export SIM_BUILD
95
60
 
@@ -99,13 +64,6 @@ COCOTB_HDL_TIMEPRECISION ?= 1ps
99
64
 
100
65
  export COCOTB_RESULTS_FILE
101
66
 
102
- # Depend on all Python from the cocotb package. This triggers a
103
- # recompilation of the simulation if cocotb is updated.
104
- CUSTOM_SIM_DEPS += $(shell $(PYTHON_BIN) -c 'import glob; print(" ".join(glob.glob("$(COCOTB_PY_DIR)/cocotb/*.py")))')
105
-
106
- # This triggers a recompilation of the simulation if cocotb library is updated.
107
- CUSTOM_SIM_DEPS += $(shell $(PYTHON_BIN) -c 'import glob; print(" ".join(glob.glob("$(LIB_DIR)/*")))')
108
-
109
67
 
110
68
  $(SIM_BUILD):
111
69
  mkdir -p $@
@@ -144,7 +102,7 @@ ifndef LIBPYTHON_LOC
144
102
 
145
103
  # get the path to libpython and the return code from the script
146
104
  # adapted from https://stackoverflow.com/a/24658961/6614127
147
- FIND_LIBPYTHON_RES := $(shell cocotb-config --libpython; echo $$?)
105
+ FIND_LIBPYTHON_RES := $(shell $(PYTHON_BIN) -m cocotb_tools.config --libpython; echo $$?)
148
106
  FIND_LIBPYTHON_RC := $(lastword $(FIND_LIBPYTHON_RES))
149
107
  LIBPYTHON_LOC := $(strip $(subst $(FIND_LIBPYTHON_RC)QQQQ,,$(FIND_LIBPYTHON_RES)QQQQ))
150
108
 
@@ -171,6 +129,70 @@ define check_lib_order
171
129
  fi;
172
130
  endef
173
131
 
132
+ # NOTE: if the following simulator list is modified, update the sentence
133
+ # "This flag is enabled by default for the GHDL, NVC and Verilator simulators."
134
+ # in docs/source/building.rst accordingly.
135
+ ifneq ($(filter $(SIM),nvc ghdl verilator),)
136
+ COCOTB_TRUST_INERTIAL_WRITES ?= 1
137
+ else
138
+ COCOTB_TRUST_INERTIAL_WRITES ?= 0
139
+ endif
140
+
141
+ export COCOTB_TRUST_INERTIAL_WRITES
142
+
143
+
144
+ # Universal
145
+ clean::
146
+ @$(RM) -rf $(SIM_BUILD)
147
+ @$(RM) -f $(COCOTB_RESULTS_FILE)
148
+
149
+
150
+ # Active-HDL
151
+ clean::
152
+ @$(RM) -rf work
153
+ @$(RM) -rf wave.asdb
154
+
155
+ # IUS
156
+ clean::
157
+ @$(RM) -rf irun.*
158
+ @$(RM) -rf ncsim.*
159
+ @$(RM) -rf gdb_cmd_ncsim
160
+
161
+ # VCS
162
+ clean::
163
+ @$(RM) -rf simv.daidir
164
+ @$(RM) -rf cm.log
165
+ @$(RM) -rf ucli.key
166
+
167
+ # Riviera
168
+ clean::
169
+ @$(RM) -rf compile
170
+ @$(RM) -rf library.cfg
171
+ @$(RM) -rf dataset.asdb
172
+
173
+ # Verilator
174
+ clean::
175
+ @$(RM) -f dump.vcd
176
+ @$(RM) -f dump.fst
177
+
178
+ # Xcelium
179
+ clean::
180
+ @$(RM) -rf xrun.*
181
+ @$(RM) -rf xmsim.*
182
+ @$(RM) -rf gdb_cmd_xmsim
183
+ @$(RM) -f qrun*
184
+ @$(RM) -f visualizer.log
185
+ @$(RM) -f design.bin
186
+ @$(RM) -f qwave.db
187
+ @$(RM) -f transcript
188
+
189
+
190
+ # DSim
191
+ clean::
192
+ @$(RM) -rf dsim.*
193
+ @$(RM) -rf metrics.db
194
+ @$(RM) -rf file.vcd
195
+
174
196
  else
175
197
  $(warning Including Makefile.inc from a user makefile is a no-op and deprecated. Remove the Makefile.inc inclusion from your makefile, and only leave the Makefile.sim include.)
176
198
  endif # COCOTB_MAKEFILE_INC_INCLUDED
@@ -1,31 +1,8 @@
1
- ###############################################################################
1
+ # Copyright cocotb contributors
2
2
  # Copyright (c) 2013, 2018 Potential Ventures Ltd
3
3
  # Copyright (c) 2013 SolarFlare Communications Inc
4
- # All rights reserved.
5
- #
6
- # Redistribution and use in source and binary forms, with or without
7
- # modification, are permitted provided that the following conditions are met:
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above copyright
11
- # notice, this list of conditions and the following disclaimer in the
12
- # documentation and/or other materials provided with the distribution.
13
- # * Neither the name of Potential Ventures Ltd,
14
- # SolarFlare Communications Inc nor the
15
- # names of its contributors may be used to endorse or promote products
16
- # derived from this software without specific prior written permission.
17
- #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- # DISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY
22
- # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
- # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
- # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- ###############################################################################
4
+ # Licensed under the Revised BSD License, see LICENSE for details.
5
+ # SPDX-License-Identifier: BSD-3-Clause
29
6
 
30
7
  # This file includes an appropriate makefile depending on the SIM variable.
31
8
 
@@ -63,7 +40,7 @@ SIM_CMD_PREFIX Prefix for simulation command invocations
63
40
  COMPILE_ARGS Arguments to pass to compile (analysis) stage of simulation
64
41
  SIM_ARGS Arguments to pass to execution of compiled simulation
65
42
  EXTRA_ARGS Arguments for compile and execute phases
66
- PLUSARGS Plusargs to pass to the simulator
43
+ COCOTB_PLUSARGS Plusargs to pass to the simulator
67
44
  COCOTB_HDL_TIMEUNIT Default time unit for simulation
68
45
  COCOTB_HDL_TIMEPRECISION Default time precision for simulation
69
46
  CUSTOM_COMPILE_DEPS Add additional dependencies to the compilation target
@@ -80,29 +57,35 @@ define newline
80
57
 
81
58
  endef
82
59
 
60
+ # this ensures we use the same python as the one cocotb was installed into
61
+ # attempts to use cocotb_config entry script to get that info, falls back to "python"
62
+ PYTHON_BIN_RES := $(shell cocotb-config --python-bin 2>>/dev/null; echo $$?)
63
+ PYTHON_BIN_RC := $(lastword $(PYTHON_BIN_RES))
64
+ PYTHON_BIN := $(strip $(subst $(PYTHON_BIN_RC)QQQQ,,$(PYTHON_BIN_RES)QQQQ))
65
+ ifneq ($(PYTHON_BIN_RC),0)
66
+ PYTHON_BIN := python3
67
+ endif
68
+
83
69
  # this cannot be a regular target because of the way Makefile.$(SIM) is included
84
70
  ifeq ($(MAKECMDGOALS),help)
85
71
  $(info $(help_targets))
86
72
  $(info $(help_makevars))
87
73
  # hack to get newlines in output, see https://stackoverflow.com/a/54539610
88
74
  # NOTE: the output of the command must not include a '%' sign, otherwise the formatting will break
89
- help_envvars := $(subst %,${newline},$(shell cocotb-config --help-vars | tr \\n %))
75
+ help_envvars := $(subst %,${newline},$(shell $(PYTHON_BIN) -m cocotb.config --help-vars | tr \\n %))
90
76
  $(info ${help_envvars})
91
77
  # is there a cleaner way to exit here?
92
78
  $(error Stopping after printing help)
93
79
  endif
94
80
 
81
+ include $(shell $(PYTHON_BIN) -m cocotb_tools.config --makefiles)/Makefile.inc
82
+
95
83
  # Default to Icarus if no simulator is defined
96
84
  SIM ?= icarus
97
85
 
98
86
  # Maintain backwards compatibility by supporting upper and lower case SIM variable
99
87
  SIM_LOWERCASE := $(shell echo $(SIM) | tr A-Z a-z)
100
88
 
101
- # Directory containing the cocotb Makfiles
102
- COCOTB_MAKEFILES_DIR := $(shell cocotb-config --makefiles)
103
-
104
- include $(COCOTB_MAKEFILES_DIR)/Makefile.deprecations
105
-
106
89
  HAVE_SIMULATOR = $(shell if [ -f $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.$(SIM_LOWERCASE) ]; then echo 1; else echo 0; fi;)
107
90
  AVAILABLE_SIMULATORS = $(patsubst .%,%,$(suffix $(wildcard $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.*)))
108
91