support explicitly typed struct patterns

This commit is contained in:
Zachary Snow 2021-07-19 11:42:36 -04:00
parent 836536c362
commit 56c597e35e
4 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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 }

View File

@ -0,0 +1,12 @@
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

View File

@ -0,0 +1,3 @@
module top;
initial $display("%b", { 8'd1, 16'd2, 32'd3, 8'd4 } );
endmodule