mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Delay parameter type assignment determination until elaboration
This commit is contained in:
parent
e7de2c5a05
commit
5f39c69d19
@ -3928,7 +3928,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
nodep->refDTypep(defp);
|
||||
nodep->classOrPackagep(foundp->classOrPackagep());
|
||||
}
|
||||
} else if (AstClass* const defp = foundp ? VN_AS(foundp->nodep(), Class) : nullptr) {
|
||||
} else if (AstClass* const defp = foundp ? VN_CAST(foundp->nodep(), Class) : nullptr) {
|
||||
AstPin* const paramsp = nodep->paramsp();
|
||||
if (paramsp) paramsp->unlinkFrBackWithNext();
|
||||
AstClassRefDType* const newp
|
||||
@ -3941,7 +3941,11 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||
return;
|
||||
} else {
|
||||
if (foundp) UINFO(1, "Found sym node: " << foundp->nodep() << endl);
|
||||
nodep->v3error("Can't find typedef: " << nodep->prettyNameQ());
|
||||
if (foundp) {
|
||||
nodep->v3error("Expecting a data type: " << nodep->prettyNameQ());
|
||||
} else {
|
||||
nodep->v3error("Can't find typedef: " << nodep->prettyNameQ());
|
||||
}
|
||||
}
|
||||
}
|
||||
iterateChildren(nodep);
|
||||
|
@ -2137,6 +2137,26 @@ data_type<nodeDTypep>: // ==IEEE: data_type
|
||||
$$ = GRAMMARP->createArray(refp, $4, true); }
|
||||
;
|
||||
|
||||
data_typeAny<nodeDTypep>: // ==IEEE: data_type (accepting idAny)
|
||||
// // IEEE: data_type_or_incomplete_class_scoped_type parses same as this
|
||||
// // as can't tell them apart until link
|
||||
// // This expansion also replicated elsewhere, IE data_type__AndID
|
||||
data_typeNoRef { $$ = $1; }
|
||||
//
|
||||
// // REFERENCES
|
||||
//
|
||||
// // IEEE: [ class_scope | package_scope ] type_identifier { packed_dimension }
|
||||
// // IEEE: class_type
|
||||
// // IEEE: ps_covergroup_identifier
|
||||
// // Don't distinguish between types and classes so all these combined
|
||||
| packageClassScopeE idAny packed_dimensionListE
|
||||
{ AstRefDType* const refp = new AstRefDType{$<fl>2, *$2, $1, nullptr};
|
||||
$$ = GRAMMARP->createArray(refp, $3, true); }
|
||||
| packageClassScopeE idAny parameter_value_assignmentClass packed_dimensionListE
|
||||
{ AstRefDType* const refp = new AstRefDType{$<fl>2, *$2, $1, $3};
|
||||
$$ = GRAMMARP->createArray(refp, $4, true); }
|
||||
;
|
||||
|
||||
data_typeBasic<nodeDTypep>: // IEEE: part of data_type
|
||||
integer_vector_type signingE rangeListE { $1->setSignedState($2); $$ = GRAMMARP->addRange($1, $3, true); }
|
||||
| integer_atom_type signingE { $1->setSignedState($2); $$ = $1; }
|
||||
@ -3176,7 +3196,7 @@ type_assignment<varp>: // ==IEEE: type_assignment
|
||||
// // note exptOrDataType being a data_type is only for yPARAMETER yTYPE
|
||||
idAny/*new-parameter*/ sigAttrListE
|
||||
{ $$ = VARDONEA($<fl>1, *$1, nullptr, $2); }
|
||||
| idAny/*new-parameter*/ sigAttrListE '=' data_type
|
||||
| idAny/*new-parameter*/ sigAttrListE '=' data_typeAny
|
||||
{ $$ = VARDONEA($<fl>1, *$1, nullptr, $2); $$->valuep($4); }
|
||||
;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
%Error: t/t_param_type_bad.v:9:27: syntax error, unexpected INTEGER NUMBER, expecting TYPE-IDENTIFIER
|
||||
%Error: t/t_param_type_bad.v:9:27: syntax error, unexpected INTEGER NUMBER, expecting IDENTIFIER or TYPE-IDENTIFIER or randomize
|
||||
9 | localparam type bad2 = 2;
|
||||
| ^
|
||||
%Error: Exiting due to
|
||||
|
4
test_regress/t/t_param_type_id_bad.out
Normal file
4
test_regress/t/t_param_type_id_bad.out
Normal file
@ -0,0 +1,4 @@
|
||||
%Error: t/t_param_type_id_bad.v:9:34: Expecting a data type: 'i'
|
||||
9 | class Cls #(parameter type P_T = i);
|
||||
| ^
|
||||
%Error: Exiting due to
|
16
test_regress/t/t_param_type_id_bad.py
Executable file
16
test_regress/t/t_param_type_id_bad.py
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2024 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
|
||||
|
||||
import vltest_bootstrap
|
||||
|
||||
test.scenarios('linter')
|
||||
|
||||
test.lint(fails=test.vlt_all, expect_filename=test.golden_filename)
|
||||
|
||||
test.passes()
|
10
test_regress/t/t_param_type_id_bad.v
Normal file
10
test_regress/t/t_param_type_id_bad.v
Normal file
@ -0,0 +1,10 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2019 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
int i;
|
||||
|
||||
class Cls #(parameter type P_T = i);
|
||||
endclass
|
@ -1,4 +1,4 @@
|
||||
%Error: t/t_no_typedef_bad.v:10:4: Can't find typedef: 'sometype'
|
||||
%Error: t/t_typedef_no_bad.v:10:4: Can't find typedef: 'sometype'
|
||||
10 | sometype p;
|
||||
| ^~~~~~~~
|
||||
%Error: Exiting due to
|
Loading…
Reference in New Issue
Block a user