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

In reply to dave_59:

Hi Dave,
Poking around for “DPI books” under the SV forum I actually found that earlier (Easy modelsim DPI book - SystemVerilog - Verification Academy) and was going to parse it, thanks for the guidance.

You didn’t say how you imported the C tasks that call the exported SystemVerilog tasks.

So I showed my small c test read function. This is called in the top level tb.
In the instantiated axi4lite module, I used “import “DPI-C” function void read_register();” at the top level (as the read_register c fcn is called therein).

If you do the import from within the same BFM model as the export, the C code gets the context to find the exported tasks.
I think that’s what I am getting at. The read_register() c code is used at the top level (xadc_top_tb) and that c code calls the axi_rd task. That task is one level down in the hierarchy.
From the error “…‘axi_rd’ could not be found within calling context ‘xadc_top_tb’”, I suspect that the the top level tb cannot find the axi_rd task, called by read_register() in the top level testbench as it’s not in the namespace of the top level testbench.

Ok so with that said, I am going to look over your model and digest it.

Do you suggest I reference IEEE 1800? Would it clarify this import - export usage?

If you want the code to look over, I can post it - it’s not really proprietary.
Best, thanks,
Jerry