SV DPI; accessing a task within a module in the C code

In reply to jolup:

Hi Dave,
Tried a cheap trick

I wrapped the c function in a sv task that simply calls it.
Now the import / export are at the same level of context, which seems to be what you said above (ok I admit the need to read a certain LRM).

… and now get this:


# ** Fatal: (vsim-3757) The DPI exported task 'axi_rd' must be called from a context imported *task*. A call from a context imported *function* was detected. The caller's scope is xadc_top_tb.bus_mstr_c.
# The nearest DPI import tf up the call chain is at line 268 of file ./repo/rfsoc_test/sim/axi_test/axi4lite_mst_c_skel.v
#    Time: 1608 ns  Iteration: 3  Process: /xadc_top_tb/#ALWAYS#348 File: ./repo/rfsoc_test/sim/axi_test/axi4lite_mst_c_skel.v

Then I set the task up as


   import "DPI-C" context task read_register();

and it crashes when I run (note not load the design). Probably the call.

Ok, I’ll take some time and review your code, thanks for stimulating some thought about it.
Jerry