<- Click here to Toggle

Home » Resources » SystemVerilog Assertion API » Dynamic Information

SystemVerilog Assertion API - Dynamic Information

This section defines how to place assertion system and assertion callbacks.

Placing assertion system callbacks

Use vpi_register_cb() , setting the cb_rtn element to the function to be invoked and the reason element of the s_cb_data structure to one of the following values, to place an assertion system callback.

cbAssertionSysInitialized Occurs after the system has initialized. No assertion-specific actions can be performed until this callback completes.

cbAssertionSysStart the assertion system has become active and starts processing assertion attempts. This always occur after cbAssertionSysInitialized.

cbAssertionSysStop the assertion system has been temporarily suspended. While stopped no assertion attempts are processed and no assertion-related callbacks occur.

cbAssertionSysEnd Occurs when all assertions have completed and no new attempts shall start.

Once this callback occurs no more assertion-related callbacks shall occur and assertion-related actions shall have no further effect.

cbAssertionSysResetOccurs when the assertion system is reset, e.g., due to a system control action.

Placing assertions callback

Use vpi_register_assertion_cb() to place an assertion callback; the prototype is:

/* typedef for vpi_register_assertion_cb callback function */
typedef PLI_INT32 (vpi_assertion_callback_func)(
PLI_INT32 reason, /* callback reason */
p_vpi_time cb_time, /* callback time */
vpiHandle assertion, /* handle to assertion */
p_vpi_attempt_info info, /* attempt related information */
PLI_BYTE8 *user_data /* user data entered upon registration */
);
vpiHandle vpi_register_assertion_cb(
vpiHandle assertion, /* handle to assertion */
PLI_INT32 reason, /* reason for which callbacks needed */
vpi_assertion_callback_func *cb_rtn,
PLI_BYTE8 *user_data /* user data to be supplied to cb */
);

where reason is any of the following.

cbAssertionStart: An assertion attempt has started. For most assertions one attempt starts each and every clock tick.

cbAssertionSuccess: when an assertion attempt reaches a success state.

cbAssertionFailure: when an assertion attempt fails to reach a success state.

cbAssertionStepSuccess: progress one step an attempt. By default, step callbacks are not enabled on any assertions; they are enabled on a per-assertion/per-attempt basis , rather than on a per-assertion basis.

cbAssertionKill: when an attempt is killed (e.g., as a result of a control action).

Placing such a callback on one assertion does not cause the callback to trigger on an event occurring on a different assertion. If the callback is successfully placed, a handle to the callback is returned.

This handle can be used to remove the callback via vpi_remove_cb() . If there were errors on placing the callback, a NULL handle is returned.

The callback function shall be supplied the following arguments:

The t_vpi_attempt_info attempt information structure contains details relevant to the specific event that occurred.

On disable, enable, reset and kill callbacks, the returned p_vpi_attempt_info info pointer is NULL and no attempt information is available.

On start and success callbacks, only the attemptStartTime field is valid.

On a step callback, the detail describes the set of expressions matched in satisfying a step along the assertion, along with the corresponding source references. In addition, the step also identifies the source and destination “states” needed to uniquely identify the path being taken through the assertion.