cocotb 1.9.2__cp311-cp311-win32.whl → 2.0.0rc2__cp311-cp311-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cocotb might be problematic. Click here for more details.

Files changed (161) hide show
  1. cocotb/_ANSI.py +65 -0
  2. cocotb/__init__.py +81 -327
  3. cocotb/_base_triggers.py +515 -0
  4. cocotb/_bridge.py +186 -0
  5. cocotb/_decorators.py +515 -0
  6. cocotb/_deprecation.py +3 -3
  7. cocotb/_exceptions.py +7 -0
  8. cocotb/_extended_awaitables.py +419 -0
  9. cocotb/_gpi_triggers.py +385 -0
  10. cocotb/_init.py +301 -0
  11. cocotb/_outcomes.py +54 -0
  12. cocotb/_profiling.py +46 -0
  13. cocotb/_py_compat.py +114 -29
  14. cocotb/_scheduler.py +448 -0
  15. cocotb/_test.py +248 -0
  16. cocotb/_test_factory.py +312 -0
  17. cocotb/_test_functions.py +42 -0
  18. cocotb/_typing.py +7 -0
  19. cocotb/_utils.py +274 -0
  20. cocotb/_version.py +3 -7
  21. cocotb/_xunit_reporter.py +66 -0
  22. cocotb/clock.py +353 -108
  23. cocotb/debug.py +24 -0
  24. cocotb/handle.py +1370 -793
  25. cocotb/libs/cocotb.dll +0 -0
  26. cocotb/libs/cocotb.exp +0 -0
  27. cocotb/libs/cocotb.lib +0 -0
  28. cocotb/libs/cocotbfli_modelsim.dll +0 -0
  29. cocotb/libs/cocotbfli_modelsim.exp +0 -0
  30. cocotb/libs/cocotbfli_modelsim.lib +0 -0
  31. cocotb/libs/cocotbutils.dll +0 -0
  32. cocotb/libs/cocotbutils.exp +0 -0
  33. cocotb/libs/cocotbutils.lib +0 -0
  34. cocotb/libs/cocotbvhpi_aldec.dll +0 -0
  35. cocotb/libs/cocotbvhpi_aldec.exp +0 -0
  36. cocotb/libs/cocotbvhpi_aldec.lib +0 -0
  37. cocotb/libs/cocotbvhpi_modelsim.dll +0 -0
  38. cocotb/libs/cocotbvhpi_modelsim.exp +0 -0
  39. cocotb/libs/cocotbvhpi_modelsim.lib +0 -0
  40. cocotb/libs/cocotbvpi_aldec.dll +0 -0
  41. cocotb/libs/cocotbvpi_aldec.exp +0 -0
  42. cocotb/libs/cocotbvpi_aldec.lib +0 -0
  43. cocotb/libs/cocotbvpi_ghdl.dll +0 -0
  44. cocotb/libs/cocotbvpi_ghdl.exp +0 -0
  45. cocotb/libs/cocotbvpi_ghdl.lib +0 -0
  46. cocotb/libs/cocotbvpi_icarus.exp +0 -0
  47. cocotb/libs/cocotbvpi_icarus.lib +0 -0
  48. cocotb/libs/cocotbvpi_icarus.vpl +0 -0
  49. cocotb/libs/cocotbvpi_modelsim.dll +0 -0
  50. cocotb/libs/cocotbvpi_modelsim.exp +0 -0
  51. cocotb/libs/cocotbvpi_modelsim.lib +0 -0
  52. cocotb/libs/embed.dll +0 -0
  53. cocotb/libs/embed.exp +0 -0
  54. cocotb/libs/embed.lib +0 -0
  55. cocotb/libs/gpi.dll +0 -0
  56. cocotb/libs/gpi.exp +0 -0
  57. cocotb/libs/gpi.lib +0 -0
  58. cocotb/libs/gpilog.dll +0 -0
  59. cocotb/libs/gpilog.exp +0 -0
  60. cocotb/libs/gpilog.lib +0 -0
  61. cocotb/libs/pygpilog.dll +0 -0
  62. cocotb/libs/pygpilog.exp +0 -0
  63. cocotb/libs/pygpilog.lib +0 -0
  64. cocotb/logging.py +424 -0
  65. cocotb/queue.py +103 -57
  66. cocotb/regression.py +680 -717
  67. cocotb/result.py +17 -188
  68. cocotb/share/def/aldec.exp +0 -0
  69. cocotb/share/def/aldec.lib +0 -0
  70. cocotb/share/def/ghdl.exp +0 -0
  71. cocotb/share/def/ghdl.lib +0 -0
  72. cocotb/share/def/icarus.exp +0 -0
  73. cocotb/share/def/icarus.lib +0 -0
  74. cocotb/share/def/modelsim.def +1 -0
  75. cocotb/share/def/modelsim.exp +0 -0
  76. cocotb/share/def/modelsim.lib +0 -0
  77. cocotb/share/include/cocotb_utils.h +9 -32
  78. cocotb/share/include/embed.h +7 -30
  79. cocotb/share/include/gpi.h +331 -137
  80. cocotb/share/include/gpi_logging.h +221 -142
  81. cocotb/share/include/py_gpi_logging.h +8 -5
  82. cocotb/share/include/vpi_user_ext.h +4 -26
  83. cocotb/share/lib/verilator/verilator.cpp +80 -67
  84. cocotb/simtime.py +230 -0
  85. cocotb/simulator.cp311-win32.exp +0 -0
  86. cocotb/simulator.cp311-win32.lib +0 -0
  87. cocotb/simulator.cp311-win32.pyd +0 -0
  88. cocotb/simulator.pyi +107 -0
  89. cocotb/task.py +478 -213
  90. cocotb/triggers.py +55 -1092
  91. cocotb/types/__init__.py +28 -47
  92. cocotb/types/_abstract_array.py +151 -0
  93. cocotb/types/_array.py +295 -0
  94. cocotb/types/_indexing.py +17 -0
  95. cocotb/types/_logic.py +333 -0
  96. cocotb/types/_logic_array.py +868 -0
  97. cocotb/types/{range.py → _range.py} +47 -48
  98. cocotb/types/_resolve.py +76 -0
  99. cocotb/utils.py +58 -646
  100. cocotb-2.0.0rc2.dist-info/METADATA +60 -0
  101. cocotb-2.0.0rc2.dist-info/RECORD +146 -0
  102. {cocotb-1.9.2.dist-info → cocotb-2.0.0rc2.dist-info}/WHEEL +1 -1
  103. cocotb-2.0.0rc2.dist-info/entry_points.txt +2 -0
  104. {cocotb-1.9.2.dist-info → cocotb-2.0.0rc2.dist-info/licenses}/LICENSE +1 -0
  105. {cocotb-1.9.2.dist-info → cocotb-2.0.0rc2.dist-info}/top_level.txt +1 -0
  106. cocotb_tools/__init__.py +0 -0
  107. cocotb_tools/_coverage.py +33 -0
  108. cocotb_tools/_vendor/__init__.py +3 -0
  109. cocotb_tools/check_results.py +65 -0
  110. cocotb_tools/combine_results.py +152 -0
  111. cocotb_tools/config.py +241 -0
  112. {cocotb → cocotb_tools}/ipython_support.py +29 -22
  113. cocotb_tools/makefiles/Makefile.deprecations +27 -0
  114. {cocotb/share → cocotb_tools}/makefiles/Makefile.inc +77 -55
  115. {cocotb/share → cocotb_tools}/makefiles/Makefile.sim +16 -33
  116. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.activehdl +9 -16
  117. cocotb_tools/makefiles/simulators/Makefile.cvc +61 -0
  118. cocotb_tools/makefiles/simulators/Makefile.dsim +39 -0
  119. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.ghdl +13 -42
  120. cocotb_tools/makefiles/simulators/Makefile.icarus +80 -0
  121. cocotb_tools/makefiles/simulators/Makefile.ius +93 -0
  122. cocotb_tools/makefiles/simulators/Makefile.modelsim +9 -0
  123. cocotb_tools/makefiles/simulators/Makefile.nvc +60 -0
  124. cocotb_tools/makefiles/simulators/Makefile.questa +29 -0
  125. cocotb/share/makefiles/simulators/Makefile.questa → cocotb_tools/makefiles/simulators/Makefile.questa-compat +26 -54
  126. cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun +149 -0
  127. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.riviera +17 -56
  128. cocotb_tools/makefiles/simulators/Makefile.vcs +65 -0
  129. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.verilator +15 -22
  130. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.xcelium +20 -52
  131. cocotb_tools/py.typed +0 -0
  132. cocotb_tools/runner.py +1868 -0
  133. cocotb/_sim_versions.py → cocotb_tools/sim_versions.py +16 -21
  134. pygpi/entry.py +34 -18
  135. pygpi/py.typed +0 -0
  136. cocotb/ANSI.py +0 -92
  137. cocotb/binary.py +0 -858
  138. cocotb/config.py +0 -289
  139. cocotb/decorators.py +0 -332
  140. cocotb/log.py +0 -303
  141. cocotb/memdebug.py +0 -35
  142. cocotb/outcomes.py +0 -56
  143. cocotb/runner.py +0 -1400
  144. cocotb/scheduler.py +0 -1099
  145. cocotb/share/makefiles/Makefile.deprecations +0 -12
  146. cocotb/share/makefiles/simulators/Makefile.cvc +0 -94
  147. cocotb/share/makefiles/simulators/Makefile.icarus +0 -111
  148. cocotb/share/makefiles/simulators/Makefile.ius +0 -125
  149. cocotb/share/makefiles/simulators/Makefile.modelsim +0 -32
  150. cocotb/share/makefiles/simulators/Makefile.nvc +0 -64
  151. cocotb/share/makefiles/simulators/Makefile.vcs +0 -98
  152. cocotb/types/array.py +0 -309
  153. cocotb/types/logic.py +0 -292
  154. cocotb/types/logic_array.py +0 -298
  155. cocotb/wavedrom.py +0 -199
  156. cocotb/xunit_reporter.py +0 -80
  157. cocotb-1.9.2.dist-info/METADATA +0 -168
  158. cocotb-1.9.2.dist-info/RECORD +0 -121
  159. cocotb-1.9.2.dist-info/entry_points.txt +0 -2
  160. /cocotb/{_vendor/__init__.py → py.typed} +0 -0
  161. {cocotb → cocotb_tools}/_vendor/distutils_version.py +0 -0
@@ -1,44 +1,23 @@
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
- ******************************************************************************/
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
29
6
 
30
7
  #ifndef COCOTB_GPI_LOGGING_H_
31
8
  #define COCOTB_GPI_LOGGING_H_
32
9
 
33
- #include <exports.h>
10
+ #include <cstdarg> // va_list
11
+ #include <cstring> // strlen
12
+
13
+ #include "exports.h"
14
+
34
15
  #ifdef GPILOG_EXPORTS
35
16
  #define GPILOG_EXPORT COCOTB_EXPORT
36
17
  #else
37
18
  #define GPILOG_EXPORT COCOTB_IMPORT
38
19
  #endif
39
20
 
40
- #include <cstdarg>
41
-
42
21
  #ifdef __cplusplus
43
22
  extern "C" {
44
23
  #endif
@@ -50,158 +29,258 @@ extern "C" {
50
29
  * Python logging module. Implementers of custom loggers should emit human
51
30
  * readable level names for these value, but may support other values.
52
31
  */
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
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.
65
48
  };
66
49
 
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
- */
50
+ #define LOG_EXPLICIT(logger, level, file, func, lineno, ...) \
51
+ gpi_log_(logger, level, file, func, lineno, __VA_ARGS__)
52
+
71
53
  #define LOG_(level, ...) \
72
- gpi_log("gpi", level, __FILE__, __func__, __LINE__, __VA_ARGS__);
54
+ gpi_log_("gpi", level, __FILE__, __func__, __LINE__, __VA_ARGS__)
73
55
 
74
56
  /** 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__)
57
+ Automatically populates arguments using information in the called context.
58
+ */
59
+ #define LOG_TRACE(...) LOG_(GPI_TRACE, __VA_ARGS__)
78
60
 
79
61
  /** 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__)
62
+ Automatically populates arguments using information in the called context.
63
+ */
64
+ #define LOG_DEBUG(...) LOG_(GPI_DEBUG, __VA_ARGS__)
83
65
 
84
66
  /** 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__);
67
+ Automatically populates arguments using information in the called context.
68
+ */
69
+ #define LOG_INFO(...) LOG_(GPI_INFO, __VA_ARGS__)
88
70
 
89
71
  /** 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__);
72
+ Automatically populates arguments using information in the called context.
73
+ */
74
+ #define LOG_WARN(...) LOG_(GPI_WARNING, __VA_ARGS__)
93
75
 
94
76
  /** 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__);
77
+ Automatically populates arguments using information in the called context.
78
+ */
79
+ #define LOG_ERROR(...) LOG_(GPI_ERROR, __VA_ARGS__)
98
80
 
99
81
  /** Logs a message at CRITICAL log level using the current log handler.
100
- Automatically populates arguments using information in the called context.
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
101
99
  */
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
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
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);
115
+ typedef bool (*gpi_log_filter_ftype)(void *userdata, const char *logger,
116
+ int level);
118
117
 
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
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*.
129
127
  */
130
- GPILOG_EXPORT void gpi_log(const char *name, int level, const char *pathname,
131
- const char *funcname, long lineno, const char *msg,
132
- ...);
128
+ typedef bool (*gpi_log_set_level_ftype)(void *userdata, const char *logger,
129
+ int level);
133
130
 
134
131
  /** 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
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
144
141
  */
145
- GPILOG_EXPORT void gpi_vlog(const char *name, int level, const char *pathname,
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,
146
149
  const char *funcname, long lineno, const char *msg,
147
- va_list args);
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);
148
191
 
149
192
  /** 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
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`.
153
201
  */
154
- GPILOG_EXPORT void gpi_get_log_handler(gpi_log_handler_type **handler,
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,
155
205
  void **userdata);
156
206
 
157
207
  /** 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
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.
160
212
  */
161
- GPILOG_EXPORT void gpi_set_log_handler(gpi_log_handler_type *handler,
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,
162
216
  void *userdata);
163
217
 
164
- /** Clear the current custom log handler and use native logger
165
- */
218
+ /** Clear the current custom log handler and use native logger. */
166
219
  GPILOG_EXPORT void gpi_clear_log_handler(void);
167
220
 
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, ...);
221
+ /*******************************************************************************
222
+ * GPI Native Logger
223
+ *******************************************************************************/
183
224
 
184
225
  /** 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
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
194
235
  */
195
- GPILOG_EXPORT void gpi_native_logger_vlog(const char *name, int level,
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,
196
244
  const char *pathname,
197
245
  const char *funcname, long lineno,
198
- const char *msg, va_list args);
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);
199
277
 
200
278
  /** 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
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
205
284
  */
206
285
  GPILOG_EXPORT int gpi_native_logger_set_level(int level);
207
286
 
@@ -5,7 +5,10 @@
5
5
  #ifndef PY_GPI_LOGGING_H
6
6
  #define PY_GPI_LOGGING_H
7
7
 
8
- #include <exports.h>
8
+ #include <Python.h>
9
+
10
+ #include "exports.h"
11
+
9
12
  #ifdef PYGPILOG_EXPORTS
10
13
  #define PYGPILOG_EXPORT COCOTB_EXPORT
11
14
  #else
@@ -16,13 +19,13 @@
16
19
  extern "C" {
17
20
  #endif
18
21
 
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);
22
+ PYGPILOG_EXPORT void py_gpi_logger_initialize(PyObject *handler,
23
+ PyObject *get_logger);
23
24
 
24
25
  PYGPILOG_EXPORT void py_gpi_logger_finalize();
25
26
 
27
+ extern PYGPILOG_EXPORT PyObject *pEventFn; // This is gross but I don't care
28
+
26
29
  #ifdef __cplusplus
27
30
  }
28
31
  #endif
@@ -1,29 +1,7 @@
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
- ******************************************************************************/
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
27
5
 
28
6
  /* extensions to vpi_user.h */
29
7