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§
- Export
Request - What a parked call is asking the owner to run.
- Task
Call - One import-task call in flight.
Enums§
- Call
Poll - The outcome of one
TaskCall::poll.
Constants§
- EXPORT_
CALL_ DISABLED - Status
sv_rt_dpi_export_task_callreturns 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 bysvAckDisabledState().
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
flagfrom 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, orEXPORT_CALL_DISABLED, orEXPORT_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 tasknamefrom 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.labelsare 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 withoutsvAckDisabledState()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 ofEXPORT_CALL_NOT_ON_FIBER.nameis the import task’s SV name (null whenonis 0), whichdisable <task>;of another process matches (35.9).