Commit 121fea5a by Zachary Snow

avoid unnecessary casts on substituted hierarchical constants

parent 46be0edb
......@@ -99,7 +99,7 @@ traverseStmtM stmt = do
return stmt'
traverseExprM :: Expr -> SC Expr
traverseExprM (Cast (Left (IntegerVector _ sg rs)) value) = do
traverseExprM (Cast (Left (IntegerVector kw sg rs)) value) | kw /= TBit = do
value' <- traverseExprM value
size' <- traverseExprM size
convertCastM size' value' signed
......
......@@ -71,7 +71,10 @@ traverseDeclM decl = do
scopeExpr e >>= insertElem x . Right
Param Localparam (Implicit sg rs) x e ->
scopeExpr (Cast (Left t) e) >>= insertElem x . Right
where t = IntegerVector TLogic sg rs
where t = IntegerVector TBit sg rs
Param Localparam (IntegerVector _ sg rs) x e ->
scopeExpr (Cast (Left t) e) >>= insertElem x . Right
where t = IntegerVector TBit sg rs
Param Localparam t x e ->
scopeExpr (Cast (Left t) e) >>= insertElem x . Right
_ -> return ()
......
module top;
typedef struct packed {
int A;
byte B;
shortint C;
} T;
localparam T Q = '{ A: 1, B: 2, C: 3 };
if (1) begin : blk
localparam T P = Q;
logic [P.A - 1:0] a;
logic [P.B - 1:0] b;
logic [P.C - 1:0] c;
end
initial begin
$display("%b", $bits(blk.a));
$display("%b", $bits(blk.b));
$display("%b", $bits(blk.c));
end
endmodule
module top;
initial begin
$display("%b", 32'd1);
$display("%b", 8'd2);
$display("%b", 16'd3);
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