svPutBitArrElemVecVal error

Hi all, i’m trying to get array from cpp code to my sv code and get the error:

xmsim: *F,SIGUSR: Unix Signal SIGSEGV raised from user application code. Stack trace information is captured in file sigusrdump.out.

sv code:

    
    function void nmu_sv_get_l_y_msb_array_by_index(int index);
	    	int result[];
	    	result = new [100];
		nmu_cpp_get_l_y_msb_array_by_index(index,p_nmu_simulator,result);
    endfunction : nmu_sv_get_l_y_msb_array_by_index


import from sv:


import "DPI-C" context function void nmu_cpp_get_l_y_msb_array_by_index(int index,chandle handle, output int result[]);

cpp code:


  void nmu_cpp_get_l_y_msb_array_by_index(int index,void* handle ,svOpenArrayHandle result){
	  myclass* p_cpp_nmu = static_cast<myclass *>(handle);
	  uint32_t myArray[2]= {8,10};
	  svPutBitArrElemVecVal(result,myArray, 1); // fail in run time in this line

  }

In reply to eranv:

Your issue is the declaration of ‘result’ in the SV code. You are declaring ‘result’ as a dynamic array, where the DPI is expecting a static array. These data types are different and not compatible.

You want:


function void nmu_sv_get_l_y_msb_array_by_index(int index);
  int result[100];
  nmu_cpp_get_l_y_msb_array_by_index(index,p_nmu_simulator,result);
endfunction : nmu_sv_get_l_y_msb_array_by_index

In reply to cgales:

thanks for the answer but still the same isuue.

i also tested the options:


import "DPI-C" context function void nmu_cpp_get_l_y_msb_array_by_index(int index,chandle handle, output int result[]);


import "DPI-C" context function void nmu_cpp_get_l_y_msb_array_by_index(int index,chandle handle, output int result[100]);

In reply to eranv:

Here is a complete example that works:

test.sv


import "DPI-C" function void nmu_cpp_get_l_y_msb_array_by_index(int index,chandle handle, output int result[]);

module test();

  function void nmu_sv_get_l_y_msb_array_by_index(int index);
    int result[100];
    nmu_cpp_get_l_y_msb_array_by_index(index,null,result);
  endfunction : nmu_sv_get_l_y_msb_array_by_index

  initial begin
    nmu_sv_get_l_y_msb_array_by_index(1);
  end
endmodule

test.cpp

#include "svdpi.h"
extern "C" void nmu_cpp_get_l_y_msb_array_by_index(int index,void* handle,const svOpenArrayHandle result);

void nmu_cpp_get_l_y_msb_array_by_index(int index,void* handle ,const svOpenArrayHandle result){
  //myclass* p_cpp_nmu = static_cast<myclass *>(handle);
  uint32_t myArray[2]= {8,10};
  svPutBitArrElemVecVal(result,myArray, 1); 
}

In reply to cgales:

sorry, but your full example doesn’t work for me, and fails on the same error.

In reply to eranv:

You should contact your tool vendor for additional assistance.