forked from github/verilator
Fix parameter type redeclaring a type, #2195.
This commit is contained in:
parent
0ca07e4d58
commit
1e0e51edd3
2
Changes
2
Changes
@ -11,6 +11,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
*** Change --quiet-exit to also suppress 'Exiting due to N errors'.
|
||||
|
||||
**** Fix parameter type redeclaring a type, #2195. [hdzhangdoc]
|
||||
|
||||
|
||||
* Verilator 4.030 2020-03-08
|
||||
|
||||
|
@ -1010,6 +1010,7 @@ paramPortDeclOrArgList<nodep>: // IEEE: list_of_param_assignments + { parameter_
|
||||
paramPortDeclOrArg<nodep>: // IEEE: param_assignment + parameter_port_declaration
|
||||
// // We combine the two as we can't tell which follows a comma
|
||||
parameter_port_declarationFrontE param_assignment { $$ = $2; }
|
||||
| parameter_port_declarationTypeFrontE type_assignment { $$ = $2; }
|
||||
;
|
||||
|
||||
portsStarE<nodep>: // IEEE: .* + list_of_ports + list_of_port_declarations + empty
|
||||
@ -1342,6 +1343,7 @@ local_parameter_declaration<nodep>: // IEEE: local_parameter_declaration
|
||||
// // See notes in parameter_declaration
|
||||
// // Front must execute first so VARDTYPE is ready before list of vars
|
||||
local_parameter_declarationFront list_of_param_assignments { $$ = $2; }
|
||||
| local_parameter_declarationTypeFront list_of_type_assignments { $$ = $2; }
|
||||
;
|
||||
|
||||
parameter_declaration<nodep>: // IEEE: parameter_declaration
|
||||
@ -1350,21 +1352,30 @@ parameter_declaration<nodep>: // IEEE: parameter_declaration
|
||||
// // we use list_of_param_assignments because for port handling
|
||||
// // it already must accept types, so simpler to have code only one place
|
||||
// // Front must execute first so VARDTYPE is ready before list of vars
|
||||
parameter_declarationFront list_of_param_assignments { $$ = $2; }
|
||||
parameter_declarationFront list_of_param_assignments { $$ = $2; }
|
||||
| parameter_declarationTypeFront list_of_type_assignments { $$ = $2; }
|
||||
;
|
||||
|
||||
local_parameter_declarationFront: // IEEE: local_parameter_declaration w/o assignment
|
||||
// // Front must execute first so VARDTYPE is ready before list of vars
|
||||
varLParamReset implicit_typeE { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
|
||||
| varLParamReset data_type { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
|
||||
| varLParamReset yTYPE { /*VARRESET-in-varLParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
;
|
||||
|
||||
local_parameter_declarationTypeFront: // IEEE: local_parameter_declaration w/o assignment
|
||||
// // Front must execute first so VARDTYPE is ready before list of vars
|
||||
varLParamReset yTYPE { /*VARRESET-in-varLParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
;
|
||||
|
||||
parameter_declarationFront: // IEEE: parameter_declaration w/o assignment
|
||||
// // Front must execute first so VARDTYPE is ready before list of vars
|
||||
varGParamReset implicit_typeE { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
|
||||
| varGParamReset data_type { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
|
||||
| varGParamReset yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
;
|
||||
|
||||
parameter_declarationTypeFront: // IEEE: parameter_declaration w/o assignment
|
||||
// // Front must execute first so VARDTYPE is ready before list of vars
|
||||
varGParamReset yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
;
|
||||
|
||||
parameter_port_declarationFrontE: // IEEE: parameter_port_declaration w/o assignment
|
||||
@ -1373,12 +1384,18 @@ parameter_port_declarationFrontE: // IEEE: parameter_port_declaration w/o assign
|
||||
// // Front must execute first so VARDTYPE is ready before list of vars
|
||||
varGParamReset implicit_typeE { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
|
||||
| varGParamReset data_type { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
|
||||
| varGParamReset yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
| varLParamReset implicit_typeE { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
|
||||
| varLParamReset data_type { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
|
||||
| varLParamReset yTYPE { /*VARRESET-in-varLParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
| implicit_typeE { /*VARRESET-in-varGParam*/ VARDTYPE($1); }
|
||||
| data_type { /*VARRESET-in-varGParam*/ VARDTYPE($1); }
|
||||
;
|
||||
|
||||
parameter_port_declarationTypeFrontE: // IEEE: parameter_port_declaration w/o assignment
|
||||
// // IEEE: parameter_declaration (minus assignment)
|
||||
// // IEEE: local_parameter_declaration (minus assignment)
|
||||
// // Front must execute first so VARDTYPE is ready before list of vars
|
||||
varGParamReset yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
| varLParamReset yTYPE { /*VARRESET-in-varLParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
| yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($1)); }
|
||||
;
|
||||
|
||||
@ -2348,8 +2365,7 @@ packed_dimension<rangep>: // ==IEEE: packed_dimension
|
||||
param_assignment<varp>: // ==IEEE: param_assignment
|
||||
// // IEEE: constant_param_expression
|
||||
// // constant_param_expression: '$' is in expr
|
||||
// // note exptOrDataType being a data_type is only for yPARAMETER yTYPE
|
||||
id/*new-parameter*/ variable_dimensionListE sigAttrListE '=' exprOrDataType
|
||||
id/*new-parameter*/ variable_dimensionListE sigAttrListE '=' expr
|
||||
/**/ { $$ = VARDONEA($<fl>1,*$1, $2, $3); $$->valuep($5); }
|
||||
| id/*new-parameter*/ variable_dimensionListE sigAttrListE
|
||||
/**/ { $$ = VARDONEA($<fl>1,*$1, $2, $3);
|
||||
@ -2362,6 +2378,17 @@ list_of_param_assignments<varp>: // ==IEEE: list_of_param_assignments
|
||||
| list_of_param_assignments ',' param_assignment { $$ = $1; $1->addNext($3); }
|
||||
;
|
||||
|
||||
type_assignment<varp>: // ==IEEE: type_assignment
|
||||
// // note exptOrDataType being a data_type is only for yPARAMETER yTYPE
|
||||
idAny/*new-parameter*/ sigAttrListE '=' data_type
|
||||
/**/ { $$ = VARDONEA($<fl>1,*$1, NULL, $2); $$->valuep($4); }
|
||||
;
|
||||
|
||||
list_of_type_assignments<varp>: // ==IEEE: list_of_type_assignments
|
||||
type_assignment { $$ = $1; }
|
||||
| list_of_type_assignments ',' type_assignment { $$ = $1; $1->addNext($3); }
|
||||
;
|
||||
|
||||
list_of_defparam_assignments<nodep>: //== IEEE: list_of_defparam_assignments
|
||||
defparam_assignment { $$ = $1; }
|
||||
| list_of_defparam_assignments ',' defparam_assignment { $$ = $1->addNext($3); }
|
||||
|
21
test_regress/t/t_param_type3.pl
Executable file
21
test_regress/t/t_param_type3.pl
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003 by Wilson Snyder. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
compile(
|
||||
);
|
||||
|
||||
#execute(
|
||||
# check_finished => 1,
|
||||
# );
|
||||
|
||||
ok(1);
|
||||
1;
|
50
test_regress/t/t_param_type3.v
Normal file
50
test_regress/t/t_param_type3.v
Normal file
@ -0,0 +1,50 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2012 by Iztok Jeras.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
typedef logic T_t;
|
||||
|
||||
module t (/*AUTOARG*/
|
||||
// Outputs
|
||||
o, o2,
|
||||
// Inputs
|
||||
i
|
||||
);
|
||||
|
||||
input T_t i;
|
||||
output T_t o;
|
||||
output T_t o2;
|
||||
|
||||
sub #(.T_t(T_t))
|
||||
sub (.i, .o);
|
||||
|
||||
sub2 #(.T_t(T_t))
|
||||
sub2 (.i, .o(o2));
|
||||
|
||||
endmodule
|
||||
|
||||
module sub (i,o);
|
||||
parameter type T_t = logic;
|
||||
localparam type T2_t = T_t;
|
||||
input T_t i;
|
||||
output T2_t o;
|
||||
assign o = i;
|
||||
endmodule
|
||||
|
||||
module sub2
|
||||
#(
|
||||
parameter type T_t = logic,
|
||||
localparam type T2_t = T_t
|
||||
)
|
||||
(
|
||||
input T_t i,
|
||||
output T_t o
|
||||
);
|
||||
assign o = i;
|
||||
endmodule
|
||||
|
||||
// Local Variables:
|
||||
// verilog-typedef-regexp: "_t$"
|
||||
// End:
|
@ -1,4 +1,4 @@
|
||||
%Error: t/t_param_type_bad.v:9:20: Parameter type's initial value isn't a type: 'bad2'
|
||||
%Error: t/t_param_type_bad.v:9:27: syntax error, unexpected INTEGER NUMBER, expecting TYPE-IDENTIFIER
|
||||
localparam type bad2 = 2;
|
||||
^~~~
|
||||
^
|
||||
%Error: Exiting due to
|
||||
|
@ -1,9 +1,7 @@
|
||||
%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
|
||||
%Error: t/t_param_type_bad2.v:8:24: syntax error, unexpected ';', expecting "'{"
|
||||
localparam t = logic;
|
||||
^~~~~
|
||||
%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
|
||||
^
|
||||
%Error: t/t_param_type_bad2.v:9:28: syntax error, unexpected ';', expecting "'{"
|
||||
localparam t2 = realtime;
|
||||
^~~~~~~~
|
||||
^
|
||||
%Error: Exiting due to
|
||||
|
Loading…
Reference in New Issue
Block a user