Commit d0a6b0f5 by Zachary Snow

fix 32 bit constant cast

parent 3186afe4
...@@ -66,7 +66,9 @@ traverseExprM = ...@@ -66,7 +66,9 @@ traverseExprM =
where where
str = (show size) ++ "'d" ++ (show num) str = (show size) ++ "'d" ++ (show num)
size = s' size = s'
num = n' `mod` (2 ^ s') num = if size == 32
then n'
else n' `mod` (2 ^ s')
_ -> convertCastM (Number s) (Number n) _ -> convertCastM (Number s) (Number n)
convertExprM (orig @ (Cast (Right DimsFn{}) _)) = convertExprM (orig @ (Cast (Right DimsFn{}) _)) =
return orig return orig
......
...@@ -22,6 +22,7 @@ module top; ...@@ -22,6 +22,7 @@ module top;
$display("%0d %0d", x, ($clog2(WIDTH))'(x)); $display("%0d %0d", x, ($clog2(WIDTH))'(x));
$display("%0d %0d", y, ($clog2(WIDTH))'(y)); $display("%0d %0d", y, ($clog2(WIDTH))'(y));
$display("%0d %0d", z, ($clog2(WIDTH))'(z)); $display("%0d %0d", z, ($clog2(WIDTH))'(z));
$display("%b", 32'(4));
end end
localparam bit foo = '0; localparam bit foo = '0;
......
...@@ -25,6 +25,7 @@ module top; ...@@ -25,6 +25,7 @@ module top;
$display("%0d %0d", x, $signed(x[4:0])); $display("%0d %0d", x, $signed(x[4:0]));
$display("%0d %0d", y, $signed(y[4:0])); $display("%0d %0d", y, $signed(y[4:0]));
$display("%0d %0d", z, z[4:0]); $display("%0d %0d", z, z[4:0]);
$display("%b", 32'd4);
end end
localparam [0:0] foo = 0; localparam [0:0] foo = 0;
......
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