mirror of https://github.com/zachjs/sv2v.git
fix handling of explicitly typed struct patterns in other contexts
This commit is contained in:
parent
dde734be26
commit
ab867465da
|
|
@ -152,9 +152,7 @@ traverseStmtM' =
|
|||
traverseStmtAsgnsM traverseAsgnM
|
||||
|
||||
traverseExprM :: Expr -> Scoper Type Expr
|
||||
traverseExprM =
|
||||
(embedScopes convertSubExpr >=> return . snd) .
|
||||
(traverseNestedExprs $ traverseExprTypes convertType)
|
||||
traverseExprM = embedScopes convertSubExpr >=> return . snd
|
||||
|
||||
traverseLHSM :: LHS -> Scoper Type LHS
|
||||
traverseLHSM = convertLHS >=> return . snd
|
||||
|
|
@ -292,10 +290,12 @@ convertExpr (struct @ (Struct _ fields [])) (Pattern itemsOrig) =
|
|||
Just value = numberToInteger n
|
||||
Right (Number n) = item
|
||||
|
||||
convertExpr _ (Cast (Left t) expr@Pattern{}) =
|
||||
Cast (Left t) $ convertExpr t expr
|
||||
convertExpr _ (Cast (Left t) expr) =
|
||||
Cast (Left t') $ convertExpr t expr
|
||||
where t' = convertType t
|
||||
|
||||
convertExpr (Implicit _ []) expr = expr
|
||||
convertExpr (Implicit _ []) expr =
|
||||
traverseSinglyNestedExprs (convertExpr UnknownType) expr
|
||||
convertExpr (Implicit sg rs) expr =
|
||||
convertExpr (IntegerVector TBit sg rs) expr
|
||||
|
||||
|
|
@ -343,7 +343,8 @@ convertExpr t (Concat exprs) =
|
|||
t' = dropInnerTypeRange t
|
||||
exprs' = map (convertExpr t') exprs
|
||||
|
||||
convertExpr _ other = other
|
||||
convertExpr _ expr =
|
||||
traverseSinglyNestedExprs (convertExpr UnknownType) expr
|
||||
|
||||
fallbackType :: Scopes Type -> Expr -> (Type, Expr)
|
||||
fallbackType scopes e =
|
||||
|
|
@ -484,7 +485,8 @@ convertSubExpr scopes e =
|
|||
traverseSinglyNestedExprs exprMapper e
|
||||
where
|
||||
exprMapper = snd . convertSubExpr scopes
|
||||
typeMapper = traverseNestedTypes $ traverseTypeExprs exprMapper
|
||||
typeMapper = convertType .
|
||||
traverseNestedTypes (traverseTypeExprs exprMapper)
|
||||
|
||||
-- get the fields and type function of a struct or union
|
||||
getFields :: Type -> Maybe [Field]
|
||||
|
|
|
|||
|
|
@ -8,5 +8,25 @@ module top;
|
|||
shortint y;
|
||||
S z;
|
||||
} T;
|
||||
initial $display("%b", T'{ x: 1, y: 2, z: '{ x: 3, y: 4 } });
|
||||
var T a;
|
||||
initial a = T'{ x: 5, y: 6, z: '{ x: 7, y: 8 } };
|
||||
var T b;
|
||||
T c;
|
||||
assign c = T'{ x: 9, y: 10, z: '{ x: 11, y: 12 } };
|
||||
initial begin
|
||||
b = T'{ x: 13, y: 14, z: '{ x: 15, y: 16 } };
|
||||
#1;
|
||||
$display("a %b", a);
|
||||
$display("b %b", b);
|
||||
$display("c %b", c);
|
||||
$display("x %b", T'{ x: 1, y: 2, z: '{ x: 3, y: 4 } });
|
||||
$display("$bits(S) = %0d", $bits(S));
|
||||
$display("$bits(T) = %0d", $bits(T));
|
||||
$display("$bits(a) = %0d", $bits(a));
|
||||
$display("$bits(a.x) = %0d", $bits(a.x));
|
||||
$display("$bits(a.y) = %0d", $bits(a.y));
|
||||
$display("$bits(a.z) = %0d", $bits(a.z));
|
||||
$display("$bits(a.z.x) = %0d", $bits(a.z.x));
|
||||
$display("$bits(a.z.y) = %0d", $bits(a.z.y));
|
||||
end
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -1,3 +1,20 @@
|
|||
module top;
|
||||
initial $display("%b", { 8'd1, 16'd2, 32'd3, 8'd4 } );
|
||||
reg [63:0] a = { 8'd5, 16'd6, 32'd7, 8'd8 };
|
||||
reg [63:0] b = { 8'd13, 16'd14, 32'd15, 8'd16 };
|
||||
wire [63:0] c = { 8'd9, 16'd10, 32'd11, 8'd12 };
|
||||
initial begin
|
||||
#1;
|
||||
$display("a %b", a);
|
||||
$display("b %b", b);
|
||||
$display("c %b", c);
|
||||
$display("x %b", { 8'd1, 16'd2, 32'd3, 8'd4 } );
|
||||
$display("$bits(S) = %0d", 40);
|
||||
$display("$bits(T) = %0d", 64);
|
||||
$display("$bits(a) = %0d", 64);
|
||||
$display("$bits(a.x) = %0d", 8);
|
||||
$display("$bits(a.y) = %0d", 16);
|
||||
$display("$bits(a.z) = %0d", 40);
|
||||
$display("$bits(a.z.x) = %0d", 32);
|
||||
$display("$bits(a.z.y) = %0d", 8);
|
||||
end
|
||||
endmodule
|
||||
|
|
|
|||
Loading…
Reference in New Issue