Does any one has an example on passing array of structures from C to SystemVerilog using DPI?
In reply to superUVM:
SystemVerilog code:
module top;
typedef struct {int A; byte B; int C; } my_struct_t;
typedef my_struct_t my_struct_array_t[2];
import "DPI-C" function void pass_struct(output my_struct_array_t a);
my_struct_array_t SA;
initial begin
pass_struct(SA);
$display("%p",SA);
end
endmodule // top
C code:
#include "dpicstruct.h"
void pass_struct( my_struct_t* a) {
int i=0;
a[0].A = i++;
a[0].B = i++;
a[0].C = i++;
a[1].A = i++;
a[1].B = i++;
a[1].C = i++;
}
dpicstruct.h (generated automatically)
/ * Copyright 2002-2019 Mentor Graphics Corporation.
*
* Note:
* This file is automatically generated.
* Please do not edit this file - you will lose your edits.
*
* Settings when this file was generated:
* PLATFORM = 'linux_x86_64'
*/
#include "svdpi.h"
typedef struct {
int A;
char B;
int C;
} my_struct_t;
void
pass_struct(
my_struct_t* a);
Displays:
# '{'{A:0, B:1, C:2}, '{A:3, B:4, C:5}}
In reply to dave_59:
Hi Dave,
Thanks for example. When I compile, I get this error, “unsupported datatype in formal argument” and referring to argument my_struct_array_t.
Thanks.
In reply to superUVM:
An “unsupported” message usually means the tool reconizes the construct, but has not implemented it yet. Please contact your tool vendor.