In reply to zz8318:
That’s better, but certainly not minimal or complete. This worked for me:
package my_common_pkg;
typedef struct {
string name;
int addr;
} reg_t;
reg_t reg_arr[$];
import "DPI-C" context function void get_all_reg();
export "DPI-C" function exported_sv_function;
function void exported_sv_function(input reg_t ele);
reg_arr.push_back(ele);
endfunction : exported_sv_function
endpackage: my_common_pkg
package my_test_pkg;
import my_common_pkg::*;
class A;
task run;
get_all_reg;
endtask
endclass
endpackage : my_test_pkg
module top;
import my_test_pkg::*;
A h=new;
initial h.run;
endmodule
Note the changes I had to make get the C++ code to compile
extern "C" {
void exported_sv_function(const reg_t*);
void get_all_reg() {
reg_t reg_element;
// get infomation
exported_SystemVerilog_function(®_element);
}
} // extern "C"