Search code examples
system-verilogverificationsystem-verilog-dpi

Dynamic arrays in Struct in DPI-C


I want to use a dynamic array inside a struct which i pass onto C using DPI.

How do i implement it on C-side. I tried using svOpenArrayHandle inside struct but still not working. Example:

Struct a {
    int x;
    int y[];
}

Solution

  • According to LRM section 35.5.6 Types of formal arguments, structs may only contain the types listed in that section. Dynamically sized arrays is not one of them.

    It would be much easy to pass an array of int, then unpack into a legitimate C struct.