Commit 56c597e3 by Zachary Snow

support explicitly typed struct patterns

parent 836536c3
......@@ -292,6 +292,9 @@ 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 (Implicit _ []) expr = expr
convertExpr (Implicit sg rs) expr =
convertExpr (IntegerVector TBit sg rs) expr
......
......@@ -1266,6 +1266,7 @@ Expr :: { Expr }
| Expr "?" Expr ":" Expr { Mux $1 $3 $5 }
| Expr "." Identifier { Dot $1 $3 }
| "'" "{" PatternItems "}" { Pattern $3 }
| Expr "'" "{" PatternItems "}"{ Cast (Right $1) (Pattern $4) }
| CastingType "'" "(" Expr ")" { Cast (Left $1) $4 }
| Expr "'" "(" Expr ")" { Cast (Right $1) $4 }
| "{" StreamOp StreamSize Concat "}" { Stream $2 $3 $4 }
......
module top;
typedef struct packed {
integer x;
byte y;
} S;
typedef struct packed {
byte x;
shortint y;
S z;
} T;
initial $display("%b", T'{ x: 1, y: 2, z: '{ x: 3, y: 4 } });
endmodule
module top;
initial $display("%b", { 8'd1, 16'd2, 32'd3, 8'd4 } );
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