Commit 20dc92f6 by Zachary Snow

fix typeof integer slices

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