cocotb 2.0.0b1__cp311-cp311-win_amd64.whl → 2.0.0rc2__cp311-cp311-win_amd64.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 (95) hide show
  1. cocotb/_ANSI.py +47 -54
  2. cocotb/__init__.py +12 -2
  3. cocotb/_base_triggers.py +11 -9
  4. cocotb/_bridge.py +8 -9
  5. cocotb/_extended_awaitables.py +1 -1
  6. cocotb/_gpi_triggers.py +4 -1
  7. cocotb/_init.py +17 -11
  8. cocotb/_py_compat.py +24 -10
  9. cocotb/_scheduler.py +25 -31
  10. cocotb/_test.py +6 -3
  11. cocotb/_test_factory.py +4 -1
  12. cocotb/_utils.py +1 -23
  13. cocotb/_version.py +1 -1
  14. cocotb/clock.py +98 -16
  15. cocotb/debug.py +24 -0
  16. cocotb/handle.py +62 -32
  17. cocotb/libs/cocotb.dll +0 -0
  18. cocotb/libs/cocotb.exp +0 -0
  19. cocotb/libs/cocotb.lib +0 -0
  20. cocotb/libs/cocotbfli_modelsim.dll +0 -0
  21. cocotb/libs/cocotbfli_modelsim.exp +0 -0
  22. cocotb/libs/cocotbfli_modelsim.lib +0 -0
  23. cocotb/libs/cocotbutils.dll +0 -0
  24. cocotb/libs/cocotbutils.exp +0 -0
  25. cocotb/libs/cocotbutils.lib +0 -0
  26. cocotb/libs/cocotbvhpi_aldec.dll +0 -0
  27. cocotb/libs/cocotbvhpi_aldec.exp +0 -0
  28. cocotb/libs/cocotbvhpi_aldec.lib +0 -0
  29. cocotb/libs/cocotbvhpi_modelsim.dll +0 -0
  30. cocotb/libs/cocotbvhpi_modelsim.exp +0 -0
  31. cocotb/libs/cocotbvhpi_modelsim.lib +0 -0
  32. cocotb/libs/cocotbvpi_aldec.dll +0 -0
  33. cocotb/libs/cocotbvpi_aldec.exp +0 -0
  34. cocotb/libs/cocotbvpi_aldec.lib +0 -0
  35. cocotb/libs/cocotbvpi_ghdl.dll +0 -0
  36. cocotb/libs/cocotbvpi_ghdl.exp +0 -0
  37. cocotb/libs/cocotbvpi_ghdl.lib +0 -0
  38. cocotb/libs/cocotbvpi_icarus.exp +0 -0
  39. cocotb/libs/cocotbvpi_icarus.lib +0 -0
  40. cocotb/libs/cocotbvpi_icarus.vpl +0 -0
  41. cocotb/libs/cocotbvpi_modelsim.dll +0 -0
  42. cocotb/libs/cocotbvpi_modelsim.exp +0 -0
  43. cocotb/libs/cocotbvpi_modelsim.lib +0 -0
  44. cocotb/libs/embed.dll +0 -0
  45. cocotb/libs/embed.exp +0 -0
  46. cocotb/libs/embed.lib +0 -0
  47. cocotb/libs/gpi.dll +0 -0
  48. cocotb/libs/gpi.exp +0 -0
  49. cocotb/libs/gpi.lib +0 -0
  50. cocotb/libs/gpilog.dll +0 -0
  51. cocotb/libs/gpilog.exp +0 -0
  52. cocotb/libs/gpilog.lib +0 -0
  53. cocotb/libs/pygpilog.dll +0 -0
  54. cocotb/libs/pygpilog.exp +0 -0
  55. cocotb/libs/pygpilog.lib +0 -0
  56. cocotb/logging.py +243 -117
  57. cocotb/regression.py +43 -35
  58. cocotb/share/def/aldec.exp +0 -0
  59. cocotb/share/def/aldec.lib +0 -0
  60. cocotb/share/def/ghdl.exp +0 -0
  61. cocotb/share/def/ghdl.lib +0 -0
  62. cocotb/share/def/icarus.exp +0 -0
  63. cocotb/share/def/icarus.lib +0 -0
  64. cocotb/share/def/modelsim.exp +0 -0
  65. cocotb/share/def/modelsim.lib +0 -0
  66. cocotb/share/include/cocotb_utils.h +3 -3
  67. cocotb/share/include/embed.h +2 -2
  68. cocotb/share/include/gpi.h +258 -109
  69. cocotb/share/include/py_gpi_logging.h +3 -3
  70. cocotb/share/lib/verilator/verilator.cpp +23 -15
  71. cocotb/simtime.py +230 -0
  72. cocotb/simulator.cp311-win_amd64.exp +0 -0
  73. cocotb/simulator.cp311-win_amd64.lib +0 -0
  74. cocotb/simulator.cp311-win_amd64.pyd +0 -0
  75. cocotb/task.py +54 -11
  76. cocotb/types/__init__.py +4 -1
  77. cocotb/types/_array.py +33 -2
  78. cocotb/types/_indexing.py +17 -0
  79. cocotb/types/_logic.py +96 -59
  80. cocotb/types/_logic_array.py +56 -22
  81. cocotb/types/_range.py +12 -5
  82. cocotb/utils.py +9 -129
  83. {cocotb-2.0.0b1.dist-info → cocotb-2.0.0rc2.dist-info}/METADATA +1 -1
  84. cocotb-2.0.0rc2.dist-info/RECORD +146 -0
  85. {cocotb-2.0.0b1.dist-info → cocotb-2.0.0rc2.dist-info}/licenses/LICENSE +1 -0
  86. cocotb_tools/config.py +5 -5
  87. cocotb_tools/makefiles/Makefile.inc +3 -9
  88. cocotb_tools/makefiles/Makefile.sim +9 -1
  89. cocotb_tools/makefiles/simulators/Makefile.vcs +1 -1
  90. cocotb_tools/runner.py +94 -59
  91. pygpi/entry.py +5 -6
  92. cocotb-2.0.0b1.dist-info/RECORD +0 -143
  93. {cocotb-2.0.0b1.dist-info → cocotb-2.0.0rc2.dist-info}/WHEEL +0 -0
  94. {cocotb-2.0.0b1.dist-info → cocotb-2.0.0rc2.dist-info}/entry_points.txt +0 -0
  95. {cocotb-2.0.0b1.dist-info → cocotb-2.0.0rc2.dist-info}/top_level.txt +0 -0
@@ -23,8 +23,8 @@ extern "C" {
23
23
  extern COCOTB_EMBED_EXPORT void embed_init_python(void);
24
24
  extern COCOTB_EMBED_EXPORT void embed_sim_cleanup(void);
25
25
  extern COCOTB_EMBED_EXPORT int embed_sim_init(int argc,
26
- char const* const* argv);
27
- extern COCOTB_EMBED_EXPORT void embed_sim_event(const char* msg);
26
+ char const *const *argv);
27
+ extern COCOTB_EMBED_EXPORT void embed_sim_event(const char *msg);
28
28
 
29
29
  #ifdef __cplusplus
30
30
  }
@@ -7,14 +7,15 @@
7
7
  #ifndef COCOTB_GPI_H_
8
8
  #define COCOTB_GPI_H_
9
9
 
10
- /** \file gpi.h
10
+ /** @file gpi.h
11
11
 
12
- Generic Language Interface
13
- ==========================
12
+ Generic Procedural Interface
13
+ ============================
14
14
 
15
- This header file defines a Generic Language Interface into any simulator.
16
- Implementations need to implement the underlying functions in `gpi_priv.h`.
15
+ This header file defines the GPI to interface with any simulator that supports
16
+ VPI, VHPI, or FLI.
17
17
 
18
+ Implementations need to implement the underlying functions in `gpi_priv.h`.
18
19
  The functions are essentially a limited subset of VPI/VHPI/FLI.
19
20
 
20
21
  Implementation-specific notes
@@ -76,62 +77,13 @@ typedef struct GpiIterator *gpi_iterator_hdl;
76
77
  extern "C" {
77
78
  #endif
78
79
 
79
- // Forward declaration for types needed in function signatures
80
+ /** Object discovery method when searching by name. */
80
81
  typedef enum gpi_discovery_e {
81
82
  GPI_AUTO = 0,
82
83
  GPI_NATIVE = 1,
83
84
  } gpi_discovery;
84
85
 
85
- // Functions for controlling/querying the simulation state
86
-
87
- /**
88
- * Return if there is a registered GPI implementation.
89
- * Useful for checking if a simulator is running.
90
- *
91
- * @return `1` if there is a registered GPI implementation, `0` otherwise.
92
- */
93
- GPI_EXPORT bool gpi_has_registered_impl(void);
94
-
95
- /**
96
- * Stop the simulator.
97
- */
98
- GPI_EXPORT void gpi_sim_end(void);
99
-
100
- /**
101
- * Return simulation time as two uints. Unit is the default sim unit.
102
- */
103
- GPI_EXPORT void gpi_get_sim_time(uint32_t *high, uint32_t *low);
104
- GPI_EXPORT void gpi_get_sim_precision(int32_t *precision);
105
-
106
- /**
107
- * Return a string with the running simulator product information.
108
- *
109
- * @return The simulator product string.
110
- */
111
- GPI_EXPORT const char *gpi_get_simulator_product(void);
112
-
113
- /**
114
- * Return a string with the running simulator version.
115
- *
116
- * @return The simulator version string.
117
- */
118
- GPI_EXPORT const char *gpi_get_simulator_version(void);
119
-
120
- // Functions for extracting a gpi_sim_hdl to an object
121
-
122
- /**
123
- * Returns a handle to the root simulation object.
124
- */
125
- GPI_EXPORT gpi_sim_hdl gpi_get_root_handle(const char *name);
126
- GPI_EXPORT gpi_sim_hdl gpi_get_handle_by_name(gpi_sim_hdl parent,
127
- const char *name,
128
- gpi_discovery discovery_method);
129
- GPI_EXPORT gpi_sim_hdl gpi_get_handle_by_index(gpi_sim_hdl parent,
130
- int32_t index);
131
-
132
- /**
133
- * Types that can be passed to the iterator.
134
- */
86
+ /** GPI simulation object types. */
135
87
  // Note these are strikingly similar to the VPI types...
136
88
  typedef enum gpi_objtype_e {
137
89
  GPI_UNKNOWN = 0,
@@ -153,9 +105,7 @@ typedef enum gpi_objtype_e {
153
105
  GPI_LOGIC_ARRAY = 16,
154
106
  } gpi_objtype;
155
107
 
156
- /**
157
- * When iterating, we can chose to either get child objects, drivers or loads.
158
- */
108
+ /** Types of child objects to search for when iterating. */
159
109
  typedef enum gpi_iterator_sel_e {
160
110
  GPI_OBJECTS = 1,
161
111
  GPI_DRIVERS = 2,
@@ -163,6 +113,7 @@ typedef enum gpi_iterator_sel_e {
163
113
  GPI_PACKAGE_SCOPES = 4,
164
114
  } gpi_iterator_sel;
165
115
 
116
+ /** Action to use when setting object value. */
166
117
  typedef enum gpi_set_action_e {
167
118
  GPI_DEPOSIT = 0,
168
119
  GPI_FORCE = 1,
@@ -170,115 +121,311 @@ typedef enum gpi_set_action_e {
170
121
  GPI_NO_DELAY = 3,
171
122
  } gpi_set_action;
172
123
 
124
+ /** Direction of range constraint of an object. */
173
125
  typedef enum gpi_range_dir_e {
174
126
  GPI_RANGE_DOWN = -1,
175
127
  GPI_RANGE_NO_DIR = 0,
176
128
  GPI_RANGE_UP = 1,
177
129
  } gpi_range_dir;
178
130
 
131
+ /** Type of value change to match when registering for callback. */
179
132
  typedef enum gpi_edge_e {
180
133
  GPI_RISING,
181
134
  GPI_FALLING,
182
135
  GPI_VALUE_CHANGE,
183
136
  } gpi_edge;
184
137
 
185
- // Functions for iterating over entries of a handle
138
+ /** @defgroup SimIntf Simulator Control and Interrogation
139
+ * These functions are for controlling and querying
140
+ * simulator state and information.
141
+ * @{
142
+ */
186
143
 
187
- /**
188
- * Return an iterator handle which can then be used in `gpi_next` calls.
144
+ /** Check if there is a registered GPI implementation.
189
145
  *
190
- * Unlike `vpi_iterate` the iterator handle may only be `NULL` if the `type` is
191
- * not supported, If no objects of the requested type are found, an empty
192
- * iterator is returned.
146
+ * Useful for checking if a simulator is running.
147
+ *
148
+ * @return `1` if there is a registered GPI implementation, `0` otherwise.
193
149
  */
194
- GPI_EXPORT gpi_iterator_hdl gpi_iterate(gpi_sim_hdl base,
195
- gpi_iterator_sel type);
150
+ GPI_EXPORT bool gpi_has_registered_impl(void);
151
+
152
+ /** Stop the simulation after control returns to the GPI. */
153
+ GPI_EXPORT void gpi_sim_end(void);
196
154
 
197
- /**
198
- * @return `NULL` when there are no more objects.
155
+ /** Get the simulation time as two 32-bit uints.
156
+ *
157
+ * The value is in default simulation time units,
158
+ * which can be retrieved with @ref gpi_get_sim_precision.
159
+ *
160
+ * @param high Location to return high bits of current simulation time.
161
+ * @param low Location to return low bits of current simulation time.
199
162
  */
200
- GPI_EXPORT gpi_sim_hdl gpi_next(gpi_iterator_hdl iterator);
163
+ GPI_EXPORT void gpi_get_sim_time(uint32_t *high, uint32_t *low);
201
164
 
202
- /**
203
- * @return The number of objects in the collection of the handle.
165
+ /** Get the simulation time precision.
166
+ *
167
+ * @param precision Location to return time precision.
168
+ * The value is scientific notation in terms of seconds.
169
+ * So a value of `-9` is nanosecond precision.
204
170
  */
205
- GPI_EXPORT int gpi_get_num_elems(gpi_sim_hdl gpi_sim_hdl);
171
+ GPI_EXPORT void gpi_get_sim_precision(int32_t *precision);
206
172
 
207
- /**
208
- * @return The left side of the range constraint.
173
+ /** Get the running simulator product information.
174
+ *
175
+ * @return The simulator product string.
209
176
  */
210
- GPI_EXPORT int gpi_get_range_left(gpi_sim_hdl gpi_sim_hdl);
177
+ GPI_EXPORT const char *gpi_get_simulator_product(void);
178
+
179
+ /** Get the running simulator version string.
180
+ *
181
+ * @return The simulator version string.
182
+ */
183
+ GPI_EXPORT const char *gpi_get_simulator_version(void);
184
+
185
+ /** @} */ // End of group SimIntf
186
+
187
+ /** @defgroup ObjQuery Simulation Object Query
188
+ * These functions are for getting handles to simulation objects.
189
+ * @{
190
+ */
191
+
192
+ /** Get a handle to the root simulation object.
193
+ *
194
+ * @param name Name of the root object, or `NULL`.
195
+ * @return Handle to simulation object or `NULL` if not found.
196
+ */
197
+ GPI_EXPORT gpi_sim_hdl gpi_get_root_handle(const char *name);
198
+
199
+ /** Get a handle to a child simulation object by its name.
200
+ *
201
+ * @param parent Parent object handle.
202
+ * @param name Name of the child object.
203
+ * This should not be a path,
204
+ * but only the name of a direct child object.
205
+ * @param discovery_method Object discovery method.
206
+ * @return Handle to simulation object or `NULL` if not found.
207
+ */
208
+ GPI_EXPORT gpi_sim_hdl gpi_get_handle_by_name(gpi_sim_hdl parent,
209
+ const char *name,
210
+ gpi_discovery discovery_method);
211
+
212
+ /** Get a handle to a child simulation object by its index.
213
+ *
214
+ * @param parent Parent indexable object handle.
215
+ * @param index Index of the child object.
216
+ * @return Handle to simulation object or `NULL` if not found.
217
+ */
218
+ GPI_EXPORT gpi_sim_hdl gpi_get_handle_by_index(gpi_sim_hdl parent,
219
+ int32_t index);
211
220
 
212
- /**
213
- * @return The right side of the range constraint.
221
+ /** @} */ // End of group ObjQuery
222
+
223
+ /** @defgroup ObjProps General Object Properties
224
+ * These functions are for getting and setting properties of a simulation
225
+ * object.
226
+ * @{
214
227
  */
228
+
229
+ /** @return The @ref gpi_objtype "type" of the simulation object. */
230
+ GPI_EXPORT gpi_objtype gpi_get_object_type(gpi_sim_hdl gpi_hdl);
231
+
232
+ /** @return Definition name of the simulation object. */
233
+ GPI_EXPORT const char *gpi_get_definition_name(gpi_sim_hdl gpi_hdl);
234
+
235
+ /** @return Definition file of the simulation object. */
236
+ GPI_EXPORT const char *gpi_get_definition_file(gpi_sim_hdl gpi_hdl);
237
+
238
+ /** @return The number of objects in the collection of the handle. */
239
+ GPI_EXPORT int gpi_get_num_elems(gpi_sim_hdl gpi_sim_hdl);
240
+
241
+ /** @return The left side of the range constraint. */
242
+ GPI_EXPORT int gpi_get_range_left(gpi_sim_hdl gpi_sim_hdl);
243
+
244
+ /** @return The right side of the range constraint. */
215
245
  GPI_EXPORT int gpi_get_range_right(gpi_sim_hdl gpi_sim_hdl);
216
246
 
217
- /**
218
- * @return The direction of the range constraint:
247
+ /** @return The direction of the range constraint:
219
248
  * `+1` for ascending, `-1` for descending, `0` for undefined.
220
249
  */
221
250
  GPI_EXPORT gpi_range_dir gpi_get_range_dir(gpi_sim_hdl gpi_sim_hdl);
222
251
 
223
- // Functions for querying the properties of a handle
252
+ /** Determine whether an object value is constant (parameters / generics etc).
253
+ *
254
+ * @return `1` if the object value is constant, `0` otherwise.
255
+ */
256
+ GPI_EXPORT int gpi_is_constant(gpi_sim_hdl gpi_hdl);
224
257
 
225
- /**
226
- * This is all slightly verbose but it saves having to enumerate various value
227
- * types. We only care about a limited subset of values.
258
+ /** Determine whether an object is indexable.
259
+ *
260
+ * @return `1` if the object value is indexable, `0` otherwise.
261
+ */
262
+ GPI_EXPORT int gpi_is_indexable(gpi_sim_hdl gpi_hdl);
263
+
264
+ /** @} */ // End of group ObjProps
265
+
266
+ /** @defgroup SigProps Signal Object Properties
267
+ * These functions are for getting and setting properties of a signal object.
268
+ * @{
269
+ */
270
+
271
+ // Getting properties
272
+
273
+ /** Get signal object value as a binary string.
274
+ * @param gpi_hdl Signal object handle.
275
+ * @return Object value.
228
276
  */
229
277
  GPI_EXPORT const char *gpi_get_signal_value_binstr(gpi_sim_hdl gpi_hdl);
278
+
279
+ /** Get signal object value as a byte array.
280
+ * @param gpi_hdl Signal object handle.
281
+ * @return Object value. Null-terminated byte array.
282
+ */
230
283
  GPI_EXPORT const char *gpi_get_signal_value_str(gpi_sim_hdl gpi_hdl);
231
- GPI_EXPORT double gpi_get_signal_value_real(gpi_sim_hdl gpi_hdl);
232
- GPI_EXPORT long gpi_get_signal_value_long(gpi_sim_hdl gpi_hdl);
233
- GPI_EXPORT const char *gpi_get_signal_name_str(gpi_sim_hdl gpi_hdl);
234
- GPI_EXPORT const char *gpi_get_signal_type_str(gpi_sim_hdl gpi_hdl);
235
284
 
236
- /**
237
- * @return One of the types defined above.
285
+ /** Get signal object value as a real.
286
+ * @param gpi_hdl Signal object handle.
287
+ * @return Object value.
238
288
  */
239
- GPI_EXPORT gpi_objtype gpi_get_object_type(gpi_sim_hdl gpi_hdl);
289
+ GPI_EXPORT double gpi_get_signal_value_real(gpi_sim_hdl gpi_hdl);
240
290
 
241
- /**
242
- * Get information about the definition of a handle.
291
+ /** Get signal object value as a long.
292
+ * @param gpi_hdl Signal object handle.
293
+ * @return Object value.
243
294
  */
244
- GPI_EXPORT const char *gpi_get_definition_name(gpi_sim_hdl gpi_hdl);
245
- GPI_EXPORT const char *gpi_get_definition_file(gpi_sim_hdl gpi_hdl);
295
+ GPI_EXPORT long gpi_get_signal_value_long(gpi_sim_hdl gpi_hdl);
246
296
 
247
- /**
248
- * Determine whether an object value is constant (parameters / generics etc).
297
+ /** Get signal object name.
298
+ * @param gpi_hdl Signal object handle.
299
+ * @return Object name.
249
300
  */
250
- GPI_EXPORT int gpi_is_constant(gpi_sim_hdl gpi_hdl);
301
+ GPI_EXPORT const char *gpi_get_signal_name_str(gpi_sim_hdl gpi_hdl);
251
302
 
252
- /**
253
- * Determine whether an object is indexable.
303
+ /** Get signal object type as a string.
304
+ * @param gpi_hdl Signal object handle.
305
+ * @return Object type as a string.
254
306
  */
255
- GPI_EXPORT int gpi_is_indexable(gpi_sim_hdl gpi_hdl);
307
+ GPI_EXPORT const char *gpi_get_signal_type_str(gpi_sim_hdl gpi_hdl);
256
308
 
257
- // Functions for setting the properties of a handle
309
+ // Setting properties
258
310
 
311
+ /** Set signal object value with a real.
312
+ * @param gpi_hdl Signal object handle.
313
+ * @param value Object value.
314
+ * @param action Action to use.
315
+ */
259
316
  GPI_EXPORT void gpi_set_signal_value_real(gpi_sim_hdl gpi_hdl, double value,
260
317
  gpi_set_action action);
318
+
319
+ /** Set signal object value with an int.
320
+ * @param gpi_hdl Signal object handle.
321
+ * @param value Object value.
322
+ * @param action Action to use.
323
+ */
261
324
  GPI_EXPORT void gpi_set_signal_value_int(gpi_sim_hdl gpi_hdl, int32_t value,
262
325
  gpi_set_action action);
263
- GPI_EXPORT void gpi_set_signal_value_binstr(
264
- gpi_sim_hdl gpi_hdl, const char *str,
265
- gpi_set_action action); // String of binary char(s) [1, 0, x, z]
266
- GPI_EXPORT void gpi_set_signal_value_str(
267
- gpi_sim_hdl gpi_hdl, const char *str,
268
- gpi_set_action action); // String of ASCII char(s)
269
326
 
270
- // The callback registering functions
327
+ /** Set signal object value with a binary string.
328
+ * @param gpi_hdl Signal object handle.
329
+ * @param str Object value. Null-terminated string of binary characters
330
+ * in [`1`, `0`, `x`, `z`].
331
+ * @param action Action to use.
332
+ */
333
+ GPI_EXPORT void gpi_set_signal_value_binstr(gpi_sim_hdl gpi_hdl,
334
+ const char *str,
335
+ gpi_set_action action);
336
+
337
+ /** Set signal object value with a byte array.
338
+ * @param gpi_hdl Signal object handle.
339
+ * @param str Object value. Null-terminated byte array.
340
+ * @param action Action to use.
341
+ */
342
+ GPI_EXPORT void gpi_set_signal_value_str(gpi_sim_hdl gpi_hdl, const char *str,
343
+ gpi_set_action action);
344
+
345
+ /** @} */ // End of group SigProps
346
+
347
+ /** @defgroup HandleIteration Simulation Object Iteration
348
+ * These functions are for iterating over simulation object handles
349
+ * to discover child objects.
350
+ * @{
351
+ */
352
+
353
+ /** Start iteration on a simulation object.
354
+ *
355
+ * Unlike `vpi_iterate()` the iterator handle may only be `NULL` if the `type`
356
+ * is not supported. If no objects of the requested type are found, an empty
357
+ * iterator is returned.
358
+ * @param base Simulation object to iterate over.
359
+ * @param type Iteration type.
360
+ * @return An iterator handle which can then be used with @ref gpi_next.
361
+ */
362
+ GPI_EXPORT gpi_iterator_hdl gpi_iterate(gpi_sim_hdl base,
363
+ gpi_iterator_sel type);
271
364
 
365
+ /** Get next object in iteration.
366
+ *
367
+ * @param iterator Iterator handle.
368
+ * @return Object handle, or `NULL` when there are no more objects.
369
+ */
370
+ GPI_EXPORT gpi_sim_hdl gpi_next(gpi_iterator_hdl iterator);
371
+
372
+ /** @} */ // End of group HandleIteration
373
+
374
+ /** @defgroup SimCallbacks Simulation Callbacks
375
+ * These functions are for registering and controlling callbacks.
376
+ * @{
377
+ */
378
+
379
+ /** Register a timed callback.
380
+ *
381
+ * @param gpi_function Callback function pointer.
382
+ * @param gpi_cb_data Pointer to user data to be passed to callback function.
383
+ * @param time Time delay in simulation time units.
384
+ * @return Handle to callback object.
385
+ */
272
386
  GPI_EXPORT gpi_cb_hdl gpi_register_timed_callback(int (*gpi_function)(void *),
273
387
  void *gpi_cb_data,
274
388
  uint64_t time);
389
+
390
+ /** Register a value change callback.
391
+ *
392
+ * @param gpi_function Callback function pointer.
393
+ * @param gpi_cb_data Pointer to user data to be passed to callback function.
394
+ * @param gpi_hdl Simulation object to monitor for value change.
395
+ * @param edge Type of value change to monitor for.
396
+ * @return Handle to callback object.
397
+ */
275
398
  GPI_EXPORT gpi_cb_hdl gpi_register_value_change_callback(
276
399
  int (*gpi_function)(void *), void *gpi_cb_data, gpi_sim_hdl gpi_hdl,
277
400
  gpi_edge edge);
401
+
402
+ /** Register a readonly simulation phase callback.
403
+ *
404
+ * Callback will be called when simulation next enters the readonly phase.
405
+ * @param gpi_function Callback function pointer.
406
+ * @param gpi_cb_data Pointer to user data to be passed to callback function.
407
+ * @return Handle to callback object.
408
+ */
278
409
  GPI_EXPORT gpi_cb_hdl
279
410
  gpi_register_readonly_callback(int (*gpi_function)(void *), void *gpi_cb_data);
411
+
412
+ /** Register a next timestep simulation phase callback.
413
+ *
414
+ * Callback will be called when simulation next enters the next timestep.
415
+ * @param gpi_function Callback function pointer.
416
+ * @param gpi_cb_data Pointer to user data to be passed to callback function.
417
+ * @return Handle to callback object.
418
+ */
280
419
  GPI_EXPORT gpi_cb_hdl
281
420
  gpi_register_nexttime_callback(int (*gpi_function)(void *), void *gpi_cb_data);
421
+
422
+ /** Register a readwrite simulation phase callback.
423
+ *
424
+ * Callback will be called when simulation next enters the readwrite phase.
425
+ * @param gpi_function Callback function pointer.
426
+ * @param gpi_cb_data Pointer to user data to be passed to callback function.
427
+ * @return Handle to callback object.
428
+ */
282
429
  GPI_EXPORT gpi_cb_hdl
283
430
  gpi_register_readwrite_callback(int (*gpi_function)(void *), void *gpi_cb_data);
284
431
 
@@ -303,6 +450,8 @@ GPI_EXPORT int gpi_remove_cb(gpi_cb_hdl cb_hdl);
303
450
  GPI_EXPORT void gpi_get_cb_info(gpi_cb_hdl cb_hdl, int (**cb_func)(void *),
304
451
  void **cb_data);
305
452
 
453
+ /** @} */ // End of group SimCallbacks
454
+
306
455
  #ifdef __cplusplus
307
456
  }
308
457
  #endif
@@ -19,12 +19,12 @@
19
19
  extern "C" {
20
20
  #endif
21
21
 
22
- PYGPILOG_EXPORT void py_gpi_logger_initialize(PyObject* handler,
23
- PyObject* get_logger);
22
+ PYGPILOG_EXPORT void py_gpi_logger_initialize(PyObject *handler,
23
+ PyObject *get_logger);
24
24
 
25
25
  PYGPILOG_EXPORT void py_gpi_logger_finalize();
26
26
 
27
- extern PYGPILOG_EXPORT PyObject* pEventFn; // This is gross but I don't care
27
+ extern PYGPILOG_EXPORT PyObject *pEventFn; // This is gross but I don't care
28
28
 
29
29
  #ifdef __cplusplus
30
30
  }
@@ -25,7 +25,7 @@ using verilated_trace_t = VerilatedFstC;
25
25
  #include <verilated_vcd_c.h>
26
26
  using verilated_trace_t = VerilatedVcdC;
27
27
  #endif
28
- static verilated_trace_t* tfp;
28
+ static verilated_trace_t *tfp;
29
29
  #endif
30
30
 
31
31
  static vluint64_t main_time = 0; // Current simulation time
@@ -71,13 +71,14 @@ void wrap_up() {
71
71
  #endif
72
72
  }
73
73
 
74
- int main(int argc, char** argv) {
74
+ int main(int argc, char **argv) {
75
75
  #if VM_TRACE_FST
76
- const char* traceFile = "dump.fst";
76
+ const char *traceFile = "dump.fst";
77
77
  #else
78
- const char* traceFile = "dump.vcd";
78
+ const char *traceFile = "dump.vcd";
79
79
  #endif
80
80
  bool traceOn = false;
81
+ bool traceFlush = false;
81
82
 
82
83
  for (int i = 1; i < argc; i++) {
83
84
  std::string arg = std::string(argv[i]);
@@ -90,6 +91,8 @@ int main(int argc, char** argv) {
90
91
  "support\n");
91
92
  return -1;
92
93
  #endif
94
+ } else if (arg == "--trace-flush") {
95
+ traceFlush = true;
93
96
  } else if (arg == "--trace-file") {
94
97
  if (++i < argc) {
95
98
  traceFile = argv[i];
@@ -98,16 +101,18 @@ int main(int argc, char** argv) {
98
101
  return -1;
99
102
  }
100
103
  } else if (arg == "--help") {
101
- fprintf(stderr,
102
- "usage: %s [--trace] [--trace-file TRACEFILE]\n"
103
- "\n"
104
- "Cocotb + Verilator sim\n"
105
- "\n"
106
- "options:\n"
107
- " --trace Enables tracing (VCD or FST)\n"
108
- " --trace-file Specifies the trace file name (%s by "
109
- "default)\n",
110
- basename(argv[0]), traceFile);
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);
111
116
  return 0;
112
117
  }
113
118
  }
@@ -133,7 +138,7 @@ int main(int argc, char** argv) {
133
138
  #endif
134
139
 
135
140
  vlog_startup_routines_bootstrap();
136
- Verilated::addExitCb([](void*) { wrap_up(); }, nullptr);
141
+ Verilated::addExitCb([](void *) { wrap_up(); }, nullptr);
137
142
  VerilatedVpi::callCbs(cbStartOfSimulation);
138
143
  settle_value_callbacks();
139
144
 
@@ -162,6 +167,9 @@ int main(int argc, char** argv) {
162
167
  #if VM_TRACE
163
168
  if (tfp) {
164
169
  tfp->dump(main_time);
170
+ if (traceFlush) {
171
+ tfp->flush();
172
+ }
165
173
  }
166
174
  #endif
167
175
  // cocotb controls the clock inputs using cbAfterDelay so