Skip to main content

Module dpi_task

Module dpi_task 

Source
Expand description

Blocking DPI import-task calls (LRM 1800-2023 35.5.3, 35.7, 35.9).

A TaskCall runs one C import-task call on a Fiber. When that C code calls an exported SV task which consumes time, the export’s thunk calls sv_rt_dpi_export_task_call, which parks the fiber and hands the owner a ExportRequest: “run export export with the argument block at args”. The owner (the calling process’s kernel) spawns the export’s task as a child process, copies args into its frame, waits for it, copies the output/inout formals back into args, then polls again; the thunk returns and the C code continues. TaskCall::poll reports CallPoll::Finished with the import’s int return (35.9: 0, or 1 when the call was disabled) once the C function returns.

args points into the parked fiber’s own stack, so it stays valid exactly as long as the request is outstanding.

Structs§

ExportRequest
What a parked call is asking the owner to run.
TaskCall
One import-task call in flight.

Enums§

CallPoll
The outcome of one TaskCall::poll.

Constants§

EXPORT_CALL_DISABLED
Status sv_rt_dpi_export_task_call returns when the call was disabled.
EXPORT_CALL_NOT_ON_FIBER
Status it returns when it ran off a fiber (a task export called from an import function, or from C code outside any import call): illegal, LRM 35.5.3 – only an import task may call a task that consumes time.
MIRROR_ACKED
See MIRROR_OFF.
MIRROR_DISABLED
See MIRROR_OFF.
MIRROR_OFF
[MIRROR] values: no disable, disabled (35.9), disabled and acknowledged by svAckDisabledState().

Functions§

ack_disabled_state
svAckDisabledState() (35.9) for the call running on this thread.
active_call_disabled
Whether the import-task call running on this thread is in the disabled state (35.9): what svIsDisabledState() reports.
set_disabled_flag⚠
Mirrors the disabled state of the running call into flag from now on.
sv_rt_dpi_export_task_call⚠
int sv_rt_dpi_export_task_call(uint32_t export, void* args, void* handle): the call an export thunk of a task that consumes time makes. Blocks the calling import task until the owner has run the export; returns 0, or EXPORT_CALL_DISABLED, or EXPORT_CALL_NOT_ON_FIBER.
sv_rt_dpi_export_task_error⚠
void sv_rt_dpi_export_task_error(const char* name): the runtime error of a call of the timed export task name from outside an import task (LRM 35.5.3: only an import task may wait, an import function may not). Aborts the simulation.
sv_rt_dpi_fn_disable_index⚠
int64_t sv_rt_dpi_fn_disable_index(const char* labels): after a statement that called a subroutine. labels are the blocks enclosing the statement, separated by \n. Returns the index of the one the call disabled (the statement then leaves it), or -1. A C call that was disabled and returned without svAckDisabledState() aborts (35.9).
sv_rt_dpi_fn_disable_set⚠
void sv_rt_dpi_fn_disable_set(const char* label): disable label; executed in a function while the block is not one of its own (LRM 9.6.2): the function goes on to its end and the call site that reaches the block leaves it (sv_rt_dpi_fn_disable_index). Inside an import-function call this is the disabled state of 35.9 for the C code.
sv_rt_dpi_fn_scope
void sv_rt_dpi_fn_scope(int on): brackets the C call of an import function in a design where an exported function disables a block (35.9: the C code then sees the disabled state).
sv_rt_dpi_task_scope⚠
void sv_rt_dpi_task_scope(int on, const char* name): brackets the C call of an import task (LRM 35.5.3). Only inside such a call may C code call an export task which consumes time; the call site of an import function does not set it, so the same call there is the runtime error of EXPORT_CALL_NOT_ON_FIBER. name is the import task’s SV name (null when on is 0), which disable <task>; of another process matches (35.9).