I was attempting to write a struct compatible with DPI-C for Verilog.
The struct is as follows:
/* Microcontroller FW config */
struct ucode_image_config {
uintptr_t src_addr;
uint32_t size;
};
In DPI-C the code is as follows:
/* Microcontroller FW configuration */
typedef struct {
int unsigned src_addr;
int unsigned size;
} ucode_image_config_t;
I assume this is not a 1-1 equivalence because of the variable size of uintptr_t, so I'm wondering if there's a better solution.
SystemVerilog does not have pointers, so there is no compatible pointer data type between C and SystemVerilog. It does a an opaque pointer called a
chandlewhich allows you to pass a C pointer from one DPI-C routine to another. But there is no way to reference anything using the chandle from the SystemVerilog side without importing another DPI-C access routine.The DPI has the concept of Open arrays (Section 35.5.6.1 in the IEEE 1800-2017 SystemVerilog LRM. You should take a look at that and probably ask another question giving details on the intent of what you are trying to accomplish.