Commit 13b62fd8 by Zachary Snow

support structs of integers

parent ddaa7ff6
......@@ -17,6 +17,20 @@ convert =
traverseTypes $ traverseNestedTypes convertType
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 (IntegerVector TBit sg rs) = IntegerVector TLogic sg rs
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
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
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
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