Reputation: 2868
I have a struct declared inside a module like this:
module myModule;
struct {
logic a;
logic b;
logic [A - 1:0] c[0:B - 1];
logic [C - 1:0] d;
} [D - 1:0] e [0:E - 1][0:F - 1];
endmodule
I want to use c
like an unpacked array, but Verilog does not allow this. It throws an error on the line where c
is defined:
Unsupported: Unpacked array in packed struct/union
Is there a way around this?
Upvotes: 1
Views: 2858
Reputation: 42698
In order to have a packed array, all element must be packed. So either make the struct packed:
struct packed {
logic a;
logic b;
logic [A - 1:0] [0:B - 1] c;
logic [C - 1:0] d;
} [D - 1:0] e [0:E - 1][0:F - 1];
or make the e array all unpacked
struct {
logic a;
logic b;
logic [A - 1:0] [0:B - 1] c;
logic [C - 1:0] d;
} e [0:E - 1][0:F - 1][D - 1:0];
BTW, it is highly recommended that you use a typedef
for your struct instead of having an anonymous struct type.
Upvotes: 4