mirror of https://github.com/zachjs/sv2v.git
avoid unnecessary casts on substituted hierarchical constants
This commit is contained in:
parent
46be0edbdf
commit
121fea5aec
|
|
@ -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 ()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
module top;
|
||||
initial begin
|
||||
$display("%b", 32'd1);
|
||||
$display("%b", 8'd2);
|
||||
$display("%b", 16'd3);
|
||||
end
|
||||
endmodule
|
||||
Loading…
Reference in New Issue