cocotb 2.0.0rc2__cp311-cp311-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cocotb might be problematic. Click here for more details.
- cocotb/_ANSI.py +65 -0
- cocotb/__init__.py +125 -0
- cocotb/_base_triggers.py +515 -0
- cocotb/_bridge.py +186 -0
- cocotb/_decorators.py +515 -0
- cocotb/_deprecation.py +36 -0
- cocotb/_exceptions.py +7 -0
- cocotb/_extended_awaitables.py +419 -0
- cocotb/_gpi_triggers.py +385 -0
- cocotb/_init.py +301 -0
- cocotb/_outcomes.py +54 -0
- cocotb/_profiling.py +46 -0
- cocotb/_py_compat.py +148 -0
- cocotb/_scheduler.py +448 -0
- cocotb/_test.py +248 -0
- cocotb/_test_factory.py +312 -0
- cocotb/_test_functions.py +42 -0
- cocotb/_typing.py +7 -0
- cocotb/_utils.py +274 -0
- cocotb/_version.py +4 -0
- cocotb/_xunit_reporter.py +66 -0
- cocotb/clock.py +419 -0
- cocotb/debug.py +24 -0
- cocotb/handle.py +1752 -0
- cocotb/libs/libcocotb.so +0 -0
- cocotb/libs/libcocotbfli_modelsim.so +0 -0
- cocotb/libs/libcocotbutils.so +0 -0
- cocotb/libs/libcocotbvhpi_aldec.so +0 -0
- cocotb/libs/libcocotbvhpi_ius.so +0 -0
- cocotb/libs/libcocotbvhpi_modelsim.so +0 -0
- cocotb/libs/libcocotbvhpi_nvc.so +0 -0
- cocotb/libs/libcocotbvpi_aldec.so +0 -0
- cocotb/libs/libcocotbvpi_dsim.so +0 -0
- cocotb/libs/libcocotbvpi_ghdl.so +0 -0
- cocotb/libs/libcocotbvpi_icarus.vpl +0 -0
- cocotb/libs/libcocotbvpi_ius.so +0 -0
- cocotb/libs/libcocotbvpi_modelsim.so +0 -0
- cocotb/libs/libcocotbvpi_vcs.so +0 -0
- cocotb/libs/libcocotbvpi_verilator.so +0 -0
- cocotb/libs/libembed.so +0 -0
- cocotb/libs/libgpi.so +0 -0
- cocotb/libs/libgpilog.so +0 -0
- cocotb/libs/libpygpilog.so +0 -0
- cocotb/logging.py +424 -0
- cocotb/py.typed +0 -0
- cocotb/queue.py +225 -0
- cocotb/regression.py +896 -0
- cocotb/result.py +38 -0
- cocotb/share/def/.gitignore +2 -0
- cocotb/share/def/README.md +4 -0
- cocotb/share/def/aldec.def +61 -0
- cocotb/share/def/ghdl.def +43 -0
- cocotb/share/def/icarus.def +43 -0
- cocotb/share/def/modelsim.def +138 -0
- cocotb/share/include/cocotb_utils.h +70 -0
- cocotb/share/include/embed.h +33 -0
- cocotb/share/include/exports.h +20 -0
- cocotb/share/include/gpi.h +459 -0
- cocotb/share/include/gpi_logging.h +291 -0
- cocotb/share/include/py_gpi_logging.h +33 -0
- cocotb/share/include/vhpi_user_ext.h +26 -0
- cocotb/share/include/vpi_user_ext.h +33 -0
- cocotb/share/lib/verilator/verilator.cpp +209 -0
- cocotb/simtime.py +230 -0
- cocotb/simulator.cpython-311-darwin.so +0 -0
- cocotb/simulator.pyi +107 -0
- cocotb/task.py +590 -0
- cocotb/triggers.py +67 -0
- cocotb/types/__init__.py +31 -0
- cocotb/types/_abstract_array.py +151 -0
- cocotb/types/_array.py +295 -0
- cocotb/types/_indexing.py +17 -0
- cocotb/types/_logic.py +333 -0
- cocotb/types/_logic_array.py +868 -0
- cocotb/types/_range.py +197 -0
- cocotb/types/_resolve.py +76 -0
- cocotb/utils.py +110 -0
- cocotb-2.0.0rc2.dist-info/METADATA +60 -0
- cocotb-2.0.0rc2.dist-info/RECORD +115 -0
- cocotb-2.0.0rc2.dist-info/WHEEL +5 -0
- cocotb-2.0.0rc2.dist-info/entry_points.txt +2 -0
- cocotb-2.0.0rc2.dist-info/licenses/LICENSE +29 -0
- cocotb-2.0.0rc2.dist-info/top_level.txt +23 -0
- cocotb_tools/__init__.py +0 -0
- cocotb_tools/_coverage.py +33 -0
- cocotb_tools/_vendor/__init__.py +3 -0
- cocotb_tools/_vendor/distutils_version.py +346 -0
- cocotb_tools/check_results.py +65 -0
- cocotb_tools/combine_results.py +152 -0
- cocotb_tools/config.py +241 -0
- cocotb_tools/ipython_support.py +99 -0
- cocotb_tools/makefiles/Makefile.deprecations +27 -0
- cocotb_tools/makefiles/Makefile.inc +198 -0
- cocotb_tools/makefiles/Makefile.sim +96 -0
- cocotb_tools/makefiles/simulators/Makefile.activehdl +72 -0
- cocotb_tools/makefiles/simulators/Makefile.cvc +61 -0
- cocotb_tools/makefiles/simulators/Makefile.dsim +39 -0
- cocotb_tools/makefiles/simulators/Makefile.ghdl +84 -0
- cocotb_tools/makefiles/simulators/Makefile.icarus +80 -0
- cocotb_tools/makefiles/simulators/Makefile.ius +93 -0
- cocotb_tools/makefiles/simulators/Makefile.modelsim +9 -0
- cocotb_tools/makefiles/simulators/Makefile.nvc +60 -0
- cocotb_tools/makefiles/simulators/Makefile.questa +29 -0
- cocotb_tools/makefiles/simulators/Makefile.questa-compat +143 -0
- cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun +149 -0
- cocotb_tools/makefiles/simulators/Makefile.riviera +144 -0
- cocotb_tools/makefiles/simulators/Makefile.vcs +65 -0
- cocotb_tools/makefiles/simulators/Makefile.verilator +79 -0
- cocotb_tools/makefiles/simulators/Makefile.xcelium +104 -0
- cocotb_tools/py.typed +0 -0
- cocotb_tools/runner.py +1868 -0
- cocotb_tools/sim_versions.py +140 -0
- pygpi/__init__.py +0 -0
- pygpi/entry.py +42 -0
- pygpi/py.typed +0 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
// Copyright cocotb contributors
|
|
2
|
+
// Copyright (c) 2013 Potential Ventures Ltd
|
|
3
|
+
// Copyright (c) 2013 SolarFlare Communications Inc
|
|
4
|
+
// Licensed under the Revised BSD License, see LICENSE for details.
|
|
5
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
|
|
7
|
+
#ifndef COCOTB_GPI_LOGGING_H_
|
|
8
|
+
#define COCOTB_GPI_LOGGING_H_
|
|
9
|
+
|
|
10
|
+
#include <cstdarg> // va_list
|
|
11
|
+
#include <cstring> // strlen
|
|
12
|
+
|
|
13
|
+
#include "exports.h"
|
|
14
|
+
|
|
15
|
+
#ifdef GPILOG_EXPORTS
|
|
16
|
+
#define GPILOG_EXPORT COCOTB_EXPORT
|
|
17
|
+
#else
|
|
18
|
+
#define GPILOG_EXPORT COCOTB_IMPORT
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#ifdef __cplusplus
|
|
22
|
+
extern "C" {
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
/** Named logging level
|
|
26
|
+
*
|
|
27
|
+
* The native logger only logs level names at these log level values.
|
|
28
|
+
* They were specifically chosen to align with the default level values in the
|
|
29
|
+
* Python logging module. Implementers of custom loggers should emit human
|
|
30
|
+
* readable level names for these value, but may support other values.
|
|
31
|
+
*/
|
|
32
|
+
enum gpi_log_level {
|
|
33
|
+
GPI_NOTSET = 0, ///< Lets the parent logger in the hierarchy decide the
|
|
34
|
+
///< effective log level. By default this behaves like
|
|
35
|
+
///< `INFO`.
|
|
36
|
+
GPI_TRACE = 5, ///< Prints `TRACE` by default. Information about execution
|
|
37
|
+
///< of simulator callbacks and Python/simulator contexts.
|
|
38
|
+
GPI_DEBUG = 10, ///< Prints `DEBUG` by default. Verbose information, useful
|
|
39
|
+
///< for debugging.
|
|
40
|
+
GPI_INFO = 20, ///< Prints `INFO` by default. Information about major
|
|
41
|
+
///< events in the current program.
|
|
42
|
+
GPI_WARNING = 30, ///< Prints `WARN` by default. Encountered a recoverable
|
|
43
|
+
///< bug, or information about surprising behavior.
|
|
44
|
+
GPI_ERROR = 40, ///< Prints `ERROR` by default. An unrecoverable error
|
|
45
|
+
GPI_CRITICAL = 50 ///< Prints `CRITICAL` by default. An unrecoverable
|
|
46
|
+
///< error, to be followed by immediate simulator
|
|
47
|
+
///< shutdown.
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
#define LOG_EXPLICIT(logger, level, file, func, lineno, ...) \
|
|
51
|
+
gpi_log_(logger, level, file, func, lineno, __VA_ARGS__)
|
|
52
|
+
|
|
53
|
+
#define LOG_(level, ...) \
|
|
54
|
+
gpi_log_("gpi", level, __FILE__, __func__, __LINE__, __VA_ARGS__)
|
|
55
|
+
|
|
56
|
+
/** Logs a message at TRACE log level using the current log handler.
|
|
57
|
+
Automatically populates arguments using information in the called context.
|
|
58
|
+
*/
|
|
59
|
+
#define LOG_TRACE(...) LOG_(GPI_TRACE, __VA_ARGS__)
|
|
60
|
+
|
|
61
|
+
/** Logs a message at DEBUG log level using the current log handler.
|
|
62
|
+
Automatically populates arguments using information in the called context.
|
|
63
|
+
*/
|
|
64
|
+
#define LOG_DEBUG(...) LOG_(GPI_DEBUG, __VA_ARGS__)
|
|
65
|
+
|
|
66
|
+
/** Logs a message at INFO log level using the current log handler.
|
|
67
|
+
Automatically populates arguments using information in the called context.
|
|
68
|
+
*/
|
|
69
|
+
#define LOG_INFO(...) LOG_(GPI_INFO, __VA_ARGS__)
|
|
70
|
+
|
|
71
|
+
/** Logs a message at WARN log level using the current log handler.
|
|
72
|
+
Automatically populates arguments using information in the called context.
|
|
73
|
+
*/
|
|
74
|
+
#define LOG_WARN(...) LOG_(GPI_WARNING, __VA_ARGS__)
|
|
75
|
+
|
|
76
|
+
/** Logs a message at ERROR log level using the current log handler.
|
|
77
|
+
Automatically populates arguments using information in the called context.
|
|
78
|
+
*/
|
|
79
|
+
#define LOG_ERROR(...) LOG_(GPI_ERROR, __VA_ARGS__)
|
|
80
|
+
|
|
81
|
+
/** Logs a message at CRITICAL log level using the current log handler.
|
|
82
|
+
Automatically populates arguments using information in the called context.
|
|
83
|
+
*/
|
|
84
|
+
#define LOG_CRITICAL(...) LOG_(GPI_CRITICAL, __VA_ARGS__)
|
|
85
|
+
|
|
86
|
+
#define MAKE_LOG_NAME_(extra_name) \
|
|
87
|
+
(extra_name[0] == '\0' ? "gpi" : "gpi." extra_name)
|
|
88
|
+
|
|
89
|
+
/** Type of a logger handler function.
|
|
90
|
+
* @param userdata private implementation data registered with this function
|
|
91
|
+
* @param name Name of the logger
|
|
92
|
+
* @param level Level at which to log the message
|
|
93
|
+
* @param pathname Name of the file where the call site is located
|
|
94
|
+
* @param funcname Name of the function where the call site is located
|
|
95
|
+
* @param lineno Line number of the call site
|
|
96
|
+
* @param msg The message to log, uses C-sprintf-style format specifier
|
|
97
|
+
* @param args Additional arguments; formatted and inserted in message
|
|
98
|
+
* according to format specifier in msg argument
|
|
99
|
+
*/
|
|
100
|
+
typedef void (*gpi_log_handler_ftype)(void *userdata, const char *name,
|
|
101
|
+
int level, const char *pathname,
|
|
102
|
+
const char *funcname, long lineno,
|
|
103
|
+
const char *msg, va_list args);
|
|
104
|
+
|
|
105
|
+
/** Type of a logger filter function.
|
|
106
|
+
*
|
|
107
|
+
* Log filter functions test to see if a message would be emitted if logged at
|
|
108
|
+
* the given log level.
|
|
109
|
+
*
|
|
110
|
+
* @param userdata Private implementation data registered with this function.
|
|
111
|
+
* @param logger Name of the logger.
|
|
112
|
+
* @param level Level at which to test if the logger would emit a message.
|
|
113
|
+
* @return `true` if the *logger* is enabled at *level*.
|
|
114
|
+
*/
|
|
115
|
+
typedef bool (*gpi_log_filter_ftype)(void *userdata, const char *logger,
|
|
116
|
+
int level);
|
|
117
|
+
|
|
118
|
+
/** Type of a logger set level function.
|
|
119
|
+
*
|
|
120
|
+
* Log filter functions test to see if a message would be emitted if logged at
|
|
121
|
+
* the given log level.
|
|
122
|
+
*
|
|
123
|
+
* @param userdata Private implementation data registered with this function.
|
|
124
|
+
* @param logger Name of the logger.
|
|
125
|
+
* @param level Level at which to test if the logger would emit a message.
|
|
126
|
+
* @return `true` if the *logger* is enabled at *level*.
|
|
127
|
+
*/
|
|
128
|
+
typedef bool (*gpi_log_set_level_ftype)(void *userdata, const char *logger,
|
|
129
|
+
int level);
|
|
130
|
+
|
|
131
|
+
/** Log a message using the currently registered log handler.
|
|
132
|
+
*
|
|
133
|
+
* @param extra_name Name of the "gpi" child logger, "" for the root logger
|
|
134
|
+
* @param level Level at which to log the message
|
|
135
|
+
* @param pathname Name of the file where the call site is located
|
|
136
|
+
* @param funcname Name of the function where the call site is located
|
|
137
|
+
* @param lineno Line number of the call site
|
|
138
|
+
* @param msg The message to log, uses C-sprintf-style format specifier
|
|
139
|
+
* @param ... Additional arguments; formatted and inserted in message
|
|
140
|
+
* according to format specifier in msg argument
|
|
141
|
+
*/
|
|
142
|
+
#define gpi_log(extra_name, level, pathname, funcname, lineno, ...) \
|
|
143
|
+
gpi_log_(MAKE_LOG_NAME_(extra_name), level, pathname, funcname, lineno, \
|
|
144
|
+
__VA_ARGS__)
|
|
145
|
+
|
|
146
|
+
// Don't call this function directly unless the name is "gpi" or starts with
|
|
147
|
+
// "gpi."
|
|
148
|
+
GPILOG_EXPORT void gpi_log_(const char *name, int level, const char *pathname,
|
|
149
|
+
const char *funcname, long lineno, const char *msg,
|
|
150
|
+
...);
|
|
151
|
+
|
|
152
|
+
/** Log a message using the currently registered log handler.
|
|
153
|
+
*
|
|
154
|
+
* @param extra_name Name of the "gpi" child logger, "" for the root logger
|
|
155
|
+
* @param level Level at which to log the message
|
|
156
|
+
* @param pathname Name of the file where the call site is located
|
|
157
|
+
* @param funcname Name of the function where the call site is located
|
|
158
|
+
* @param lineno Line number of the call site
|
|
159
|
+
* @param msg The message to log, uses C-sprintf-style format specifier
|
|
160
|
+
* @param args Additional arguments; formatted and inserted in message
|
|
161
|
+
* according to format specifier in msg argument
|
|
162
|
+
*/
|
|
163
|
+
#define gpi_vlog(extra_name, level, pathname, funcname, lineno, msg, args) \
|
|
164
|
+
gpi_vlog_(MAKE_LOG_NAME_(extra_name), level, pathname, funcname, lineno, \
|
|
165
|
+
msg, args)
|
|
166
|
+
|
|
167
|
+
// Don't call this function directly unless the name is "gpi" or starts with
|
|
168
|
+
// "gpi."
|
|
169
|
+
GPILOG_EXPORT void gpi_vlog_(const char *name, int level, const char *pathname,
|
|
170
|
+
const char *funcname, long lineno, const char *msg,
|
|
171
|
+
va_list args);
|
|
172
|
+
|
|
173
|
+
/** Check if a log would be filtered.
|
|
174
|
+
*
|
|
175
|
+
* @param logger Name of the logger.
|
|
176
|
+
* @param level Level at which to test if the logger would emit a message.
|
|
177
|
+
* @return `true` if the *logger* is enabled at *level*.
|
|
178
|
+
*/
|
|
179
|
+
GPILOG_EXPORT bool gpi_log_filtered(const char *logger, int level);
|
|
180
|
+
|
|
181
|
+
/** Set the log level of a logger.
|
|
182
|
+
*
|
|
183
|
+
* @param logger Name of the logger.
|
|
184
|
+
* @param level Level to set the logger to.
|
|
185
|
+
* @return The old log level.
|
|
186
|
+
*/
|
|
187
|
+
GPILOG_EXPORT int gpi_log_set_level(const char *logger, int level);
|
|
188
|
+
|
|
189
|
+
/** @return The string representation of the GPI log level. */
|
|
190
|
+
GPILOG_EXPORT const char *gpi_log_level_to_str(int level);
|
|
191
|
+
|
|
192
|
+
/** Retrieve the current log handler.
|
|
193
|
+
* @param handler Location to return current log handler function. If no
|
|
194
|
+
* custom logger is registered this will be `NULL`.
|
|
195
|
+
* @param filter Location to return current log filter function. If no
|
|
196
|
+
* custom logger is registered this will be `NULL`.
|
|
197
|
+
* @param set_level Location to return current log set level function. If no
|
|
198
|
+
* custom logger is registered this will be `NULL`.
|
|
199
|
+
* @param userdata Location to return log handler userdata. If no custom
|
|
200
|
+
* logger is registered this will be `NULL`.
|
|
201
|
+
*/
|
|
202
|
+
GPILOG_EXPORT void gpi_get_log_handler(gpi_log_handler_ftype *handler,
|
|
203
|
+
gpi_log_filter_ftype *filter,
|
|
204
|
+
gpi_log_set_level_ftype *set_level,
|
|
205
|
+
void **userdata);
|
|
206
|
+
|
|
207
|
+
/** Set custom log handler
|
|
208
|
+
* @param handler Logger handler function.
|
|
209
|
+
* @param filter Logger level filter function.
|
|
210
|
+
* @param set_level Logger set level function.
|
|
211
|
+
* @param userdata Data passed to the above functions.
|
|
212
|
+
*/
|
|
213
|
+
GPILOG_EXPORT void gpi_set_log_handler(gpi_log_handler_ftype handler,
|
|
214
|
+
gpi_log_filter_ftype filter,
|
|
215
|
+
gpi_log_set_level_ftype set_level,
|
|
216
|
+
void *userdata);
|
|
217
|
+
|
|
218
|
+
/** Clear the current custom log handler and use native logger. */
|
|
219
|
+
GPILOG_EXPORT void gpi_clear_log_handler(void);
|
|
220
|
+
|
|
221
|
+
/*******************************************************************************
|
|
222
|
+
* GPI Native Logger
|
|
223
|
+
*******************************************************************************/
|
|
224
|
+
|
|
225
|
+
/** Log a message using the native log handler.
|
|
226
|
+
* User is expected to populate all arguments to this function.
|
|
227
|
+
* @param extra_name Name of the "gpi" child logger, "" for the root logger
|
|
228
|
+
* @param level Level at which to log the message
|
|
229
|
+
* @param pathname Name of the file where the call site is located
|
|
230
|
+
* @param funcname Name of the function where the call site is located
|
|
231
|
+
* @param lineno Line number of the call site
|
|
232
|
+
* @param msg The message to log, uses C-sprintf-style format specifier
|
|
233
|
+
* @param ... Additional arguments; formatted and inserted in message
|
|
234
|
+
* according to format specifier in msg argument
|
|
235
|
+
*/
|
|
236
|
+
#define gpi_native_logger_log(extra_name, level, pathname, funcname, lineno, \
|
|
237
|
+
...) \
|
|
238
|
+
gpi_native_logger_log_(MAKE_LOG_NAME_(extra_name), level, pathname, \
|
|
239
|
+
funcname, lineno, __VA_ARGS__)
|
|
240
|
+
|
|
241
|
+
// Don't call this function directly unless the name is "gpi" or starts with
|
|
242
|
+
// "gpi."
|
|
243
|
+
GPILOG_EXPORT void gpi_native_logger_log_(const char *name, int level,
|
|
244
|
+
const char *pathname,
|
|
245
|
+
const char *funcname, long lineno,
|
|
246
|
+
const char *msg, ...);
|
|
247
|
+
|
|
248
|
+
/** Log a message using the native log handler.
|
|
249
|
+
* User is expected to populate all arguments to this function.
|
|
250
|
+
* @param extra_name Name of the "gpi" child logger, "" for the root logger
|
|
251
|
+
* @param level Level at which to log the message
|
|
252
|
+
* @param pathname Name of the file where the call site is located
|
|
253
|
+
* @param funcname Name of the function where the call site is located
|
|
254
|
+
* @param lineno Line number of the call site
|
|
255
|
+
* @param msg The message to log, uses C-sprintf-style format specifier
|
|
256
|
+
* @param args Additional arguments; formatted and inserted in message
|
|
257
|
+
* according to format specifier in msg argument
|
|
258
|
+
*/
|
|
259
|
+
#define gpi_native_logger_vlog(extra_name, level, pathname, funcname, lineno, \
|
|
260
|
+
msg, args) \
|
|
261
|
+
gpi_native_logger_vlog_(MAKE_LOG_NAME_(extra_name), level, pathname, \
|
|
262
|
+
funcname, lineno, msg, args)
|
|
263
|
+
|
|
264
|
+
// Don't call this function directly unless the name is "gpi" or starts with
|
|
265
|
+
// "gpi."
|
|
266
|
+
GPILOG_EXPORT void gpi_native_logger_vlog_(const char *name, int level,
|
|
267
|
+
const char *pathname,
|
|
268
|
+
const char *funcname, long lineno,
|
|
269
|
+
const char *msg, va_list args);
|
|
270
|
+
|
|
271
|
+
/** Check if a message would be filtered by the native logger.
|
|
272
|
+
*
|
|
273
|
+
* @param level Level at which to test if the logger would emit a message.
|
|
274
|
+
* @return `true` if the *logger* is enabled at *level*.
|
|
275
|
+
*/
|
|
276
|
+
GPILOG_EXPORT bool gpi_native_logger_filtered(int level);
|
|
277
|
+
|
|
278
|
+
/** Set minimum logging level of the native logger.
|
|
279
|
+
*
|
|
280
|
+
* If a logging request occurs where the logging level is lower than the level
|
|
281
|
+
* set by this function, it is not logged. Only affects the native logger.
|
|
282
|
+
* @param level Logging level
|
|
283
|
+
* @return Previous logging level
|
|
284
|
+
*/
|
|
285
|
+
GPILOG_EXPORT int gpi_native_logger_set_level(int level);
|
|
286
|
+
|
|
287
|
+
#ifdef __cplusplus
|
|
288
|
+
}
|
|
289
|
+
#endif
|
|
290
|
+
|
|
291
|
+
#endif /* COCOTB_GPI_LOGGING_H_ */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright cocotb contributors
|
|
2
|
+
// Licensed under the Revised BSD License, see LICENSE for details.
|
|
3
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
|
|
5
|
+
#ifndef PY_GPI_LOGGING_H
|
|
6
|
+
#define PY_GPI_LOGGING_H
|
|
7
|
+
|
|
8
|
+
#include <Python.h>
|
|
9
|
+
|
|
10
|
+
#include "exports.h"
|
|
11
|
+
|
|
12
|
+
#ifdef PYGPILOG_EXPORTS
|
|
13
|
+
#define PYGPILOG_EXPORT COCOTB_EXPORT
|
|
14
|
+
#else
|
|
15
|
+
#define PYGPILOG_EXPORT COCOTB_IMPORT
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
#ifdef __cplusplus
|
|
19
|
+
extern "C" {
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
PYGPILOG_EXPORT void py_gpi_logger_initialize(PyObject *handler,
|
|
23
|
+
PyObject *get_logger);
|
|
24
|
+
|
|
25
|
+
PYGPILOG_EXPORT void py_gpi_logger_finalize();
|
|
26
|
+
|
|
27
|
+
extern PYGPILOG_EXPORT PyObject *pEventFn; // This is gross but I don't care
|
|
28
|
+
|
|
29
|
+
#ifdef __cplusplus
|
|
30
|
+
}
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#endif
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright cocotb contributors
|
|
2
|
+
// Licensed under the Revised BSD License, see LICENSE for details.
|
|
3
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
|
|
5
|
+
/* extensions to vhpi_user.h */
|
|
6
|
+
|
|
7
|
+
#ifndef VHPI_USER_EXT_H
|
|
8
|
+
#define VHPI_USER_EXT_H
|
|
9
|
+
|
|
10
|
+
#ifdef __cplusplus
|
|
11
|
+
extern "C" {
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
/* arguments for vhpiStop or vhpiFinish */
|
|
15
|
+
typedef enum
|
|
16
|
+
{
|
|
17
|
+
vhpiDiagNone = 0, /* prints nothing */
|
|
18
|
+
vhpiDiagTimeLoc = 1, /* prints simulation time and location */
|
|
19
|
+
vhpiDiagTimeLocCPUMem = 2 /* prints simulation time, location and statistics about CPU and memory usage */
|
|
20
|
+
} vhpiDiagT;
|
|
21
|
+
|
|
22
|
+
#ifdef __cplusplus
|
|
23
|
+
}
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
#endif /* VHPI_USER_EXT_H */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright cocotb contributors
|
|
2
|
+
// Copyright (c) 2013, 2019 Potential Ventures Ltd
|
|
3
|
+
// Licensed under the Revised BSD License, see LICENSE for details.
|
|
4
|
+
// SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
|
|
6
|
+
/* extensions to vpi_user.h */
|
|
7
|
+
|
|
8
|
+
#ifndef VPI_USER_EXT_H
|
|
9
|
+
#define VPI_USER_EXT_H
|
|
10
|
+
|
|
11
|
+
#ifdef __cplusplus
|
|
12
|
+
extern "C" {
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
/* used by Cadence Xcelium for packed unions */
|
|
16
|
+
#define vpiUnionNet 525
|
|
17
|
+
|
|
18
|
+
/* used by Cadence Xcelium for Verilog-AMS */
|
|
19
|
+
#define vpiRealNet 526
|
|
20
|
+
#define vpiInterconnectNet 533
|
|
21
|
+
#define vpiInterconnectArray 534
|
|
22
|
+
|
|
23
|
+
/* arguments for vpiStop or vpiFinish */
|
|
24
|
+
#define vpiDiagNone 0 /* prints nothing */
|
|
25
|
+
#define vpiDiagTimeLoc 1 /* prints simulation time and location */
|
|
26
|
+
#define vpiDiagTimeLocCPUMem 2 /* prints simulation time, location and
|
|
27
|
+
statistics about CPU and memory usage */
|
|
28
|
+
|
|
29
|
+
#ifdef __cplusplus
|
|
30
|
+
}
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#endif /* VPI_USER_EXT_H */
|
|
@@ -0,0 +1,209 @@
|
|
|
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
|
+
using verilated_trace_t = VerilatedFstC;
|
|
24
|
+
#else
|
|
25
|
+
#include <verilated_vcd_c.h>
|
|
26
|
+
using verilated_trace_t = VerilatedVcdC;
|
|
27
|
+
#endif
|
|
28
|
+
static verilated_trace_t *tfp;
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
static vluint64_t main_time = 0; // Current simulation time
|
|
32
|
+
|
|
33
|
+
double sc_time_stamp() { // Called by $time in Verilog
|
|
34
|
+
return main_time; // converts to double, to match
|
|
35
|
+
// what SystemC does
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
extern "C" {
|
|
39
|
+
void vlog_startup_routines_bootstrap(void);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static inline bool settle_value_callbacks() {
|
|
43
|
+
bool cbs_called, again;
|
|
44
|
+
|
|
45
|
+
// Call Value Change callbacks
|
|
46
|
+
// These can modify signal values so we loop
|
|
47
|
+
// until there are no more changes
|
|
48
|
+
cbs_called = again = VerilatedVpi::callValueCbs();
|
|
49
|
+
while (again) {
|
|
50
|
+
again = VerilatedVpi::callValueCbs();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return cbs_called;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
void wrap_up() {
|
|
57
|
+
VerilatedVpi::callCbs(cbEndOfSimulation);
|
|
58
|
+
|
|
59
|
+
#if VM_TRACE
|
|
60
|
+
if (tfp) {
|
|
61
|
+
delete tfp;
|
|
62
|
+
tfp = nullptr;
|
|
63
|
+
}
|
|
64
|
+
#endif
|
|
65
|
+
|
|
66
|
+
// VM_COVERAGE is a define which is set if Verilator is
|
|
67
|
+
// instructed to collect coverage (when compiling the simulation)
|
|
68
|
+
#if VM_COVERAGE
|
|
69
|
+
VerilatedCov::write(); // Uses +verilator+coverage+file+<filename>,
|
|
70
|
+
// defaults to coverage.dat
|
|
71
|
+
#endif
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
int main(int argc, char **argv) {
|
|
75
|
+
#if VM_TRACE_FST
|
|
76
|
+
const char *traceFile = "dump.fst";
|
|
77
|
+
#else
|
|
78
|
+
const char *traceFile = "dump.vcd";
|
|
79
|
+
#endif
|
|
80
|
+
bool traceOn = false;
|
|
81
|
+
bool traceFlush = false;
|
|
82
|
+
|
|
83
|
+
for (int i = 1; i < argc; i++) {
|
|
84
|
+
std::string arg = std::string(argv[i]);
|
|
85
|
+
if (arg == "--trace") {
|
|
86
|
+
#if VM_TRACE
|
|
87
|
+
traceOn = true;
|
|
88
|
+
#else
|
|
89
|
+
fprintf(stderr,
|
|
90
|
+
"Error: --trace requires the design to be built with trace "
|
|
91
|
+
"support\n");
|
|
92
|
+
return -1;
|
|
93
|
+
#endif
|
|
94
|
+
} else if (arg == "--trace-flush") {
|
|
95
|
+
traceFlush = true;
|
|
96
|
+
} else if (arg == "--trace-file") {
|
|
97
|
+
if (++i < argc) {
|
|
98
|
+
traceFile = argv[i];
|
|
99
|
+
} else {
|
|
100
|
+
fprintf(stderr, "Error: --trace-file requires a parameter\n");
|
|
101
|
+
return -1;
|
|
102
|
+
}
|
|
103
|
+
} else if (arg == "--help") {
|
|
104
|
+
fprintf(
|
|
105
|
+
stderr,
|
|
106
|
+
"usage: %s [--trace] [--trace-flush] [--trace-file TRACEFILE]\n"
|
|
107
|
+
"\n"
|
|
108
|
+
"cocotb + Verilator sim\n"
|
|
109
|
+
"\n"
|
|
110
|
+
"options:\n"
|
|
111
|
+
" --trace Enable tracing (VCD or FST)\n"
|
|
112
|
+
" --trace-flush Flush trace at each time step (slow)\n"
|
|
113
|
+
" --trace-file Specify the trace file name (%s by "
|
|
114
|
+
"default)\n",
|
|
115
|
+
basename(argv[0]), traceFile);
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Verilated::commandArgs(argc, argv);
|
|
121
|
+
#ifdef VERILATOR_SIM_DEBUG
|
|
122
|
+
Verilated::debug(99);
|
|
123
|
+
#endif
|
|
124
|
+
std::unique_ptr<Vtop> top(new Vtop(""));
|
|
125
|
+
Verilated::fatalOnVpiError(false); // otherwise it will fail on systemtf
|
|
126
|
+
|
|
127
|
+
#ifdef VERILATOR_SIM_DEBUG
|
|
128
|
+
Verilated::internalsDump();
|
|
129
|
+
#endif
|
|
130
|
+
|
|
131
|
+
#if VM_TRACE
|
|
132
|
+
Verilated::traceEverOn(true);
|
|
133
|
+
if (traceOn) {
|
|
134
|
+
tfp = new verilated_trace_t;
|
|
135
|
+
top->trace(tfp, 99);
|
|
136
|
+
tfp->open(traceFile);
|
|
137
|
+
}
|
|
138
|
+
#endif
|
|
139
|
+
|
|
140
|
+
vlog_startup_routines_bootstrap();
|
|
141
|
+
Verilated::addExitCb([](void *) { wrap_up(); }, nullptr);
|
|
142
|
+
VerilatedVpi::callCbs(cbStartOfSimulation);
|
|
143
|
+
settle_value_callbacks();
|
|
144
|
+
|
|
145
|
+
while (!Verilated::gotFinish()) {
|
|
146
|
+
do {
|
|
147
|
+
// We must evaluate whole design until we process all 'events' for
|
|
148
|
+
// this time step
|
|
149
|
+
do {
|
|
150
|
+
top->eval_step();
|
|
151
|
+
VerilatedVpi::clearEvalNeeded();
|
|
152
|
+
VerilatedVpi::doInertialPuts();
|
|
153
|
+
settle_value_callbacks();
|
|
154
|
+
} while (VerilatedVpi::evalNeeded());
|
|
155
|
+
|
|
156
|
+
// Run ReadWrite callback as we are done processing this eval step
|
|
157
|
+
VerilatedVpi::callCbs(cbReadWriteSynch);
|
|
158
|
+
VerilatedVpi::doInertialPuts();
|
|
159
|
+
settle_value_callbacks();
|
|
160
|
+
} while (VerilatedVpi::evalNeeded());
|
|
161
|
+
|
|
162
|
+
top->eval_end_step();
|
|
163
|
+
|
|
164
|
+
// Call ReadOnly callbacks
|
|
165
|
+
VerilatedVpi::callCbs(cbReadOnlySynch);
|
|
166
|
+
|
|
167
|
+
#if VM_TRACE
|
|
168
|
+
if (tfp) {
|
|
169
|
+
tfp->dump(main_time);
|
|
170
|
+
if (traceFlush) {
|
|
171
|
+
tfp->flush();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
#endif
|
|
175
|
+
// cocotb controls the clock inputs using cbAfterDelay so
|
|
176
|
+
// skip ahead to the next registered callback
|
|
177
|
+
const vluint64_t NO_TOP_EVENTS_PENDING = static_cast<vluint64_t>(~0ULL);
|
|
178
|
+
vluint64_t next_time_cocotb = VerilatedVpi::cbNextDeadline();
|
|
179
|
+
vluint64_t next_time_timing =
|
|
180
|
+
top->eventsPending() ? top->nextTimeSlot() : NO_TOP_EVENTS_PENDING;
|
|
181
|
+
vluint64_t next_time = std::min(next_time_cocotb, next_time_timing);
|
|
182
|
+
|
|
183
|
+
// If there are no more cbAfterDelay callbacks,
|
|
184
|
+
// the next deadline is max value, so end the simulation now
|
|
185
|
+
if (next_time == NO_TOP_EVENTS_PENDING) {
|
|
186
|
+
break;
|
|
187
|
+
} else {
|
|
188
|
+
main_time = next_time;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Call registered NextSimTime
|
|
192
|
+
// It should be called in simulation cycle before everything else
|
|
193
|
+
// but not on first cycle
|
|
194
|
+
VerilatedVpi::callCbs(cbNextSimTime);
|
|
195
|
+
settle_value_callbacks();
|
|
196
|
+
|
|
197
|
+
// Call registered timed callbacks (e.g. clock timer)
|
|
198
|
+
// These are called at the beginning of the time step
|
|
199
|
+
// before the iterative regions (IEEE 1800-2012 4.4.1)
|
|
200
|
+
VerilatedVpi::callTimedCbs();
|
|
201
|
+
settle_value_callbacks();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
top->final();
|
|
205
|
+
|
|
206
|
+
wrap_up();
|
|
207
|
+
|
|
208
|
+
return 0;
|
|
209
|
+
}
|