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,265 @@
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"
19
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ * ARE 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
+ #ifndef COCOTB_GPI_H_
31
+ #define COCOTB_GPI_H_
32
+
33
+ /*
34
+ Generic Language Interface
35
+
36
+ This header file defines a Generic Language Interface into any simulator.
37
+ Implementations need to implement the underlying functions in gpi_priv.h
38
+
39
+ The functions are essentially a limited subset of VPI/VHPI/FLI.
40
+
41
+ Implementation specific notes
42
+ =============================
43
+
44
+ By amazing coincidence, VPI and VHPI are strikingly similar which is obviously
45
+ reflected by this header file. Unfortunately, this means that proprietry,
46
+ non-standard, less featured language interfaces (for example Mentor FLI) may
47
+ have to resort to some hackery.
48
+
49
+ Because of the lack of ability to register a callback on event change using the
50
+ FLI, we have to create a process with the signal on the sensitivity list to
51
+ imitate a callback.
52
+
53
+ */
54
+
55
+ #include <exports.h>
56
+ #ifdef GPI_EXPORTS
57
+ #define GPI_EXPORT COCOTB_EXPORT
58
+ #else
59
+ #define GPI_EXPORT COCOTB_IMPORT
60
+ #endif
61
+
62
+ #include <gpi_logging.h>
63
+ #include <stdbool.h>
64
+ #include <stdint.h>
65
+ #include <stdio.h>
66
+ #include <stdlib.h>
67
+ #include <string.h>
68
+
69
+ /*
70
+ * Declare the handle types.
71
+ *
72
+ * We want these handles to be opaque pointers, since their layout is not
73
+ * exposed to C. We do this by using incomplete types. The assumption being
74
+ * made here is that `sizeof(some_cpp_class*) == sizeof(some_c_struct*)`, which
75
+ * is true on all reasonable platforms.
76
+ */
77
+ #ifdef __cplusplus
78
+ /* In C++, we use forward-declarations of the types in gpi_priv.h as our
79
+ * incomplete types, as this avoids the need for any casting in GpiCommon.cpp.
80
+ */
81
+ class GpiObjHdl;
82
+ class GpiCbHdl;
83
+ class GpiIterator;
84
+ typedef GpiObjHdl *gpi_sim_hdl;
85
+ typedef GpiCbHdl *gpi_cb_hdl;
86
+ typedef GpiIterator *gpi_iterator_hdl;
87
+ #else
88
+ /* In C, we declare some incomplete struct types that we never complete.
89
+ * The names of these are irrelevant, but for simplicity they match the C++
90
+ * names.
91
+ */
92
+ struct GpiObjHdl;
93
+ struct GpiCbHdl;
94
+ struct GpiIterator;
95
+ typedef struct GpiObjHdl *gpi_sim_hdl;
96
+ typedef struct GpiCbHdl *gpi_cb_hdl;
97
+ typedef struct GpiIterator *gpi_iterator_hdl;
98
+ #endif
99
+
100
+ #ifdef __cplusplus
101
+ extern "C" {
102
+ #endif
103
+
104
+ // Functions for controlling/querying the simulation state
105
+
106
+ /**
107
+ * Returns 1 if there is a registered GPI implementation, 0 otherwise.
108
+ *
109
+ * Useful for checking if a simulator is running.
110
+ */
111
+ GPI_EXPORT bool gpi_has_registered_impl(void);
112
+
113
+ // Stop the simulator
114
+ GPI_EXPORT void gpi_sim_end(void);
115
+
116
+ // Returns simulation time as two uints. Units are default sim units
117
+ GPI_EXPORT void gpi_get_sim_time(uint32_t *high, uint32_t *low);
118
+ GPI_EXPORT void gpi_get_sim_precision(int32_t *precision);
119
+
120
+ /**
121
+ * Returns a string with the running simulator product information
122
+ *
123
+ * @return simulator product string
124
+ */
125
+ GPI_EXPORT const char *gpi_get_simulator_product(void);
126
+
127
+ /**
128
+ * Returns a string with the running simulator version
129
+ *
130
+ * @return simulator version string
131
+ */
132
+ GPI_EXPORT const char *gpi_get_simulator_version(void);
133
+
134
+ // Functions for extracting a gpi_sim_hdl to an object
135
+ // Returns a handle to the root simulation object,
136
+ // Should be freed with gpi_free_handle
137
+ GPI_EXPORT gpi_sim_hdl gpi_get_root_handle(const char *name);
138
+ GPI_EXPORT gpi_sim_hdl gpi_get_handle_by_name(gpi_sim_hdl parent,
139
+ const char *name);
140
+ GPI_EXPORT gpi_sim_hdl gpi_get_handle_by_index(gpi_sim_hdl parent,
141
+ int32_t index);
142
+ GPI_EXPORT void gpi_free_handle(gpi_sim_hdl gpi_hdl);
143
+
144
+ // Types that can be passed to the iterator.
145
+ //
146
+ // Note these are strikingly similar to the VPI types...
147
+ typedef enum gpi_objtype_e {
148
+ GPI_UNKNOWN = 0,
149
+ GPI_MEMORY = 1,
150
+ GPI_MODULE = 2,
151
+ GPI_NET = 3,
152
+ // GPI_PARAMETER = 4, // Deprecated
153
+ GPI_REGISTER = 5,
154
+ GPI_ARRAY = 6,
155
+ GPI_ENUM = 7,
156
+ GPI_STRUCTURE = 8,
157
+ GPI_REAL = 9,
158
+ GPI_INTEGER = 10,
159
+ GPI_STRING = 11,
160
+ GPI_GENARRAY = 12,
161
+ } gpi_objtype_t;
162
+
163
+ // When iterating, we can chose to either get child objects, drivers or loads
164
+ typedef enum gpi_iterator_sel_e {
165
+ GPI_OBJECTS = 1,
166
+ GPI_DRIVERS = 2,
167
+ GPI_LOADS = 3,
168
+ } gpi_iterator_sel_t;
169
+
170
+ typedef enum gpi_set_action_e {
171
+ GPI_DEPOSIT = 0,
172
+ GPI_FORCE = 1,
173
+ GPI_RELEASE = 2,
174
+ } gpi_set_action_t;
175
+
176
+ // Functions for iterating over entries of a handle
177
+ // Returns an iterator handle which can then be used in gpi_next calls
178
+ //
179
+ // Unlike `vpi_iterate` the iterator handle may only be NULL if the `type` is
180
+ // not supported, If no objects of the requested type are found, an empty
181
+ // iterator is returned.
182
+ GPI_EXPORT gpi_iterator_hdl gpi_iterate(gpi_sim_hdl base,
183
+ gpi_iterator_sel_t type);
184
+
185
+ // Returns NULL when there are no more objects
186
+ GPI_EXPORT gpi_sim_hdl gpi_next(gpi_iterator_hdl iterator);
187
+
188
+ // Returns the number of objects in the collection of the handle
189
+ GPI_EXPORT int gpi_get_num_elems(gpi_sim_hdl gpi_sim_hdl);
190
+
191
+ // Returns the left side of the range constraint
192
+ GPI_EXPORT int gpi_get_range_left(gpi_sim_hdl gpi_sim_hdl);
193
+
194
+ // Returns the right side of the range constraint
195
+ GPI_EXPORT int gpi_get_range_right(gpi_sim_hdl gpi_sim_hdl);
196
+
197
+ // Functions for querying the properties of a handle
198
+ // Caller responsible for freeing the returned string.
199
+ // This is all slightly verbose but it saves having to enumerate various value
200
+ // types We only care about a limited subset of values.
201
+ GPI_EXPORT const char *gpi_get_signal_value_binstr(gpi_sim_hdl gpi_hdl);
202
+ GPI_EXPORT const char *gpi_get_signal_value_str(gpi_sim_hdl gpi_hdl);
203
+ GPI_EXPORT double gpi_get_signal_value_real(gpi_sim_hdl gpi_hdl);
204
+ GPI_EXPORT long gpi_get_signal_value_long(gpi_sim_hdl gpi_hdl);
205
+ GPI_EXPORT const char *gpi_get_signal_name_str(gpi_sim_hdl gpi_hdl);
206
+ GPI_EXPORT const char *gpi_get_signal_type_str(gpi_sim_hdl gpi_hdl);
207
+
208
+ // Returns one of the types defined above e.g. gpiMemory etc.
209
+ GPI_EXPORT gpi_objtype_t gpi_get_object_type(gpi_sim_hdl gpi_hdl);
210
+
211
+ // Get information about the definition of a handle
212
+ GPI_EXPORT const char *gpi_get_definition_name(gpi_sim_hdl gpi_hdl);
213
+ GPI_EXPORT const char *gpi_get_definition_file(gpi_sim_hdl gpi_hdl);
214
+
215
+ // Determine whether an object value is constant (parameters / generics etc)
216
+ GPI_EXPORT int gpi_is_constant(gpi_sim_hdl gpi_hdl);
217
+
218
+ // Determine whether an object is indexable
219
+ GPI_EXPORT int gpi_is_indexable(gpi_sim_hdl gpi_hdl);
220
+
221
+ // Functions for setting the properties of a handle
222
+ GPI_EXPORT void gpi_set_signal_value_real(gpi_sim_hdl gpi_hdl, double value,
223
+ gpi_set_action_t action);
224
+ GPI_EXPORT void gpi_set_signal_value_int(gpi_sim_hdl gpi_hdl, int32_t value,
225
+ gpi_set_action_t action);
226
+ GPI_EXPORT void gpi_set_signal_value_binstr(
227
+ gpi_sim_hdl gpi_hdl, const char *str,
228
+ gpi_set_action_t action); // String of binary char(s) [1, 0, x, z]
229
+ GPI_EXPORT void gpi_set_signal_value_str(
230
+ gpi_sim_hdl gpi_hdl, const char *str,
231
+ gpi_set_action_t action); // String of ASCII char(s)
232
+
233
+ typedef enum gpi_edge {
234
+ GPI_RISING = 1,
235
+ GPI_FALLING = 2,
236
+ } gpi_edge_e;
237
+
238
+ // The callback registering functions
239
+ GPI_EXPORT gpi_cb_hdl gpi_register_timed_callback(int (*gpi_function)(void *),
240
+ void *gpi_cb_data,
241
+ uint64_t time);
242
+ GPI_EXPORT gpi_cb_hdl gpi_register_value_change_callback(
243
+ int (*gpi_function)(void *), void *gpi_cb_data, gpi_sim_hdl gpi_hdl,
244
+ int edge);
245
+ GPI_EXPORT gpi_cb_hdl
246
+ gpi_register_readonly_callback(int (*gpi_function)(void *), void *gpi_cb_data);
247
+ GPI_EXPORT gpi_cb_hdl
248
+ gpi_register_nexttime_callback(int (*gpi_function)(void *), void *gpi_cb_data);
249
+ GPI_EXPORT gpi_cb_hdl
250
+ gpi_register_readwrite_callback(int (*gpi_function)(void *), void *gpi_cb_data);
251
+
252
+ // Calling convention is that 0 = success and negative numbers a failure
253
+ // For implementers of GPI the provided macro GPI_RET(x) is provided
254
+ GPI_EXPORT void gpi_deregister_callback(gpi_cb_hdl gpi_hdl);
255
+
256
+ // Because the internal structures may be different for different
257
+ // implementations of GPI we provide a convenience function to extract the
258
+ // callback data
259
+ GPI_EXPORT void *gpi_get_callback_data(gpi_cb_hdl gpi_hdl);
260
+
261
+ #ifdef __cplusplus
262
+ }
263
+ #endif
264
+
265
+ #endif /* COCOTB_GPI_H_ */
@@ -0,0 +1,212 @@
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"
19
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ * ARE 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
+ #ifndef COCOTB_GPI_LOGGING_H_
31
+ #define COCOTB_GPI_LOGGING_H_
32
+
33
+ #include <exports.h>
34
+ #ifdef GPILOG_EXPORTS
35
+ #define GPILOG_EXPORT COCOTB_EXPORT
36
+ #else
37
+ #define GPILOG_EXPORT COCOTB_IMPORT
38
+ #endif
39
+
40
+ #include <cstdarg>
41
+
42
+ #ifdef __cplusplus
43
+ extern "C" {
44
+ #endif
45
+
46
+ /** Named logging level
47
+ *
48
+ * The native logger only logs level names at these log level values.
49
+ * They were specifically chosen to align with the default level values in the
50
+ * Python logging module. Implementers of custom loggers should emit human
51
+ * readable level names for these value, but may support other values.
52
+ */
53
+ enum gpi_log_levels {
54
+ GPITrace = 5, ///< Prints `TRACE` by default. Information about execution
55
+ ///< of simulator callbacks and Python / simulator contexts
56
+ GPIDebug = 10, ///< Prints `DEBUG` by default. Verbose information, useful
57
+ ///< for debugging
58
+ GPIInfo = 20, ///< Prints `INFO` by default. Information about major events
59
+ ///< in the current program
60
+ GPIWarning = 30, ///< Prints `WARN` by default. Encountered a recoverable
61
+ ///< bug, or information about surprising behavior
62
+ GPIError = 40, ///< Prints `ERROR` by default. An unrecoverable error
63
+ GPICritical = 50 ///< Prints `CRITICAL` by default. An unrecoverable error,
64
+ ///< to be followed by immediate simulator shutdown
65
+ };
66
+
67
+ /** Logs a message at the given log level using the current log handler.
68
+ Automatically populates arguments using information in the called context.
69
+ @param level The level at which to log the message
70
+ */
71
+ #define LOG_(level, ...) \
72
+ gpi_log("gpi", level, __FILE__, __func__, __LINE__, __VA_ARGS__);
73
+
74
+ /** Logs a message at TRACE log level using the current log handler.
75
+ Automatically populates arguments using information in the called context.
76
+ */
77
+ #define LOG_TRACE(...) LOG_(GPITrace, __VA_ARGS__)
78
+
79
+ /** Logs a message at DEBUG log level using the current log handler.
80
+ Automatically populates arguments using information in the called context.
81
+ */
82
+ #define LOG_DEBUG(...) LOG_(GPIDebug, __VA_ARGS__)
83
+
84
+ /** Logs a message at INFO log level using the current log handler.
85
+ Automatically populates arguments using information in the called context.
86
+ */
87
+ #define LOG_INFO(...) LOG_(GPIInfo, __VA_ARGS__);
88
+
89
+ /** Logs a message at WARN log level using the current log handler.
90
+ Automatically populates arguments using information in the called context.
91
+ */
92
+ #define LOG_WARN(...) LOG_(GPIWarning, __VA_ARGS__);
93
+
94
+ /** Logs a message at ERROR log level using the current log handler.
95
+ Automatically populates arguments using information in the called context.
96
+ */
97
+ #define LOG_ERROR(...) LOG_(GPIError, __VA_ARGS__);
98
+
99
+ /** Logs a message at CRITICAL log level using the current log handler.
100
+ Automatically populates arguments using information in the called context.
101
+ */
102
+ #define LOG_CRITICAL(...) LOG_(GPICritical, __VA_ARGS__);
103
+
104
+ /** Type of a log handler function.
105
+ @param userdata private implementation data registered with this function
106
+ @param name Name of the logger
107
+ @param level Level at which to log the message
108
+ @param pathname Name of the file where the call site is located
109
+ @param funcname Name of the function where the call site is located
110
+ @param lineno Line number of the call site
111
+ @param msg The message to log, uses C-sprintf-style format specifier
112
+ @param args Additional arguments; formatted and inserted in message
113
+ according to format specifier in msg argument
114
+ */
115
+ typedef void(gpi_log_handler_type)(void *userdata, const char *name, int level,
116
+ const char *pathname, const char *funcname,
117
+ long lineno, const char *msg, va_list args);
118
+
119
+ /** Log a message using the currently registered log handler.
120
+ User is expected to populate all arguments to this function.
121
+ @param name Name of the logger
122
+ @param level Level at which to log the message
123
+ @param pathname Name of the file where the call site is located
124
+ @param funcname Name of the function where the call site is located
125
+ @param lineno Line number of the call site
126
+ @param msg The message to log, uses C-sprintf-style format specifier
127
+ @param ... Additional arguments; formatted and inserted in message
128
+ according to format specifier in msg argument
129
+ */
130
+ GPILOG_EXPORT void gpi_log(const char *name, int level, const char *pathname,
131
+ const char *funcname, long lineno, const char *msg,
132
+ ...);
133
+
134
+ /** Log a message using the currently registered log handler.
135
+ User is expected to populate all arguments to this function.
136
+ @param name Name of the logger
137
+ @param level Level at which to log the message
138
+ @param pathname Name of the file where the call site is located
139
+ @param funcname Name of the function where the call site is located
140
+ @param lineno Line number of the call site
141
+ @param msg The message to log, uses C-sprintf-style format specifier
142
+ @param args Additional arguments; formatted and inserted in message
143
+ according to format specifier in msg argument
144
+ */
145
+ GPILOG_EXPORT void gpi_vlog(const char *name, int level, const char *pathname,
146
+ const char *funcname, long lineno, const char *msg,
147
+ va_list args);
148
+
149
+ /** Retrieve the current log handler.
150
+ @param handler Location to return current log handler. If no custom logger
151
+ is registered this will be `NULL`.
152
+ @param userdata Location to return log handler userdata
153
+ */
154
+ GPILOG_EXPORT void gpi_get_log_handler(gpi_log_handler_type **handler,
155
+ void **userdata);
156
+
157
+ /** Set custom log handler
158
+ @param handler Handler function to call when the GPI logs a message
159
+ @param userdata Data to pass to the handler function when logging a message
160
+ */
161
+ GPILOG_EXPORT void gpi_set_log_handler(gpi_log_handler_type *handler,
162
+ void *userdata);
163
+
164
+ /** Clear the current custom log handler and use native logger
165
+ */
166
+ GPILOG_EXPORT void gpi_clear_log_handler(void);
167
+
168
+ /** Log a message using the native log handler.
169
+ User is expected to populate all arguments to this function.
170
+ @param name Name of the logger
171
+ @param level Level at which to log the message
172
+ @param pathname Name of the file where the call site is located
173
+ @param funcname Name of the function where the call site is located
174
+ @param lineno Line number of the call site
175
+ @param msg The message to log, uses C-sprintf-style format specifier
176
+ @param ... Additional arguments; formatted and inserted in message
177
+ according to format specifier in msg argument
178
+ */
179
+ GPILOG_EXPORT void gpi_native_logger_log(const char *name, int level,
180
+ const char *pathname,
181
+ const char *funcname, long lineno,
182
+ const char *msg, ...);
183
+
184
+ /** Log a message using the native log handler.
185
+ User is expected to populate all arguments to this function.
186
+ @param name Name of the logger
187
+ @param level Level at which to log the message
188
+ @param pathname Name of the file where the call site is located
189
+ @param funcname Name of the function where the call site is located
190
+ @param lineno Line number of the call site
191
+ @param msg The message to log, uses C-sprintf-style format specifier
192
+ @param args Additional arguments; formatted and inserted in message
193
+ according to format specifier in msg argument
194
+ */
195
+ GPILOG_EXPORT void gpi_native_logger_vlog(const char *name, int level,
196
+ const char *pathname,
197
+ const char *funcname, long lineno,
198
+ const char *msg, va_list args);
199
+
200
+ /** Set minimum logging level of the native logger.
201
+ If a logging request occurs where the logging level is lower than the level
202
+ set by this function, it is not logged. Only affects the native logger.
203
+ @param level Logging level
204
+ @return Previous logging level
205
+ */
206
+ GPILOG_EXPORT int gpi_native_logger_set_level(int level);
207
+
208
+ #ifdef __cplusplus
209
+ }
210
+ #endif
211
+
212
+ #endif /* COCOTB_GPI_LOGGING_H_ */
@@ -0,0 +1,30 @@
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 <exports.h>
9
+ #ifdef PYGPILOG_EXPORTS
10
+ #define PYGPILOG_EXPORT COCOTB_EXPORT
11
+ #else
12
+ #define PYGPILOG_EXPORT COCOTB_IMPORT
13
+ #endif
14
+
15
+ #ifdef __cplusplus
16
+ extern "C" {
17
+ #endif
18
+
19
+ PYGPILOG_EXPORT void py_gpi_logger_set_level(int level);
20
+
21
+ PYGPILOG_EXPORT void py_gpi_logger_initialize(PyObject* handler,
22
+ PyObject* filter);
23
+
24
+ PYGPILOG_EXPORT void py_gpi_logger_finalize();
25
+
26
+ #ifdef __cplusplus
27
+ }
28
+ #endif
29
+
30
+ #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,55 @@
1
+ /******************************************************************************
2
+ * Copyright (c) 2013, 2019 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
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
+ /* extensions to vpi_user.h */
29
+
30
+ #ifndef VPI_USER_EXT_H
31
+ #define VPI_USER_EXT_H
32
+
33
+ #ifdef __cplusplus
34
+ extern "C" {
35
+ #endif
36
+
37
+ /* used by Cadence Xcelium for packed unions */
38
+ #define vpiUnionNet 525
39
+
40
+ /* used by Cadence Xcelium for Verilog-AMS */
41
+ #define vpiRealNet 526
42
+ #define vpiInterconnectNet 533
43
+ #define vpiInterconnectArray 534
44
+
45
+ /* arguments for vpiStop or vpiFinish */
46
+ #define vpiDiagNone 0 /* prints nothing */
47
+ #define vpiDiagTimeLoc 1 /* prints simulation time and location */
48
+ #define vpiDiagTimeLocCPUMem 2 /* prints simulation time, location and
49
+ statistics about CPU and memory usage */
50
+
51
+ #ifdef __cplusplus
52
+ }
53
+ #endif
54
+
55
+ #endif /* VPI_USER_EXT_H */