It is possible for a disable statement to disable a block that is currently executing a mixed language call chain. When a DPI import task or function is disabled, the C code is required to follow a simple disable protocol. The protocol gives the C code the opportunity to perform any necessary resource cleanup, such as closing open file handles, closing open VPI handles, or freeing heap memory.
The protocol is composed of the following items:
a) When an exported task returns due to a disable, it must return a value of 1. Otherwise, it must return 0.
b) When an imported task returns due to a disable, it must return a value of 1. Otherwise, it must return 0.
c) Before an imported function returns due to a disable, it must call the API function svAckDisabledState().
d) Once an imported task or function enters the disabled state, it is illegal for the current function invocation to make any further calls to exported tasks or functions.
Include Files
Applications that use the DPI with C code usually need this main include file. The include file svdpi.h defines the types for canonical representation of 2-state (bit) and 4-state (logic) values and passing references to SystemVerilog data objects. The file also provides function headers and defines a number of helper macros and constants. The content of svdpi.h does not depend on any particular implementation; all simulators shall use the same file.