mirror of
https://github.com/verilator/verilator.git
synced 2025-01-24 15:24:04 +00:00
Fix parsing parameter type with assignment and no type keyword.
This commit is contained in:
parent
dea0e6793f
commit
3a0b8c8870
@ -2569,8 +2569,15 @@ packed_dimension<rangep>: // ==IEEE: packed_dimension
|
|||||||
param_assignment<varp>: // ==IEEE: param_assignment
|
param_assignment<varp>: // ==IEEE: param_assignment
|
||||||
// // IEEE: constant_param_expression
|
// // IEEE: constant_param_expression
|
||||||
// // constant_param_expression: '$' is in expr
|
// // constant_param_expression: '$' is in expr
|
||||||
id/*new-parameter*/ variable_dimensionListE sigAttrListE exprEqE
|
id/*new-parameter*/ variable_dimensionListE sigAttrListE exprOrDataTypeEqE
|
||||||
{ $$ = VARDONEA($<fl>1, *$1, $2, $3); if ($4) $$->valuep($4); }
|
{ // To handle #(type A=int, B=A) and properly imply B
|
||||||
|
// as a type (for parsing) we need to detect "A" is a type
|
||||||
|
if (AstNodeDType* refp = VN_CAST($4, NodeDType)) {
|
||||||
|
if (VSymEnt* foundp = SYMP->symCurrentp()->findIdFallback(refp->name())) {
|
||||||
|
UINFO(9, "declaring type via param assignment" << foundp->nodep() << endl);
|
||||||
|
VARDTYPE(new AstParseTypeDType($<fl>1))
|
||||||
|
SYMP->reinsert(foundp->nodep()->cloneTree(false), NULL, *$1); }}
|
||||||
|
$$ = VARDONEA($<fl>1, *$1, $2, $3); if ($4) $$->valuep($4); }
|
||||||
;
|
;
|
||||||
|
|
||||||
list_of_param_assignments<varp>: // ==IEEE: list_of_param_assignments
|
list_of_param_assignments<varp>: // ==IEEE: list_of_param_assignments
|
||||||
@ -3925,6 +3932,12 @@ exprEqE<nodep>: // IEEE: optional '=' expression (part of param_assignment)
|
|||||||
| '=' expr { $$ = $2; }
|
| '=' expr { $$ = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
exprOrDataTypeEqE<nodep>: // IEEE: optional '=' expression (part of param_assignment)
|
||||||
|
// // constant_param_expression: '$' is in expr
|
||||||
|
/*empty*/ { $$ = NULL; }
|
||||||
|
| '=' exprOrDataType { $$ = $2; }
|
||||||
|
;
|
||||||
|
|
||||||
constExpr<nodep>:
|
constExpr<nodep>:
|
||||||
expr { $$ = $1; }
|
expr { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
@ -73,13 +73,14 @@ module mod_typ #(
|
|||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module mod_typ2 #(
|
module mod_typ2
|
||||||
parameter int WIDTH1 = 0,
|
#(
|
||||||
parameter int WIDTH2 = WIDTH1,
|
parameter int WIDTH1 = 0,
|
||||||
parameter type TYP1 = byte,
|
parameter int WIDTH2 = WIDTH1,
|
||||||
//UNSUP not needing 'parameter type' below and implying it
|
parameter type TYP1 = byte,
|
||||||
parameter type TYP2 = TYP1
|
// Below we need to imply that TYP2 is a type
|
||||||
)();
|
TYP2 = TYP1
|
||||||
|
)();
|
||||||
|
|
||||||
TYP1 t1;
|
TYP1 t1;
|
||||||
TYP2 t2;
|
TYP2 t2;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
%Error: t/t_param_type_bad2.v:8:24: syntax error, unexpected ';', expecting "'{"
|
%Error: t/t_param_type_bad2.v:8:19: Operator VAR 't' expected non-datatype Initial value but 'logic' is a datatype.
|
||||||
|
: ... In instance t
|
||||||
8 | localparam t = logic;
|
8 | localparam t = logic;
|
||||||
| ^
|
| ^~~~~
|
||||||
%Error: t/t_param_type_bad2.v:9:28: syntax error, unexpected ';', expecting "'{"
|
%Error: t/t_param_type_bad2.v:9:20: Operator VAR 't2' expected non-datatype Initial value but 'real' is a datatype.
|
||||||
|
: ... In instance t
|
||||||
9 | localparam t2 = realtime;
|
9 | localparam t2 = realtime;
|
||||||
| ^
|
| ^~~~~~~~
|
||||||
%Error: Exiting due to
|
%Error: Exiting due to
|
||||||
|
Loading…
Reference in New Issue
Block a user