Commit 2dcd35ad by Zachary Snow

support typedefs with unpacked dimensions

parent a402a734
......@@ -776,6 +776,7 @@ PackageItem :: { [PackageItem] }
| NonDeclPackageItem { $1 }
NonDeclPackageItem :: { [PackageItem] }
: "typedef" Type Identifier ";" { [Typedef $2 $3] }
| "typedef" Type Identifier DimensionsNonEmpty ";" { [Typedef (UnpackedType $2 $4) $3] }
| "function" Lifetime FuncRetAndName TFItems DeclsAndStmts "endfunction" opt(Tag) { [Function $2 (fst $3) (snd $3) (map defaultFuncInput $ (map makeInput $4) ++ fst $5) (snd $5)] }
| "function" Lifetime "void" Identifier TFItems DeclsAndStmts "endfunction" opt(Tag) { [Task $2 $4 (map defaultFuncInput $ $5 ++ fst $6) (snd $6)] }
| "task" Lifetime Identifier TFItems DeclsAndStmts "endtask" opt(Tag) { [Task $2 $3 (map defaultFuncInput $ $4 ++ fst $5) (snd $5)] }
......
......@@ -16,6 +16,8 @@ module top;
integer ints [3:0];
typedef struct packed { logic x, y, z; } T;
logic [$size(T)-1:0] foo;
typedef byte unpacked_t [3];
unpacked_t unpacked;
initial begin
$display($size(Word));
$display($size(Ram,2));
......@@ -33,5 +35,7 @@ module top;
`EXHAUST(bit);
`EXHAUST(byte);
`EXHAUST(ints);
`EXHAUST(unpacked_t);
`EXHAUST(unpacked);
end
endmodule
......@@ -114,5 +114,26 @@ module top;
$display(2);
$display(1);
$display(128);
$display(3, 3, 8);
$display(0, 0, 7);
$display(2, 2, 0);
$display(2, 2, 7);
$display(0, 0, 0);
$display(-1, -1, 1);
$display(2);
$display(1);
$display(24);
$display(3, 3, 8);
$display(0, 0, 7);
$display(2, 2, 0);
$display(2, 2, 7);
$display(0, 0, 0);
$display(-1, -1, 1);
$display(2);
$display(1);
$display(24);
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