mirror of https://github.com/zachjs/sv2v.git
support structs of integers
This commit is contained in:
parent
ddaa7ff6c6
commit
13b62fd81e
|
|
@ -17,6 +17,20 @@ convert =
|
||||||
traverseTypes $ traverseNestedTypes convertType
|
traverseTypes $ traverseNestedTypes convertType
|
||||||
|
|
||||||
convertType :: Type -> Type
|
convertType :: Type -> Type
|
||||||
|
convertType (Struct pk fields rs) =
|
||||||
|
Struct pk fields' rs
|
||||||
|
where fields' = convertStructFields fields
|
||||||
|
convertType (Union pk fields rs) =
|
||||||
|
Union pk fields' rs
|
||||||
|
where fields' = convertStructFields fields
|
||||||
convertType (IntegerAtom kw sg) = elaborateIntegerAtom $ IntegerAtom kw sg
|
convertType (IntegerAtom kw sg) = elaborateIntegerAtom $ IntegerAtom kw sg
|
||||||
convertType (IntegerVector TBit sg rs) = IntegerVector TLogic sg rs
|
convertType (IntegerVector TBit sg rs) = IntegerVector TLogic sg rs
|
||||||
convertType other = other
|
convertType other = other
|
||||||
|
|
||||||
|
convertStructFields :: [(Type, Identifier)] -> [(Type, Identifier)]
|
||||||
|
convertStructFields fields =
|
||||||
|
zip (map (convertStructFieldType . fst) fields) (map snd fields)
|
||||||
|
|
||||||
|
convertStructFieldType :: Type -> Type
|
||||||
|
convertStructFieldType (IntegerAtom TInteger sg) = IntegerAtom TInt sg
|
||||||
|
convertStructFieldType t = t
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
module top;
|
||||||
|
typedef struct packed {
|
||||||
|
integer a, b, c;
|
||||||
|
} S;
|
||||||
|
S s = '{a: 1, b: 2, c: 3};
|
||||||
|
initial #1 $display("%b %b %b %b", s, s.a, s.b, s.c);
|
||||||
|
endmodule
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
module top;
|
||||||
|
wire [32*3-1:0] s = {32'd1, 32'd2, 32'd3};
|
||||||
|
initial #1 $display("%b %b %b %b", s, s[64+:32], s[32+:32], s[0+:32]);
|
||||||
|
endmodule
|
||||||
Loading…
Reference in New Issue