简体   繁体   中英

DPI-C export of a task defined inside a SystemVerilog class

Would it be possible to export to C a task defined inside a SystemVerilog class as the following?

class packet_bfm_t;
    int id = 0;

    export "DPI-C" task send; // Is this possible and legal to call from C code?

    function new (int my_id = 0);
      id = my_id;
    endfunction : new

    task send (int data);
      #1ns;
      $display ("data = %h", data);
    endtask : send

endclass : packet_bfm_t

The DPI does not alow exporting a class method. Same problem as calling a C++ class method from C. You would have to define and export a non-class task wrapper that uses an Id or whatever is needed to look up the class object in a table. The you can call the method on that class object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM