cocotb 1.9.2__cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.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 (89) hide show
  1. cocotb/ANSI.py +92 -0
  2. cocotb/__init__.py +371 -0
  3. cocotb/_deprecation.py +36 -0
  4. cocotb/_py_compat.py +63 -0
  5. cocotb/_sim_versions.py +145 -0
  6. cocotb/_vendor/__init__.py +0 -0
  7. cocotb/_vendor/distutils_version.py +346 -0
  8. cocotb/_version.py +8 -0
  9. cocotb/binary.py +858 -0
  10. cocotb/clock.py +174 -0
  11. cocotb/config.py +289 -0
  12. cocotb/decorators.py +332 -0
  13. cocotb/handle.py +1175 -0
  14. cocotb/ipython_support.py +92 -0
  15. cocotb/libs/libcocotb.so +0 -0
  16. cocotb/libs/libcocotbfli_modelsim.so +0 -0
  17. cocotb/libs/libcocotbutils.so +0 -0
  18. cocotb/libs/libcocotbvhpi_aldec.so +0 -0
  19. cocotb/libs/libcocotbvhpi_ius.so +0 -0
  20. cocotb/libs/libcocotbvhpi_modelsim.so +0 -0
  21. cocotb/libs/libcocotbvhpi_nvc.so +0 -0
  22. cocotb/libs/libcocotbvpi_aldec.so +0 -0
  23. cocotb/libs/libcocotbvpi_ghdl.so +0 -0
  24. cocotb/libs/libcocotbvpi_icarus.vpl +0 -0
  25. cocotb/libs/libcocotbvpi_ius.so +0 -0
  26. cocotb/libs/libcocotbvpi_modelsim.so +0 -0
  27. cocotb/libs/libcocotbvpi_vcs.so +0 -0
  28. cocotb/libs/libcocotbvpi_verilator.so +0 -0
  29. cocotb/libs/libembed.so +0 -0
  30. cocotb/libs/libgpi.so +0 -0
  31. cocotb/libs/libgpilog.so +0 -0
  32. cocotb/libs/libpygpilog.so +0 -0
  33. cocotb/log.py +303 -0
  34. cocotb/memdebug.py +35 -0
  35. cocotb/outcomes.py +56 -0
  36. cocotb/queue.py +179 -0
  37. cocotb/regression.py +933 -0
  38. cocotb/result.py +209 -0
  39. cocotb/runner.py +1400 -0
  40. cocotb/scheduler.py +1099 -0
  41. cocotb/share/def/.gitignore +2 -0
  42. cocotb/share/def/README.md +4 -0
  43. cocotb/share/def/aldec.def +61 -0
  44. cocotb/share/def/ghdl.def +43 -0
  45. cocotb/share/def/icarus.def +43 -0
  46. cocotb/share/def/modelsim.def +137 -0
  47. cocotb/share/include/cocotb_utils.h +93 -0
  48. cocotb/share/include/embed.h +56 -0
  49. cocotb/share/include/exports.h +20 -0
  50. cocotb/share/include/gpi.h +265 -0
  51. cocotb/share/include/gpi_logging.h +212 -0
  52. cocotb/share/include/py_gpi_logging.h +30 -0
  53. cocotb/share/include/vhpi_user_ext.h +26 -0
  54. cocotb/share/include/vpi_user_ext.h +55 -0
  55. cocotb/share/lib/verilator/verilator.cpp +196 -0
  56. cocotb/share/makefiles/Makefile.deprecations +12 -0
  57. cocotb/share/makefiles/Makefile.inc +176 -0
  58. cocotb/share/makefiles/Makefile.sim +113 -0
  59. cocotb/share/makefiles/simulators/Makefile.activehdl +79 -0
  60. cocotb/share/makefiles/simulators/Makefile.cvc +94 -0
  61. cocotb/share/makefiles/simulators/Makefile.ghdl +113 -0
  62. cocotb/share/makefiles/simulators/Makefile.icarus +111 -0
  63. cocotb/share/makefiles/simulators/Makefile.ius +125 -0
  64. cocotb/share/makefiles/simulators/Makefile.modelsim +32 -0
  65. cocotb/share/makefiles/simulators/Makefile.nvc +64 -0
  66. cocotb/share/makefiles/simulators/Makefile.questa +171 -0
  67. cocotb/share/makefiles/simulators/Makefile.riviera +183 -0
  68. cocotb/share/makefiles/simulators/Makefile.vcs +98 -0
  69. cocotb/share/makefiles/simulators/Makefile.verilator +86 -0
  70. cocotb/share/makefiles/simulators/Makefile.xcelium +136 -0
  71. cocotb/simulator.cpython-313-x86_64-linux-gnu.so +0 -0
  72. cocotb/task.py +325 -0
  73. cocotb/triggers.py +1104 -0
  74. cocotb/types/__init__.py +50 -0
  75. cocotb/types/array.py +309 -0
  76. cocotb/types/logic.py +292 -0
  77. cocotb/types/logic_array.py +298 -0
  78. cocotb/types/range.py +198 -0
  79. cocotb/utils.py +698 -0
  80. cocotb/wavedrom.py +199 -0
  81. cocotb/xunit_reporter.py +80 -0
  82. cocotb-1.9.2.dist-info/LICENSE +28 -0
  83. cocotb-1.9.2.dist-info/METADATA +168 -0
  84. cocotb-1.9.2.dist-info/RECORD +89 -0
  85. cocotb-1.9.2.dist-info/WHEEL +6 -0
  86. cocotb-1.9.2.dist-info/entry_points.txt +2 -0
  87. cocotb-1.9.2.dist-info/top_level.txt +21 -0
  88. pygpi/__init__.py +0 -0
  89. pygpi/entry.py +26 -0
cocotb/wavedrom.py ADDED
@@ -0,0 +1,199 @@
1
+ # Copyright cocotb contributors
2
+ # Copyright (c) 2014 Potential Ventures Ltd
3
+ # Licensed under the Revised BSD License, see LICENSE for details.
4
+ # SPDX-License-Identifier: BSD-3-Clause
5
+
6
+ import json
7
+ from collections import OrderedDict, defaultdict
8
+ from collections.abc import Mapping
9
+
10
+ import cocotb
11
+ from cocotb.handle import SimHandleBase
12
+ from cocotb.triggers import ReadOnly, RisingEdge
13
+
14
+ try:
15
+ from cocotb_bus.bus import Bus
16
+ except ImportError:
17
+ Bus = None
18
+
19
+
20
+ class Wavedrom:
21
+ """Base class for a WaveDrom compatible tracer."""
22
+
23
+ def __init__(self, obj, name=""):
24
+ self._hdls = OrderedDict()
25
+ self._name = name
26
+ if isinstance(obj, Mapping):
27
+ self._hdls.update(obj)
28
+ elif isinstance(obj, SimHandleBase):
29
+ name = obj._name.split(".")[-1]
30
+ self._hdls[name] = obj
31
+ self._name = name
32
+ elif Bus is not None and isinstance(obj, Bus):
33
+ self._hdls.update(obj._signals)
34
+ self._name = obj._name
35
+ else:
36
+ raise TypeError(
37
+ "Cannot use {} with {} objects".format(
38
+ type(self).__qualname__, type(obj).__name__
39
+ )
40
+ ) from None
41
+ self.clear()
42
+
43
+ def sample(self):
44
+ """Record a sample of the signal value at this point in time."""
45
+
46
+ def _lastval(samples):
47
+ for x in range(len(samples) - 1, -1, -1):
48
+ if samples[x] not in "=.|":
49
+ return samples[x]
50
+ return None
51
+
52
+ for name, hdl in self._hdls.items():
53
+ val = hdl.value
54
+ valstr = val.binstr.lower()
55
+
56
+ # Decide what character to use to represent this signal
57
+ if len(valstr) == 1:
58
+ char = valstr
59
+ elif "x" in valstr:
60
+ char = "x"
61
+ elif "u" in valstr:
62
+ char = "u"
63
+ elif "z" in valstr:
64
+ char = "z"
65
+ else:
66
+ if (
67
+ len(self._data[name])
68
+ and self._data[name][-1] == int(val)
69
+ and self._samples[name][-1] in "=."
70
+ ):
71
+ char = "."
72
+ else:
73
+ char = "="
74
+ self._data[name].append(int(val))
75
+
76
+ # Detect if this is unchanged
77
+ if len(valstr) == 1 and char == _lastval(self._samples[name]):
78
+ char = "."
79
+ self._samples[name].append(char)
80
+
81
+ def clear(self):
82
+ """Delete all sampled data."""
83
+ self._samples = defaultdict(list)
84
+ self._data = defaultdict(list)
85
+
86
+ def gap(self):
87
+ for name, hdl in self._hdls.items():
88
+ self._samples[name].append("|")
89
+
90
+ def get(self, add_clock=True):
91
+ """Return the samples as a list suitable for use with WaveDrom."""
92
+ siglist = []
93
+ traces = []
94
+ for name in self._hdls.keys():
95
+ samples = self._samples[name]
96
+ traces.append({"name": name, "wave": "".join(samples)})
97
+ if name in self._data:
98
+ traces[-1]["data"] = " ".join([repr(s) for s in self._data[name]])
99
+
100
+ if len(traces) > 1:
101
+ traces.insert(0, self._name)
102
+ siglist.append(traces)
103
+ else:
104
+ siglist.append(traces[0])
105
+
106
+ if add_clock:
107
+ tracelen = len(traces[-1]["wave"])
108
+ siglist.insert(0, {"name": "clk", "wave": "p" + "." * (tracelen - 1)})
109
+
110
+ return siglist
111
+
112
+
113
+ class trace:
114
+ """Context manager to enable tracing of signals.
115
+
116
+ Arguments are an arbitrary number of signals or buses to trace.
117
+ We also require a clock to sample on, passed in as a keyword argument.
118
+
119
+ Usage::
120
+
121
+ with trace(sig1, sig2, a_bus, clk=clk) as waves:
122
+ # Stuff happens, we trace it
123
+
124
+ # Dump to JSON format compatible with WaveDrom
125
+ j = waves.dumpj()
126
+ """
127
+
128
+ def __init__(self, *args, clk=None):
129
+ self._clock = clk
130
+ self._signals = []
131
+ for arg in args:
132
+ self._signals.append(Wavedrom(arg))
133
+ self._coro = None
134
+ self._clocks = 0
135
+ self._enabled = False
136
+
137
+ if self._clock is None:
138
+ raise ValueError("Trace requires a clock to sample")
139
+
140
+ async def _monitor(self):
141
+ self._clocks = 0
142
+ while True:
143
+ await RisingEdge(self._clock)
144
+ await ReadOnly()
145
+ if not self._enabled:
146
+ continue
147
+ self._clocks += 1
148
+ for sig in self._signals:
149
+ sig.sample()
150
+
151
+ def insert_gap(self):
152
+ self._clocks += 1
153
+ for sig in self._signals:
154
+ sig.gap()
155
+
156
+ def disable(self):
157
+ self._enabled = False
158
+
159
+ def enable(self):
160
+ self._enabled = True
161
+
162
+ def __enter__(self):
163
+ for sig in self._signals:
164
+ sig.clear()
165
+ self.enable()
166
+ self._coro = cocotb.start_soon(self._monitor())
167
+ return self
168
+
169
+ def __exit__(self, exc_type, exc_val, exc_tb):
170
+ self._coro.kill()
171
+ for sig in self._signals:
172
+ sig.clear()
173
+ self.disable()
174
+ return None
175
+
176
+ def write(self, filename, **kwargs):
177
+ with open(filename, "w") as f:
178
+ f.write(self.dumpj(**kwargs))
179
+
180
+ def dumpj(self, header="", footer="", config=""):
181
+ trace = {"signal": []}
182
+ trace["signal"].append(
183
+ {"name": "clock", "wave": "p" + "." * (self._clocks - 1)}
184
+ )
185
+ for sig in self._signals:
186
+ trace["signal"].extend(sig.get(add_clock=False))
187
+ if header:
188
+ if isinstance(header, dict):
189
+ trace["head"] = header
190
+ else:
191
+ trace["head"] = {"text": header}
192
+ if footer:
193
+ if isinstance(footer, dict):
194
+ trace["foot"] = footer
195
+ else:
196
+ trace["foot"] = {"text": footer}
197
+ if config:
198
+ trace["config"] = config
199
+ return json.dumps(trace, indent=4, sort_keys=False)
@@ -0,0 +1,80 @@
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 xml.etree.ElementTree as ET
29
+ from xml.etree.ElementTree import Element, SubElement
30
+
31
+
32
+ class XUnitReporter:
33
+ def __init__(self, filename="results.xml"):
34
+ self.results = Element("testsuites", name="results")
35
+ self.filename = filename
36
+
37
+ def add_testsuite(self, **kwargs):
38
+ self.last_testsuite = SubElement(self.results, "testsuite", **kwargs)
39
+ return self.last_testsuite
40
+
41
+ def add_testcase(self, testsuite=None, **kwargs):
42
+ if testsuite is None:
43
+ testsuite = self.last_testsuite
44
+ self.last_testcase = SubElement(testsuite, "testcase", **kwargs)
45
+ return self.last_testcase
46
+
47
+ def add_property(self, testsuite=None, **kwargs):
48
+ if testsuite is None:
49
+ testsuite = self.last_testsuite
50
+ self.last_property = SubElement(testsuite, "property", **kwargs)
51
+ return self.last_property
52
+
53
+ def add_failure(self, testcase=None, **kwargs):
54
+ if testcase is None:
55
+ testcase = self.last_testcase
56
+ SubElement(testcase, "failure", **kwargs)
57
+
58
+ def add_skipped(self, testcase=None, **kwargs):
59
+ if testcase is None:
60
+ testcase = self.last_testcase
61
+ SubElement(testcase, "skipped", **kwargs)
62
+
63
+ def indent(self, elem, level=0):
64
+ i = "\n" + level * " "
65
+ if len(elem):
66
+ if not elem.text or not elem.text.strip():
67
+ elem.text = i + " "
68
+ if not elem.tail or not elem.tail.strip():
69
+ elem.tail = i
70
+ for elem in elem:
71
+ self.indent(elem, level + 1)
72
+ if not elem.tail or not elem.tail.strip():
73
+ elem.tail = i
74
+ else:
75
+ if level and (not elem.tail or not elem.tail.strip()):
76
+ elem.tail = i
77
+
78
+ def write(self):
79
+ self.indent(self.results)
80
+ ET.ElementTree(self.results).write(self.filename, encoding="UTF-8")
@@ -0,0 +1,28 @@
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
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ 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.
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.1
2
+ Name: cocotb
3
+ Version: 1.9.2
4
+ Summary: cocotb is a coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python.
5
+ Home-page: https://www.cocotb.org
6
+ Author: Chris Higgs, Stuart Hodgson
7
+ Maintainer: cocotb contributors
8
+ Maintainer-email: cocotb@lists.librecores.org
9
+ License: BSD
10
+ Project-URL: Bug Tracker, https://github.com/cocotb/cocotb/issues
11
+ Project-URL: Source Code, https://github.com/cocotb/cocotb
12
+ Project-URL: Documentation, https://docs.cocotb.org
13
+ Platform: any
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.6
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: License :: OSI Approved :: BSD License
24
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
25
+ Classifier: Framework :: cocotb
26
+ Requires-Python: >=3.6
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: find-libpython
30
+ Provides-Extra: bus
31
+ Requires-Dist: cocotb-bus; extra == "bus"
32
+
33
+ **cocotb** is a coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python.
34
+
35
+ [![Documentation Status](https://readthedocs.org/projects/cocotb/badge/?version=latest)](https://docs.cocotb.org/en/latest/)
36
+ [![CI](https://github.com/cocotb/cocotb/actions/workflows/build-test-dev.yml/badge.svg?branch=master)](https://github.com/cocotb/cocotb/actions/workflows/build-test-dev.yml)
37
+ [![PyPI](https://img.shields.io/pypi/dm/cocotb.svg?label=PyPI%20downloads)](https://pypi.org/project/cocotb/)
38
+ [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cocotb/cocotb)
39
+ [![codecov](https://codecov.io/gh/cocotb/cocotb/branch/master/graph/badge.svg)](https://codecov.io/gh/cocotb/cocotb)
40
+
41
+ * Read the [documentation](https://docs.cocotb.org)
42
+ * Get involved:
43
+ * [Raise a bug / request an enhancement](https://github.com/cocotb/cocotb/issues/new) (Requires a GitHub account)
44
+ * [Join the Gitter chat room](https://gitter.im/cocotb/Lobby)
45
+
46
+ ## Installation
47
+
48
+ The current stable version of cocotb requires:
49
+
50
+ - Python 3.6+
51
+ - GNU Make 3+
52
+ - An HDL simulator (such as [Icarus Verilog](https://docs.cocotb.org/en/stable/simulator_support.html#icarus-verilog),
53
+ [Verilator](https://docs.cocotb.org/en/stable/simulator_support.html#verilator),
54
+ [GHDL](https://docs.cocotb.org/en/stable/simulator_support.html#ghdl) or
55
+ [other simulator](https://docs.cocotb.org/en/stable/simulator_support.html))
56
+
57
+ After installing these dependencies, the latest stable version 1.x of cocotb can be installed with pip.
58
+
59
+ ```command
60
+ pip install 'cocotb == 1.*'
61
+ ```
62
+
63
+ For more details on installation, including prerequisites,
64
+ see [the documentation](https://docs.cocotb.org/en/stable/install.html).
65
+
66
+ For details on how to install the *development* version of cocotb,
67
+ see [the preliminary documentation of the future release](https://docs.cocotb.org/en/latest/install_devel.html#install-devel).
68
+
69
+ **!!! Bus and Testbenching Components !!!**
70
+ The reusable bus interfaces and testbenching components have recently been moved to the [cocotb-bus](https://github.com/cocotb/cocotb-bus) package.
71
+ You can easily install these at the same time as cocotb by adding the `bus` extra install: `pip install cocotb[bus]`.
72
+
73
+ ## Usage
74
+
75
+ As a first trivial introduction to cocotb, the following example "tests" a flip-flop.
76
+
77
+ First, we need a hardware design which we can test. For this example, create a file `dff.sv` with SystemVerilog code for a simple [D flip-flop](https://en.wikipedia.org/wiki/Flip-flop_(electronics)#D_flip-flop). You could also use any other language a [cocotb-supported simulator](https://docs.cocotb.org/en/stable/simulator_support.html) understands, e.g. VHDL.
78
+
79
+ ```systemverilog
80
+ // dff.sv
81
+
82
+ `timescale 1us/1ns
83
+
84
+ module dff (
85
+ output logic q,
86
+ input logic clk, d
87
+ );
88
+
89
+ always @(posedge clk) begin
90
+ q <= d;
91
+ end
92
+
93
+ endmodule
94
+ ```
95
+
96
+ An example of a simple randomized cocotb testbench:
97
+
98
+ ```python
99
+ # test_dff.py
100
+
101
+ import random
102
+
103
+ import cocotb
104
+ from cocotb.clock import Clock
105
+ from cocotb.triggers import RisingEdge
106
+ from cocotb.types import LogicArray
107
+
108
+ @cocotb.test()
109
+ async def dff_simple_test(dut):
110
+ """Test that d propagates to q"""
111
+
112
+ # Assert initial output is unknown
113
+ assert LogicArray(dut.q.value) == LogicArray("X")
114
+ # Set initial input value to prevent it from floating
115
+ dut.d.value = 0
116
+
117
+ clock = Clock(dut.clk, 10, units="us") # Create a 10us period clock on port clk
118
+ # Start the clock. Start it low to avoid issues on the first RisingEdge
119
+ cocotb.start_soon(clock.start(start_high=False))
120
+
121
+ # Synchronize with the clock. This will regisiter the initial `d` value
122
+ await RisingEdge(dut.clk)
123
+ expected_val = 0 # Matches initial input value
124
+ for i in range(10):
125
+ val = random.randint(0, 1)
126
+ dut.d.value = val # Assign the random value val to the input port d
127
+ await RisingEdge(dut.clk)
128
+ assert dut.q.value == expected_val, f"output q was incorrect on the {i}th cycle"
129
+ expected_val = val # Save random value for next RisingEdge
130
+
131
+ # Check the final input on the next clock
132
+ await RisingEdge(dut.clk)
133
+ assert dut.q.value == expected_val, "output q was incorrect on the last cycle"
134
+ ```
135
+
136
+ A simple Makefile:
137
+
138
+ ```make
139
+ # Makefile
140
+
141
+ TOPLEVEL_LANG = verilog
142
+ VERILOG_SOURCES = $(shell pwd)/dff.sv
143
+ TOPLEVEL = dff
144
+ MODULE = test_dff
145
+
146
+ include $(shell cocotb-config --makefiles)/Makefile.sim
147
+ ```
148
+
149
+ In order to run the test with Icarus Verilog, execute:
150
+
151
+ ```command
152
+ make SIM=icarus
153
+ ```
154
+
155
+ [![asciicast](https://asciinema.org/a/317220.svg)](https://asciinema.org/a/317220)
156
+
157
+ For more information please see the [cocotb documentation](https://docs.cocotb.org/)
158
+ and [our wiki](https://github.com/cocotb/cocotb/wiki).
159
+
160
+ ## Tutorials, examples and related projects
161
+
162
+ * the tutorial section [in the official documentation](https://docs.cocotb.org/)
163
+ * [cocotb-bus](https://github.com/cocotb/cocotb-bus) for pre-packaged testbenching tools and reusable bus interfaces.
164
+ * [cocotb-based USB 1.1 test suite](https://github.com/antmicro/usb-test-suite-build) for FPGA IP, with testbenches for a variety of open source USB cores
165
+ * [`cocotb-coverage`](https://github.com/mciepluc/cocotb-coverage), an extension for Functional Coverage and Constrained Randomization
166
+ * [`uvm-python`](https://github.com/tpoikela/uvm-python), an almost 1:1 port of UVM 1.2 to Python
167
+ * our wiki [on extension modules](https://github.com/cocotb/cocotb/wiki/Further-Resources#extension-modules-cocotbext)
168
+ * the list of [GitHub projects depending on cocotb](https://github.com/cocotb/cocotb/network/dependents)
@@ -0,0 +1,89 @@
1
+ cocotb/utils.py,sha256=ZMpOTWY68lcFax3xwK5PNNIV5xUCbBtwHCG98WvCIt0,23064
2
+ cocotb/_sim_versions.py,sha256=nbUkauB7RKure0FrUz52sHkJzoAeErEKZQeUfhryrvY,3544
3
+ cocotb/binary.py,sha256=pvlBIKIA1gQpauoJ4PP9FR01gQzv1aSQCNG3pl3uZl4,27243
4
+ cocotb/outcomes.py,sha256=UVNkuFcUOhTz6lU2zJzNcTR4Fcc_thRr0zYYO72Yg0o,1299
5
+ cocotb/__init__.py,sha256=L02Hgsr8ot_i4Pfs-U3gRy9yQHtbK2lks2JLvQX7yAg,11810
6
+ cocotb/simulator.cpython-313-x86_64-linux-gnu.so,sha256=kZB81rDr3zLi_lOFbNcGtpjNU-8nPtgUVoz7oOqIWL4,121360
7
+ cocotb/scheduler.py,sha256=k0YhH6PXpD_3-a3ZpIS92QDSdLFxMIN1EIxYenU9f5Y,41039
8
+ cocotb/log.py,sha256=ydt4ZFo1iuvFRp9uu05KBhN1-bK-gH0huCbE8xbG6PY,10443
9
+ cocotb/triggers.py,sha256=jGdbOEojYKoXmS2rrZAsPPeIIT0pPJAcdcGzGKY_854,34973
10
+ cocotb/regression.py,sha256=OmIZ1xEdIgRFOXuzd8Pcr7_iRVs1YDXlrg9nCKJlVOs,32745
11
+ cocotb/memdebug.py,sha256=aqATHovldb8sqihqeb4k0tqOrUYKvIOBxxueo_6xfPc,1853
12
+ cocotb/runner.py,sha256=sP7YS7gs8mXvP9-sqoKdJE2Cm5t6-hAuDq3sFsnJiAs,50285
13
+ cocotb/handle.py,sha256=Hh23PPe8uWwR3QtCMnMpCUu6YPPm0OkeKpAwI8-X7yY,41627
14
+ cocotb/_version.py,sha256=g8Rf3408MO21ZRkd6h7E8LPz8TZ6cIDAwuiPbjN7ufg,295
15
+ cocotb/clock.py,sha256=tYbDZ5K9mDmqLTMMWtvH_4t_8vVPWQGTMq96iV1NEa0,6560
16
+ cocotb/_deprecation.py,sha256=-yCa2_9m_6-NX4RZIKibpVKlIlb7eDdXnmINqoxeGcA,1153
17
+ cocotb/wavedrom.py,sha256=xWhefs5G5L79Wusw8poY1h8x_VFeSlsnXbRrfj3VNhg,5988
18
+ cocotb/task.py,sha256=4TvJ3YHjDV6-ZhTVe2xJHE1dLjcx8rAphCfDcpDOdLU,11035
19
+ cocotb/result.py,sha256=JIAU09jxSSw99xWcY0SI7IM31vkx64G9IpdujThvmcI,6696
20
+ cocotb/queue.py,sha256=ZHaad7RMKla0NqC2k06DmVV7wXrtrteRVx19iE-0_5w,5159
21
+ cocotb/ANSI.py,sha256=cIm1ri5vWE-EFKZTzXZD_KLwhDRLJkv5iAo1sObI5rE,3366
22
+ cocotb/ipython_support.py,sha256=BzuYzDfNYgsjqL-ICtCxaHE3Mi4hY021fqzM5cUWx8Y,3136
23
+ cocotb/_py_compat.py,sha256=XniZ0qjkAyYFxaCEZnny0ZM8yi7OIAJp9VE3V3OMHuo,2691
24
+ cocotb/config.py,sha256=Bt7zHgQTraNlNNH__jk05V1hr9Wd9TMSntax3OYASUA,9654
25
+ cocotb/xunit_reporter.py,sha256=--rbUiTXMjqJw8XdcG-49TfF_zwqdVAIvaORl0dohp0,3552
26
+ cocotb/decorators.py,sha256=ZAvvXXYwJu1klH9Gd7G7_wANUqztCl74XboYkAkZryQ,11727
27
+ cocotb/types/__init__.py,sha256=ypCqqSf7agV6XoJ6P0nVvRAw2m82G5kx6A2yiiVmrr0,1803
28
+ cocotb/types/logic.py,sha256=PUOTAkpcM4nFGW4kaqA-Za1BC3uYzxZmq7SqAlPWSNo,8499
29
+ cocotb/types/range.py,sha256=MbO76LYIxR1r0eki-SSP3XOtypu4_etXUHWmNCi4gNw,6230
30
+ cocotb/types/array.py,sha256=pI8OYL6WY6I9nZkwqyn9S98bWNBlEqwM8TueZA2OaWc,10899
31
+ cocotb/types/logic_array.py,sha256=C8gHjUmof4P9hYwVOnFMjBgH0xKz0XjmWjtVvCisBbU,9957
32
+ cocotb/libs/libcocotbvpi_ius.so,sha256=gh2-xwSOlPNUFS88ipP2ZHf5Yg9fGIzv3txQfjDLuMI,989720
33
+ cocotb/libs/libembed.so,sha256=bgIHVZb-F7vWz9GEBZuX2FZnGMpMPCADQ1eYsFA3pS8,23872
34
+ cocotb/libs/libgpilog.so,sha256=M2Hy_-IIbFxu5y61TjQBgex79K1VWrBMPuXHLHwMJvI,332824
35
+ cocotb/libs/libcocotbvpi_ghdl.so,sha256=PDTI-TI0uhmUyjh1ibro9mkc013N4Q49kzXrucXW9JI,1001968
36
+ cocotb/libs/libcocotbutils.so,sha256=YA0peQAH0ufyy8CMMQYYVoEMo32jf1j65iUJ0mcmJ-0,23464
37
+ cocotb/libs/libcocotbvpi_vcs.so,sha256=PDTI-TI0uhmUyjh1ibro9mkc013N4Q49kzXrucXW9JI,1001968
38
+ cocotb/libs/libcocotbvhpi_nvc.so,sha256=Nd8obaXHUE1CK_ZPItdrNJJSGwJDdC4pN5OWe-4fRhI,1100616
39
+ cocotb/libs/libcocotbvpi_verilator.so,sha256=p1EPItGw9IIb5J_L-Cz1R87qR4K9kSn81vYCNvg4l70,1003632
40
+ cocotb/libs/libgpi.so,sha256=DzCsqREhw8dSnoUeQ786KF2EX5P4EePj_t203lL761w,533576
41
+ cocotb/libs/libcocotbvhpi_modelsim.so,sha256=NsptCZbcxzLjP7Y4NKYH0d9PPJrxgTVT8eYJ_s9OLLc,1095048
42
+ cocotb/libs/libpygpilog.so,sha256=U3_8z-pxndhqWtBKskswOlyHUAgs9eK3BEi3nAjA9t8,105952
43
+ cocotb/libs/libcocotbfli_modelsim.so,sha256=UzluGS1JIsW-ueOTYR494YeaxQa7EnJIapEfBCF2C90,1506152
44
+ cocotb/libs/libcocotbvhpi_aldec.so,sha256=G0EkFAIfrf-ZpTOJb2ZV6HgtBgPhu4_nNoiFKeZeNak,1095048
45
+ cocotb/libs/libcocotbvhpi_ius.so,sha256=t_bVLeSF2ODnJ-ddUKzPt5Q5AuWG8EPbx43zCXwqW8I,1095704
46
+ cocotb/libs/libcocotbvpi_icarus.vpl,sha256=PDTI-TI0uhmUyjh1ibro9mkc013N4Q49kzXrucXW9JI,1001968
47
+ cocotb/libs/libcocotbvpi_aldec.so,sha256=PDTI-TI0uhmUyjh1ibro9mkc013N4Q49kzXrucXW9JI,1001968
48
+ cocotb/libs/libcocotbvpi_modelsim.so,sha256=bu_Cg8uzn9EE3O0k5qrfFn0vh29YdQo_q22hZU3vtcU,1003056
49
+ cocotb/libs/libcocotb.so,sha256=5kpfu6HucMpSa8mVbnEFrjIDBEGJQ7AOvRtJqSqtItk,272768
50
+ cocotb/_vendor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
+ cocotb/_vendor/distutils_version.py,sha256=sJSPH4U0N8A-kDlLnWk6rmYVcp0FQ5asmDr43NLkBuk,12839
52
+ cocotb/share/include/embed.h,sha256=KuwYCj2fg3xNrmMwCJeWCkxn5PgonbQRjhFobvtvmJg,2453
53
+ cocotb/share/include/gpi_logging.h,sha256=DHYms7LrdXD4O7QGjzDs5HQeQVwesaNH8RcUrbPzhYc,10341
54
+ cocotb/share/include/vpi_user_ext.h,sha256=ZOcMKuwvVLtJyPNN5k8Dp_2I11W3tk-Sk3aTnsxMYTI,2456
55
+ cocotb/share/include/exports.h,sha256=g9W56sF9imgH2Lj0WMJ-KYQxvaDkEDlbWk6SMQBEus8,657
56
+ cocotb/share/include/py_gpi_logging.h,sha256=TvPV2PFArqIxDGu9xzdoijeArEKnuj2R54dRyq3IHHc,642
57
+ cocotb/share/include/cocotb_utils.h,sha256=SU_Sdl4TbcZLGoGyTfQxti_9Qx4qjnzPvO-2G71Yv0g,3998
58
+ cocotb/share/include/vhpi_user_ext.h,sha256=Pa8_2UZwEkv-eo4AHxd9LfwJ6fYaKF41X90hnYU5aYg,628
59
+ cocotb/share/include/gpi.h,sha256=srIx1hhifQ_O8ymbe60EzoRr7zUZ4WFO9rMnITrBses,9999
60
+ cocotb/share/lib/verilator/verilator.cpp,sha256=O31U_LFTIRNsUHmbJjnFTib-82EPDcVQ3UR9yj2c0b8,5734
61
+ cocotb/share/def/icarus.def,sha256=HkplSgynTbyVSY4tHmK3bgqWdQKG42LzbkR-4CjhW_M,655
62
+ cocotb/share/def/.gitignore,sha256=8esJ3SRQwSrq7hqrco6wqpuAwmbOFRtkaJdndujviKY,44
63
+ cocotb/share/def/README.md,sha256=Y6LZM38BseXAURHcgcM4MUPJuJ-UUgPjXIpg9P9fEiA,376
64
+ cocotb/share/def/ghdl.def,sha256=6Ms8xLFjCCnL7_F_tZx2DOeHCAmI5Pqym2_wfV9SXso,662
65
+ cocotb/share/def/modelsim.def,sha256=VpsMn-bIS2NEzXTRt_pErFPpf-l_QZrXIw23NUBkVK4,2252
66
+ cocotb/share/def/aldec.def,sha256=4IOhz9LD4c-jNtP4OH6SXjXmo2C8hGwt_Ll7MBxbk2I,930
67
+ cocotb/share/makefiles/Makefile.deprecations,sha256=W9TsO2YcoUDg-eSnmzy-qKoaMWDsbTBaThizTVDOHiI,416
68
+ cocotb/share/makefiles/Makefile.inc,sha256=i_2F77QC8tCDmuDOyFaU8wuS5c6M2rT9RBSrMXls2hM,6710
69
+ cocotb/share/makefiles/Makefile.sim,sha256=HozYCWwQU1Qe2eeEyeU4fQqnMHrytFLrQFgm-T8Ka64,5293
70
+ cocotb/share/makefiles/simulators/Makefile.questa,sha256=Qqz0P8MGipCvsS5RBUtx7v8XHErTZf7SeSrAfOwM624,6561
71
+ cocotb/share/makefiles/simulators/Makefile.cvc,sha256=T29SoVjycTQZvCBVLrK1hAtNUBZcGUjuqVgSHgPPqZY,3919
72
+ cocotb/share/makefiles/simulators/Makefile.ius,sha256=4FVXbyaVRmTw1zAF6z3EsD0schfsGzVPsVuMXCpneJA,4951
73
+ cocotb/share/makefiles/simulators/Makefile.nvc,sha256=qec9doM_JsPqnDFzfA7wRXd2c9p29XPC58mzl5n_Dqs,2123
74
+ cocotb/share/makefiles/simulators/Makefile.ghdl,sha256=USZfU8lHX7tt-f1WzOgTMQU7DUsv7zad7Cnuwvk3GOA,4736
75
+ cocotb/share/makefiles/simulators/Makefile.vcs,sha256=-qG38z_449aqygByZglkccLWbXpntAK1pgKC1IO3zqE,3745
76
+ cocotb/share/makefiles/simulators/Makefile.riviera,sha256=o5Qw1C0Y-1LeGODGRBGD_4ugvZfPcw1Q0P_wS28Rjmg,6877
77
+ cocotb/share/makefiles/simulators/Makefile.activehdl,sha256=DgHAMahrDJJZG7pN4XSwSAZy1w7dx-IBMlKij8RgGao,2805
78
+ cocotb/share/makefiles/simulators/Makefile.modelsim,sha256=9g63PU5kKxBKAznOQ3v9zJK3PYfmuAZlJNvzHp4HZuY,1906
79
+ cocotb/share/makefiles/simulators/Makefile.xcelium,sha256=kw3AAYVJlWR-E6ti9DqsB36xu-6y0Vi3280F50nuvXA,5626
80
+ cocotb/share/makefiles/simulators/Makefile.verilator,sha256=B0je4MFhqIkJzR5y2lDc8sB4So7O6VH0VuQpwdT7Ko4,2624
81
+ cocotb/share/makefiles/simulators/Makefile.icarus,sha256=4s1VVBtdkSDgdkDmmlrmWEXTf-BbohEB3sEEd63qM5Q,4367
82
+ cocotb-1.9.2.dist-info/top_level.txt,sha256=Fl4sx6K1RYh5oUwTHM1KkMz54rCexCBjdDi5QiC8McE,546
83
+ cocotb-1.9.2.dist-info/RECORD,,
84
+ cocotb-1.9.2.dist-info/LICENSE,sha256=8u54oq_hgh2uhGSCf5Fo3UpyB6DoAluUkPWp-ES7AFU,1542
85
+ cocotb-1.9.2.dist-info/entry_points.txt,sha256=Z2JL-ZgU-G5au6uYpkWZz9Pfk7qnh4fcoQJmBxnHSZQ,53
86
+ cocotb-1.9.2.dist-info/METADATA,sha256=9kG9EoGeVu8-Y5HL3eNMfAM3Ao9T8I0_UECnZbCOLag,6901
87
+ cocotb-1.9.2.dist-info/WHEEL,sha256=uMnaYNKCFgO8r6wjWpmUw-NS7WECQvHGV6T7wbxMyF8,151
88
+ pygpi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
89
+ pygpi/entry.py,sha256=DYNuWRXyh60vjyM95JFltJSF67XtGkiqBD73-O37iXc,946
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.2.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-manylinux_2_17_x86_64
5
+ Tag: cp313-cp313-manylinux2014_x86_64
6
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cocotb-config = cocotb.config:main
@@ -0,0 +1,21 @@
1
+ cocotb
2
+ cocotb/libs/libcocotb
3
+ cocotb/libs/libcocotbfli_modelsim
4
+ cocotb/libs/libcocotbutils
5
+ cocotb/libs/libcocotbvhpi_aldec
6
+ cocotb/libs/libcocotbvhpi_ius
7
+ cocotb/libs/libcocotbvhpi_modelsim
8
+ cocotb/libs/libcocotbvhpi_nvc
9
+ cocotb/libs/libcocotbvpi_aldec
10
+ cocotb/libs/libcocotbvpi_ghdl
11
+ cocotb/libs/libcocotbvpi_icarus
12
+ cocotb/libs/libcocotbvpi_ius
13
+ cocotb/libs/libcocotbvpi_modelsim
14
+ cocotb/libs/libcocotbvpi_vcs
15
+ cocotb/libs/libcocotbvpi_verilator
16
+ cocotb/libs/libembed
17
+ cocotb/libs/libgpi
18
+ cocotb/libs/libgpilog
19
+ cocotb/libs/libpygpilog
20
+ cocotb/simulator
21
+ pygpi
pygpi/__init__.py ADDED
File without changes
pygpi/entry.py ADDED
@@ -0,0 +1,26 @@
1
+ import importlib
2
+ import os
3
+ from functools import reduce
4
+ from types import ModuleType
5
+ from typing import Callable, Tuple
6
+
7
+
8
+ def load_entry() -> Tuple[ModuleType, Callable]:
9
+ """Gather entry point information by parsing :envvar:`PYGPI_ENTRY_POINT`."""
10
+ entry_point_str = os.environ.get(
11
+ "PYGPI_ENTRY_POINT", "cocotb:_initialise_testbench"
12
+ )
13
+ try:
14
+ if ":" not in entry_point_str:
15
+ raise ValueError(
16
+ "Invalid PYGPI_ENTRY_POINT, missing entry function (no colon)."
17
+ )
18
+ entry_module_str, entry_func_str = entry_point_str.split(":", 1)
19
+ entry_module = importlib.import_module(entry_module_str)
20
+ entry_func = reduce(getattr, entry_func_str.split("."), entry_module)
21
+ except Exception as e:
22
+ raise RuntimeError(
23
+ "Failure to parse PYGPI_ENTRY_POINT ('{}')".format(entry_point_str)
24
+ ) from e
25
+ else:
26
+ return entry_module, entry_func