mirror of https://github.com/zachjs/sv2v.git
fix struct array pattern conversion (resolves #60)
This commit is contained in:
parent
cf4c2a5491
commit
17e17ebd7f
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
module top;
|
||||
initial begin
|
||||
$display(1'b0);
|
||||
$display(1'b0);
|
||||
$display(1'b1);
|
||||
$display(1'b0);
|
||||
end
|
||||
endmodule
|
||||
Loading…
Reference in New Issue