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
@@ -0,0 +1,196 @@
1
+ // Copyright cocotb contributors
2
+ // Licensed under the Revised BSD License, see LICENSE for details.
3
+ // SPDX-License-Identifier: BSD-3-Clause
4
+
5
+ #include <libgen.h> // basename
6
+ #include <stdio.h> // stderr, fprintf
7
+
8
+ #include <memory> // std::unique_ptr
9
+ #include <string> // std::string
10
+
11
+ #include "Vtop.h"
12
+ #include "verilated.h"
13
+ #include "verilated_vpi.h"
14
+
15
+ #ifndef VM_TRACE_FST
16
+ // emulate new verilator behavior for legacy versions
17
+ #define VM_TRACE_FST 0
18
+ #endif
19
+
20
+ #if VM_TRACE
21
+ #if VM_TRACE_FST
22
+ #include <verilated_fst_c.h>
23
+ #else
24
+ #include <verilated_vcd_c.h>
25
+ #endif
26
+ #endif
27
+
28
+ static vluint64_t main_time = 0; // Current simulation time
29
+
30
+ double sc_time_stamp() { // Called by $time in Verilog
31
+ return main_time; // converts to double, to match
32
+ // what SystemC does
33
+ }
34
+
35
+ extern "C" {
36
+ void vlog_startup_routines_bootstrap(void);
37
+ }
38
+
39
+ static inline bool settle_value_callbacks() {
40
+ bool cbs_called, again;
41
+
42
+ // Call Value Change callbacks
43
+ // These can modify signal values so we loop
44
+ // until there are no more changes
45
+ cbs_called = again = VerilatedVpi::callValueCbs();
46
+ while (again) {
47
+ again = VerilatedVpi::callValueCbs();
48
+ }
49
+
50
+ return cbs_called;
51
+ }
52
+
53
+ int main(int argc, char** argv) {
54
+ bool traceOn = false;
55
+ #if VM_TRACE_FST
56
+ const char* traceFile = "dump.fst";
57
+ #else
58
+ const char* traceFile = "dump.vcd";
59
+ #endif
60
+
61
+ for (int i = 1; i < argc; i++) {
62
+ std::string arg = std::string(argv[i]);
63
+ if (arg == "--trace") {
64
+ traceOn = true;
65
+ } else if (arg == "--trace-file") {
66
+ if (++i < argc) {
67
+ traceFile = argv[i];
68
+ } else {
69
+ fprintf(stderr, "Error: --trace-file requires a parameter\n");
70
+ return -1;
71
+ }
72
+ } else if (arg == "--help") {
73
+ fprintf(stderr,
74
+ "usage: %s [--trace] [--trace-file TRACEFILE]\n"
75
+ "\n"
76
+ "Cocotb + Verilator sim\n"
77
+ "\n"
78
+ "options:\n"
79
+ " --trace Enables tracing (VCD or FST)\n"
80
+ " --trace-file Specifies the trace file name (%s by "
81
+ "default)\n",
82
+ basename(argv[0]), traceFile);
83
+ return 0;
84
+ }
85
+ }
86
+
87
+ Verilated::commandArgs(argc, argv);
88
+ #ifdef VERILATOR_SIM_DEBUG
89
+ Verilated::debug(99);
90
+ #endif
91
+ std::unique_ptr<Vtop> top(new Vtop(""));
92
+ Verilated::fatalOnVpiError(false); // otherwise it will fail on systemtf
93
+
94
+ #ifdef VERILATOR_SIM_DEBUG
95
+ Verilated::internalsDump();
96
+ #endif
97
+
98
+ vlog_startup_routines_bootstrap();
99
+ VerilatedVpi::callCbs(cbStartOfSimulation);
100
+
101
+ #if VM_TRACE
102
+ #if VM_TRACE_FST
103
+ std::unique_ptr<VerilatedFstC> tfp(new VerilatedFstC);
104
+ #else
105
+ std::unique_ptr<VerilatedVcdC> tfp(new VerilatedVcdC);
106
+ #endif
107
+
108
+ if (traceOn) {
109
+ Verilated::traceEverOn(true);
110
+ top->trace(tfp.get(), 99);
111
+ tfp->open(traceFile);
112
+ }
113
+ #endif
114
+
115
+ while (!Verilated::gotFinish()) {
116
+ // Call registered timed callbacks (e.g. clock timer)
117
+ // These are called at the beginning of the time step
118
+ // before the iterative regions (IEEE 1800-2012 4.4.1)
119
+ VerilatedVpi::callTimedCbs();
120
+
121
+ // Call Value Change callbacks triggered by Timer callbacks
122
+ // These can modify signal values
123
+ settle_value_callbacks();
124
+
125
+ // We must evaluate whole design until we process all 'events'
126
+ bool again = true;
127
+ while (again) {
128
+ // Evaluate design
129
+ top->eval_step();
130
+
131
+ // Call Value Change callbacks triggered by eval()
132
+ // These can modify signal values
133
+ again = settle_value_callbacks();
134
+
135
+ // Call registered ReadWrite callbacks
136
+ again |= VerilatedVpi::callCbs(cbReadWriteSynch);
137
+
138
+ // Call Value Change callbacks triggered by ReadWrite callbacks
139
+ // These can modify signal values
140
+ again |= settle_value_callbacks();
141
+ }
142
+ top->eval_end_step();
143
+
144
+ // Call ReadOnly callbacks
145
+ VerilatedVpi::callCbs(cbReadOnlySynch);
146
+
147
+ #if VM_TRACE
148
+ if (traceOn) {
149
+ tfp->dump(main_time);
150
+ }
151
+ #endif
152
+ // cocotb controls the clock inputs using cbAfterDelay so
153
+ // skip ahead to the next registered callback
154
+ const vluint64_t NO_TOP_EVENTS_PENDING = static_cast<vluint64_t>(~0ULL);
155
+ vluint64_t next_time_cocotb = VerilatedVpi::cbNextDeadline();
156
+ vluint64_t next_time_timing =
157
+ top->eventsPending() ? top->nextTimeSlot() : NO_TOP_EVENTS_PENDING;
158
+ vluint64_t next_time = std::min(next_time_cocotb, next_time_timing);
159
+
160
+ // If there are no more cbAfterDelay callbacks,
161
+ // the next deadline is max value, so end the simulation now
162
+ if (next_time == NO_TOP_EVENTS_PENDING) {
163
+ break;
164
+ } else {
165
+ main_time = next_time;
166
+ }
167
+
168
+ // Call registered NextSimTime
169
+ // It should be called in simulation cycle before everything else
170
+ // but not on first cycle
171
+ VerilatedVpi::callCbs(cbNextSimTime);
172
+
173
+ // Call Value Change callbacks triggered by NextTimeStep callbacks
174
+ // These can modify signal values
175
+ settle_value_callbacks();
176
+ }
177
+
178
+ VerilatedVpi::callCbs(cbEndOfSimulation);
179
+
180
+ top->final();
181
+
182
+ #if VM_TRACE
183
+ if (traceOn) {
184
+ tfp->close();
185
+ }
186
+ #endif
187
+
188
+ // VM_COVERAGE is a define which is set if Verilator is
189
+ // instructed to collect coverage (when compiling the simulation)
190
+ #if VM_COVERAGE
191
+ VerilatedCov::write(); // Uses +verilator+coverage+file+<filename>,
192
+ // defaults to coverage.dat
193
+ #endif
194
+
195
+ return 0;
196
+ }
@@ -0,0 +1,12 @@
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
@@ -0,0 +1,176 @@
1
+ ###############################################################################
2
+ # Copyright (c) 2013 Potential Ventures Ltd
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
+ ##############################################################################
29
+
30
+ # Common makefile included by everything
31
+
32
+ ifndef COCOTB_MAKEFILE_INC_INCLUDED # Protect against multiple includes
33
+ COCOTB_MAKEFILE_INC_INCLUDED = 1
34
+
35
+ # Default sim rule will force a re-run of the simulation (though the cocotb library
36
+ # and RTL compilation phases are still evaluated by makefile dependencies)
37
+ .PHONY: sim
38
+ sim:
39
+ $(RM) $(COCOTB_RESULTS_FILE)
40
+ "$(MAKE)" -f $(firstword $(MAKEFILE_LIST)) $(COCOTB_RESULTS_FILE)
41
+
42
+ # Make sure to use bash for the pipefail option used in many simulator Makefiles
43
+ SHELL := bash
44
+
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
+ OS=$(shell uname)
53
+ ifneq (, $(findstring MINGW, $(OS)))
54
+ OS := Msys
55
+ else ifneq (, $(findstring MSYS, $(OS)))
56
+ OS := Msys
57
+ endif
58
+ export OS
59
+
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)')
63
+
64
+ # this ensures we use the same python as the one cocotb was installed into
65
+ PYTHON_BIN ?= $(shell cocotb-config --python-bin)
66
+
67
+ include $(COCOTB_SHARE_DIR)/makefiles/Makefile.deprecations
68
+
69
+ LIB_DIR=$(COCOTB_PY_DIR)/cocotb/libs
70
+
71
+ PYTHON_ARCH := $(shell $(PYTHON_BIN) -c 'from platform import architecture; print(architecture()[0])')
72
+ ifeq ($(filter $(PYTHON_ARCH),64bit 32bit),)
73
+ $(error Unknown Python architecture: $(PYTHON_ARCH))
74
+ endif
75
+
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
+ ifeq ($(OS),Msys)
83
+ to_tcl_path = $(shell cygpath -m $(1) )
84
+ else
85
+ to_tcl_path = $(1)
86
+ endif
87
+
88
+ # Check that the COCOTB_RESULTS_FILE was created, since we can't set an exit code from cocotb.
89
+ define check_for_results_file
90
+ @test -f $(COCOTB_RESULTS_FILE) || (echo "ERROR: $(COCOTB_RESULTS_FILE) was not written by the simulation!" >&2 && exit 1)
91
+ endef
92
+
93
+ SIM_BUILD ?= sim_build
94
+ export SIM_BUILD
95
+
96
+ COCOTB_RESULTS_FILE ?= results.xml
97
+ COCOTB_HDL_TIMEUNIT ?= 1ns
98
+ COCOTB_HDL_TIMEPRECISION ?= 1ps
99
+
100
+ export COCOTB_RESULTS_FILE
101
+
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
+
110
+ $(SIM_BUILD):
111
+ mkdir -p $@
112
+
113
+ # Regression rule uses Make dependencies to determine whether to run the simulation
114
+ .PHONY: regression
115
+ regression: $(COCOTB_RESULTS_FILE)
116
+
117
+ # Attempt to detect TOPLEVEL_LANG based on available sources if not set
118
+ ifeq ($(TOPLEVEL_LANG),)
119
+
120
+ ifneq ($(VHDL_SOURCES),)
121
+ ifeq ($(VERILOG_SOURCES),)
122
+ TOPLEVEL_LANG := vhdl
123
+ endif
124
+ else ifneq ($(VERILOG_SOURCES),)
125
+ ifeq ($(VHDL_SOURCES),)
126
+ TOPLEVEL_LANG := verilog
127
+ endif
128
+ endif
129
+
130
+ endif
131
+
132
+ define find_libpython_errmsg =
133
+
134
+
135
+ find_libpython was not able to find a libpython in the current Python environment. Ensure
136
+ the Python development packages are installed. If they are installed and find_libpython
137
+ is not finding the path to libpython, file an upstream bug in find_libpython; then
138
+ manually override the LIBPYTHON_LOC make variable with the absolute path to libpython.so
139
+ (or python.dll on Windows).
140
+
141
+ endef
142
+
143
+ ifndef LIBPYTHON_LOC
144
+
145
+ # get the path to libpython and the return code from the script
146
+ # adapted from https://stackoverflow.com/a/24658961/6614127
147
+ FIND_LIBPYTHON_RES := $(shell cocotb-config --libpython; echo $$?)
148
+ FIND_LIBPYTHON_RC := $(lastword $(FIND_LIBPYTHON_RES))
149
+ LIBPYTHON_LOC := $(strip $(subst $(FIND_LIBPYTHON_RC)QQQQ,,$(FIND_LIBPYTHON_RES)QQQQ))
150
+
151
+ # complain if libpython isn't found, and export otherwise
152
+ ifneq ($(FIND_LIBPYTHON_RC),0)
153
+ $(error $(find_libpython_errmsg))
154
+ endif
155
+
156
+ endif
157
+
158
+ export LIBPYTHON_LOC
159
+
160
+ define check_vhdl_sources
161
+ if [ "$(VHDL_SOURCES_$(LIB))" == "" ]; then \
162
+ >&2 echo "ERROR: VHDL_SOURCES_$(LIB) is empty or undefined, but '$(LIB)' is present in VHDL_LIB_ORDER."; \
163
+ exit 1; \
164
+ fi;
165
+ endef
166
+
167
+ define check_lib_order
168
+ if [ "$(filter $(SOURCES_VAR:VHDL_SOURCES_%=%), $(VHDL_LIB_ORDER))" == "" ]; then \
169
+ >&2 echo "ERROR: $(SOURCES_VAR) defined, but library $(SOURCES_VAR:VHDL_SOURCES_%=%) not present in VHDL_LIB_ORDER."; \
170
+ exit 1; \
171
+ fi;
172
+ endef
173
+
174
+ else
175
+ $(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
+ endif # COCOTB_MAKEFILE_INC_INCLUDED
@@ -0,0 +1,113 @@
1
+ ###############################################################################
2
+ # Copyright (c) 2013, 2018 Potential Ventures Ltd
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
+ ###############################################################################
29
+
30
+ # This file includes an appropriate makefile depending on the SIM variable.
31
+
32
+ .PHONY: all
33
+ all: sim
34
+
35
+ # NOTE: keep this at 80 chars.
36
+ define help_targets =
37
+ Targets
38
+ =======
39
+ sim Unconditionally re-run the simulator (default)
40
+ regression Run simulator when dependencies have changes
41
+ clean Remove build and simulation artefacts
42
+ help This help text
43
+
44
+ endef
45
+
46
+ # NOTE: keep this at 80 chars.
47
+ define help_makevars =
48
+ Variables
49
+ =========
50
+
51
+ The following variables are makefile variables:
52
+
53
+ Makefile-based Test Scripts
54
+ ---------------------------
55
+ GUI Set this to 1 to enable the GUI mode in the simulator
56
+ SIM Selects which simulator Makefile to use
57
+ WAVES Enable wave traces dump for Riviera-PRO and Questa
58
+ VERILOG_SOURCES A list of the Verilog source files to include
59
+ VHDL_SOURCES A list of the VHDL source files to include
60
+ VHDL_SOURCES_<lib> VHDL source files to include in *lib* (GHDL/NVC/ModelSim/Questa/Xcelium/Incisive/Riviera-PRO only)
61
+ VHDL_LIB_ORDER Compilation order of VHDL libraries (needed for NVC/ModelSim/Questa/Xcelium/Incisive/Riviera-PRO)
62
+ SIM_CMD_PREFIX Prefix for simulation command invocations
63
+ COMPILE_ARGS Arguments to pass to compile (analysis) stage of simulation
64
+ SIM_ARGS Arguments to pass to execution of compiled simulation
65
+ EXTRA_ARGS Arguments for compile and execute phases
66
+ PLUSARGS Plusargs to pass to the simulator
67
+ COCOTB_HDL_TIMEUNIT Default time unit for simulation
68
+ COCOTB_HDL_TIMEPRECISION Default time precision for simulation
69
+ CUSTOM_COMPILE_DEPS Add additional dependencies to the compilation target
70
+ CUSTOM_SIM_DEPS Add additional dependencies to the simulation target
71
+ SIM_BUILD Define a scratch directory for use by the simulator
72
+ SCRIPT_FILE Simulator script to run (for e.g. wave traces)
73
+
74
+ endef
75
+
76
+
77
+ # NOTE: keep *two* empty lines between "define" and "endef":
78
+ define newline
79
+
80
+
81
+ endef
82
+
83
+ # this cannot be a regular target because of the way Makefile.$(SIM) is included
84
+ ifeq ($(MAKECMDGOALS),help)
85
+ $(info $(help_targets))
86
+ $(info $(help_makevars))
87
+ # hack to get newlines in output, see https://stackoverflow.com/a/54539610
88
+ # 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 %))
90
+ $(info ${help_envvars})
91
+ # is there a cleaner way to exit here?
92
+ $(error Stopping after printing help)
93
+ endif
94
+
95
+ # Default to Icarus if no simulator is defined
96
+ SIM ?= icarus
97
+
98
+ # Maintain backwards compatibility by supporting upper and lower case SIM variable
99
+ SIM_LOWERCASE := $(shell echo $(SIM) | tr A-Z a-z)
100
+
101
+ # Directory containing the cocotb Makfiles
102
+ COCOTB_MAKEFILES_DIR := $(shell cocotb-config --makefiles)
103
+
104
+ include $(COCOTB_MAKEFILES_DIR)/Makefile.deprecations
105
+
106
+ HAVE_SIMULATOR = $(shell if [ -f $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.$(SIM_LOWERCASE) ]; then echo 1; else echo 0; fi;)
107
+ AVAILABLE_SIMULATORS = $(patsubst .%,%,$(suffix $(wildcard $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.*)))
108
+
109
+ ifeq ($(HAVE_SIMULATOR),0)
110
+ $(error Couldn't find makefile for simulator: "$(SIM_LOWERCASE)"! Available simulators: $(AVAILABLE_SIMULATORS))
111
+ endif
112
+
113
+ include $(COCOTB_MAKEFILES_DIR)/simulators/Makefile.$(SIM_LOWERCASE)
@@ -0,0 +1,79 @@
1
+ # Copyright cocotb contributors
2
+ # Licensed under the Revised BSD License, see LICENSE for details.
3
+ # SPDX-License-Identifier: BSD-3-Clause
4
+
5
+ # Common Makefile for the Aldec Active-HDL simulator
6
+
7
+ include $(shell cocotb-config --makefiles)/Makefile.inc
8
+
9
+ CMD_BIN := vsimsa
10
+
11
+ ifdef ACTIVEHDL_BIN_DIR
12
+ CMD := $(shell :; command -v $(ACTIVEHDL_BIN_DIR)/$(CMD_BIN) 2>/dev/null)
13
+ else
14
+ # auto-detect bin dir from system path
15
+ CMD := $(shell :; command -v $(CMD_BIN) 2>/dev/null)
16
+ endif
17
+
18
+ ALOG_ARGS += -timescale $(COCOTB_HDL_TIMEUNIT)/$(COCOTB_HDL_TIMEPRECISION)
19
+
20
+ # below allows for maintaining legacy syntax as well as enables using cross-simulator vars COMPILE_ARGS/SIM_ARGS
21
+ ALOG_ARGS += $(COMPILE_ARGS)
22
+ ACOM_ARGS += $(COMPILE_ARGS)
23
+ ASIM_ARGS += $(SIM_ARGS)
24
+
25
+ ALOG_ARGS += +define+COCOTB_SIM -dbg
26
+
27
+ ifdef RTL_LIBRARY
28
+ $(warning Using RTL_LIBRARY is deprecated, please use TOPLEVEL_LIBRARY instead.)
29
+ TOPLEVEL_LIBRARY ?= $(RTL_LIBRARY)
30
+ else
31
+ TOPLEVEL_LIBRARY ?= work
32
+ endif
33
+
34
+ ACOM_ARGS += -dbg
35
+
36
+ GPI_EXTRA:=
37
+ ifeq ($(TOPLEVEL_LANG),verilog)
38
+ # backslashes needed because we embed in `echo` below
39
+ GPI_ARGS = -pli \"$(shell cocotb-config --lib-name-path vpi activehdl)\"
40
+ ifneq ($(VHDL_SOURCES),)
41
+ GPI_EXTRA = $(shell cocotb-config --lib-name-path vhpi activehdl):cocotbvhpi_entry_point
42
+ endif
43
+
44
+ else ifeq ($(TOPLEVEL_LANG),vhdl)
45
+ # backslashes needed because we embed in `echo` below
46
+ GPI_ARGS = -loadvhpi \"$(shell cocotb-config --lib-name-path vhpi activehdl):vhpi_startup_routines_bootstrap\"
47
+ ifneq ($(VERILOG_SOURCES),)
48
+ GPI_EXTRA = $(shell cocotb-config --lib-name-path vpi activehdl):cocotbvpi_entry_point
49
+ endif
50
+ else
51
+ $(error A valid value (verilog or vhdl) was not provided for TOPLEVEL_LANG=$(TOPLEVEL_LANG))
52
+ endif
53
+
54
+ # Create a DO script (Tcl-like but not fully compatible) based on the list of $(VERILOG_SOURCES)
55
+ $(SIM_BUILD)/runsim.do : $(VERILOG_SOURCES) $(VHDL_SOURCES) | $(SIM_BUILD)
56
+ @echo "alib $(TOPLEVEL_LIBRARY)" > $@
57
+ @echo "set worklib $(TOPLEVEL_LIBRARY)" >> $@
58
+ ifneq ($(VHDL_SOURCES),)
59
+ @echo "acom $(ACOM_ARGS) $(call to_tcl_path,$(VHDL_SOURCES))" >> $@
60
+ endif
61
+ ifneq ($(VERILOG_SOURCES),)
62
+ @echo "alog $(ALOG_ARGS) $(call to_tcl_path,$(VERILOG_SOURCES))" >> $@
63
+ endif
64
+ @echo "asim $(ASIM_ARGS) $(PLUSARGS) +access +w_nets -interceptcoutput $(GPI_ARGS) $(TOPLEVEL) $(EXTRA_TOPS)" >> $@
65
+ @echo "run -all" >> $@
66
+ @echo "endsim" >> $@
67
+
68
+ $(COCOTB_RESULTS_FILE): $(SIM_BUILD)/runsim.do $(CUSTOM_COMPILE_DEPS) $(CUSTOM_SIM_DEPS)
69
+ $(RM) $(COCOTB_RESULTS_FILE)
70
+
71
+ set -o pipefail; GPI_EXTRA=$(GPI_EXTRA) TOPLEVEL_LANG=$(TOPLEVEL_LANG) \
72
+ MODULE=$(MODULE) TESTCASE=$(TESTCASE) TOPLEVEL=$(TOPLEVEL) $(SIM_CMD_PREFIX) $(CMD) $(RUN_ARGS) -do $(SIM_BUILD)/runsim.do $(SIM_CMD_SUFFIX)
73
+
74
+ $(call check_for_results_file)
75
+
76
+ clean::
77
+ $(RM) -r $(SIM_BUILD)
78
+ $(RM) -r work
79
+ $(RM) -r wave.asdb
@@ -0,0 +1,94 @@
1
+ ###############################################################################
2
+ # Copyright (c) 2014 Potential Ventures Ltd
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, nor the
13
+ # names of its contributors may be used to endorse or promote products
14
+ # derived from this software without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY
20
+ # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+ # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ ###############################################################################
27
+
28
+ include $(shell cocotb-config --makefiles)/Makefile.inc
29
+
30
+ ifneq ($(VHDL_SOURCES),)
31
+
32
+ $(COCOTB_RESULTS_FILE):
33
+ @echo "Skipping simulation as VHDL is not supported on simulator=$(SIM)"
34
+ debug: $(COCOTB_RESULTS_FILE)
35
+ clean::
36
+
37
+ else
38
+
39
+ CMD_BIN := cvc64
40
+
41
+ ifdef CVC_BIN_DIR
42
+ CMD := $(shell :; command -v $(CVC_BIN_DIR)/$(CMD_BIN) 2>/dev/null)
43
+ else
44
+ # auto-detect bin dir from system path
45
+ CMD := $(shell :; command -v $(CMD_BIN) 2>/dev/null)
46
+ endif
47
+
48
+ ifeq (, $(CMD))
49
+ $(error Unable to locate command >$(CMD_BIN)<)
50
+ else
51
+ CVC_BIN_DIR := $(shell dirname $(CMD))
52
+ export CVC_BIN_DIR
53
+ endif
54
+
55
+ #only interpreted mode works for the moment
56
+ CVC_ITERP ?= 1
57
+
58
+ ifeq ($(CVC_ITERP),1)
59
+ CVC_ARGS += +interp
60
+ endif
61
+
62
+ # Compilation phase
63
+ $(SIM_BUILD)/sim.vvp: $(VERILOG_SOURCES) $(CUSTOM_COMPILE_DEPS) | $(SIM_BUILD)
64
+ MODULE=$(MODULE) \
65
+ TESTCASE=$(TESTCASE) TOPLEVEL=$(TOPLEVEL) TOPLEVEL_LANG=$(TOPLEVEL_LANG) \
66
+ $(CMD) $(CVC_ARGS) +acc+2 -o $(SIM_BUILD)/sim.vvp +define+COCOTB_SIM=1 +loadvpi=$(shell cocotb-config --lib-name-path vpi cvc):vlog_startup_routines_bootstrap $(COMPILE_ARGS) $(EXTRA_ARGS) $(VERILOG_SOURCES)
67
+
68
+ # Execution phase
69
+ ifeq ($(CVC_ITERP),1)
70
+ $(COCOTB_RESULTS_FILE): $(SIM_BUILD)/sim.vvp
71
+ else
72
+ $(COCOTB_RESULTS_FILE): $(SIM_BUILD)/sim.vvp $(CUSTOM_SIM_DEPS)
73
+ MODULE=$(MODULE) \
74
+ TESTCASE=$(TESTCASE) TOPLEVEL=$(TOPLEVEL) TOPLEVEL_LANG=$(TOPLEVEL_LANG) \
75
+ $(SIM_CMD_PREFIX) $(SIM_BUILD)/sim.vvp $(SIM_ARGS) $(EXTRA_ARGS) $(PLUSARGS) $(SIM_CMD_SUFFIX)
76
+ endif
77
+
78
+ # Execution phase
79
+ ifeq ($(CVC_ITERP),1)
80
+ debug: $(CUSTOM_SIM_DEPS)
81
+ MODULE=$(MODULE) \
82
+ TESTCASE=$(TESTCASE) TOPLEVEL=$(TOPLEVEL) TOPLEVEL_LANG=$(TOPLEVEL_LANG) \
83
+ $(SIM_CMD_PREFIX) gdb --args $(CMD) $(CVC_ARGS) +acc+2 -o $(SIM_BUILD)/sim.vvp +define+COCOTB_SIM=1 +loadvpi=$(shell cocotb-config --lib-name-path vpi cvc):vlog_startup_routines_bootstrap $(COMPILE_ARGS) $(EXTRA_ARGS) $(VERILOG_SOURCES)
84
+ else
85
+ debug: $(SIM_BUILD)/sim.vvp $(CUSTOM_SIM_DEPS)
86
+ MODULE=$(MODULE) \
87
+ TESTCASE=$(TESTCASE) TOPLEVEL=$(TOPLEVEL) TOPLEVEL_LANG=$(TOPLEVEL_LANG) \
88
+ gdb --args $(SIM_BUILD)/sim.vvp $(SIM_ARGS) $(EXTRA_ARGS) $(PLUSARGS)
89
+ endif
90
+
91
+
92
+ clean::
93
+ $(RM) -r $(SIM_BUILD)
94
+ endif