Commit 17e17ebd by Zachary Snow

fix struct array pattern conversion (resolves #60)

parent cf4c2a54
......@@ -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
......
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
module top;
initial begin
$display(1'b0);
$display(1'b0);
$display(1'b1);
$display(1'b0);
end
endmodule
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment