SV DPI Scope

SV的DPI(Directed Program Interface)提供了SV与其他语言(C/C++)通信的桥梁。本文不会讲解DPI的基础知识,只针对Scope这一概念进行解释,因为这是在DPI编程中常遇到的,也是比较难debug的问题。

对于SV呼叫C,不会存在Scope不对找不到对应的C function的问题。但是C呼叫SV,则会碰到这种问题。VCS仿真器会给出如下Log

Error-[DPI-DXFNF] DPI export function not found

The DPI export function/task ‘sv_task’ called from a user/external  C/C++/DPI-C code originated from import DPI function ‘c_main’ at file ‘test.sv'(line 3) is not defined or visible.

Please check the called DPI export function/task is defined in the mentioned which invokes that DPI export function/task is made with ‘context’. Another work-around is using svGetScopeFromName/svSetScope to explicitly set the scope to the module which contains the definition of the DPI export function/task.

Continue reading “SV DPI Scope”