Commit 20dc92f6 by Zachary Snow

fix typeof integer slices

parent ad21277e
...@@ -104,14 +104,18 @@ injectRanges t unpacked = UnpackedType t unpacked ...@@ -104,14 +104,18 @@ injectRanges t unpacked = UnpackedType t unpacked
-- removes the most significant range of the given type -- removes the most significant range of the given type
popRange :: Type -> Type popRange :: Type -> Type
popRange (UnpackedType t [_]) = t popRange (UnpackedType t [_]) = t
popRange (IntegerAtom TInteger sg) =
IntegerVector TLogic sg []
popRange t = popRange t =
tf $ tail rs tf rs
where (tf, rs) = typeRanges t where (tf, _ : rs) = typeRanges t
-- replaces the most significant range of the given type -- replaces the most significant range of the given type
replaceRange :: Range -> Type -> Type replaceRange :: Range -> Type -> Type
replaceRange r (UnpackedType t (_ : rs)) = replaceRange r (UnpackedType t (_ : rs)) =
UnpackedType t (r : rs) UnpackedType t (r : rs)
replaceRange r (IntegerAtom TInteger sg) =
IntegerVector TLogic sg [r]
replaceRange r t = replaceRange r t =
tf $ r : tail rs tf (r : rs)
where (tf, rs) = typeRanges t where (tf, _ : rs) = typeRanges t
...@@ -14,6 +14,7 @@ module top; ...@@ -14,6 +14,7 @@ module top;
Word Ram[0:9]; Word Ram[0:9];
type(Ram) RamPair [2]; type(Ram) RamPair [2];
integer ints [3:0]; integer ints [3:0];
integer ints_rev [0:3];
typedef struct packed { logic x, y, z; } T; typedef struct packed { logic x, y, z; } T;
logic [$size(T)-1:0] foo; logic [$size(T)-1:0] foo;
typedef byte unpacked_t [3]; typedef byte unpacked_t [3];
...@@ -35,7 +36,12 @@ module top; ...@@ -35,7 +36,12 @@ module top;
`EXHAUST(bit); `EXHAUST(bit);
`EXHAUST(byte); `EXHAUST(byte);
`EXHAUST(ints); `EXHAUST(ints);
`EXHAUST(ints_rev);
`EXHAUST(unpacked_t); `EXHAUST(unpacked_t);
`EXHAUST(unpacked); `EXHAUST(unpacked);
`EXHAUST(type(foo[3:0]));
`EXHAUST(type(ints[2][3:0]));
`EXHAUST(type(ints[1:0]));
`EXHAUST(type(ints_rev[0:1]));
end end
endmodule endmodule
...@@ -115,6 +115,16 @@ module top; ...@@ -115,6 +115,16 @@ module top;
$display(1); $display(1);
$display(128); $display(128);
$display(4, 4, 32);
$display(0, 0, 31);
$display(3, 3, 0);
$display(3, 3, 31);
$display(0, 0, 0);
$display(-1, -1, 1);
$display(2);
$display(1);
$display(128);
$display(3, 3, 8); $display(3, 3, 8);
$display(0, 0, 7); $display(0, 0, 7);
$display(2, 2, 0); $display(2, 2, 0);
...@@ -135,5 +145,45 @@ module top; ...@@ -135,5 +145,45 @@ module top;
$display(1); $display(1);
$display(24); $display(24);
$display(4, 4, 1'bx);
$display(3, 3, 1'bx);
$display(0, 0, 1'bx);
$display(3, 3, 1'bx);
$display(0, 0, 1'bx);
$display(1, 1, 1'bx);
$display(1);
$display(0);
$display(4);
$display(4, 4, 1'bx);
$display(3, 3, 1'bx);
$display(0, 0, 1'bx);
$display(3, 3, 1'bx);
$display(0, 0, 1'bx);
$display(1, 1, 1'bx);
$display(1);
$display(0);
$display(4);
$display(2, 2, 32);
$display(1, 1, 31);
$display(0, 0, 0);
$display(1, 1, 31);
$display(0, 0, 0);
$display(1, 1, 1);
$display(2);
$display(1);
$display(64);
$display(2, 2, 32);
$display(0, 0, 31);
$display(1, 1, 0);
$display(1, 1, 31);
$display(0, 0, 0);
$display(-1, -1, 1);
$display(2);
$display(1);
$display(64);
end end
endmodule 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