In reply to dave_59:
Hi Dave,
I was not able to solve this problem in my side. And I tried another way to implement it but failed at below error. I am not sure if I use the dpi correctly or not. Could you please take a look ?
I don’t use ‘export’ function and what I tried is shown below.
/proj/common/my_globals.svh:
typedef struct {
string name;
uint32 addr;
} reg_t;
import "DPI-C" context function void get_all_reg2(output reg_t arr[]);
and here is my c file: (proj/common/get_all_reg.cpp)
[c]
struct reg_t{
const char* name;
uint32 addr;
};
extern “C” {
void get_all_reg2(svOpenArrayHandle arr) {
reg_t reg_element;
reg_t *reg_array;
reg_array = (reg_t*)svGetArrayPtr(arr);
while(...) {
...
reg_array[idx] = reg_element;
idx++;
}
}
} // extern “C”
[/c]
and then in my test file (/proj/test/my_test2.svh), I will invoke the get_all_reg2() function as shown below.
class my_test2 extends uvm_test;
...
reg_t m_reg_array[1024]; // shall we need to identify 1024 ?
...
task run_phase(uvm_phase phase);
super.run_phase(phase);
phase.raise_objection(this, "raise objection");
get_all_reg2(m_reg_array);
...
endtask
endclass
and I met the segmentation fault…