I have a very complicated packed struct, C
, with nested packed structs, A
and B
, in SystemVerilog:
typedef struct packed {
logic [31:0] ex1;
logic [3:0] ex2;
} A;
typedef struct packed {
logic ex3;
A [7:0] ex4;
} B;
typedef struct packed {
logic ex5
A [5:0]ex6;
B ex7;
} C;
I need to send this struct via a DPI-C call and then access the different elements within the struct. Unfortunately the actual struct I'm working with is much more complicated than above and I'd like to achieve this without bit indexing into the array for every element. I have seen this post but my struct is so nested and complicated that just indexing would be largely infeasible.
So in the testbench.sv file, I have:
import "DPI-C" function void passC(input C c);
And then in the my-dpi.cc file, I want a way to simply save the svLogicVecVal into a C++ equivalent struct
struct A {
svLogicVecVal ex1; \\[31:0]
svLogicVecVal ex2; \\[3:0]
};
struct B {
svBit ex3;
A ex4[8];
};
struct C {
svBit ex5
A ex6[6];
B ex7;
};
extern "C" function void passC(svLogicVecVal* c){
C = c;
}
I know this is an extremely complicated issue so I would appreciate any advice on the best way to go about it. Unfortunately, I cannot change the SystemVerilog struct itself. I could try to convert it to C compatible types in SystemVerilog but I'd prefer to just go whatever the cleanest solution is. Thanks in advance.