diff --git a/src/Convert/Struct.hs b/src/Convert/Struct.hs index 2ff3cba..990c764 100644 --- a/src/Convert/Struct.hs +++ b/src/Convert/Struct.hs @@ -341,6 +341,15 @@ convertAsgn structs types (lhs, expr) = isStruct (Struct{}) = True isStruct _ = False + convertExpr (Struct packing fields (r : rs)) (Pattern items) = + if all null keys + then convertExpr (structTf (r : rs)) (Concat vals) + else Repeat (rangeSize r) [subExpr'] + where + (keys, vals) = unzip items + subExpr = Pattern items + structTf = Struct packing fields + subExpr' = convertExpr (structTf rs) subExpr convertExpr (Struct packing fields (r : rs)) subExpr = Repeat (rangeSize r) [subExpr'] where diff --git a/test/basic/struct_array_inline.sv b/test/basic/struct_array_inline.sv new file mode 100644 index 0000000..aec5d94 --- /dev/null +++ b/test/basic/struct_array_inline.sv @@ -0,0 +1,19 @@ +module top; + typedef struct packed { + bit a, b; + } T; + + localparam T FOO [4] = '{ + '{ 0, 0 }, + '{ 0, 1 }, + '{ 1, 0 }, + '{ 1, 1 } + }; + + initial begin + $display(FOO[0].a); + $display(FOO[0].b); + $display(FOO[2].a); + $display(FOO[2].b); + end +endmodule diff --git a/test/basic/struct_array_inline.v b/test/basic/struct_array_inline.v new file mode 100644 index 0000000..6592042 --- /dev/null +++ b/test/basic/struct_array_inline.v @@ -0,0 +1,8 @@ +module top; + initial begin + $display(1'b0); + $display(1'b0); + $display(1'b1); + $display(1'b0); + end +endmodule