Support method calls on package scoped signals

Currently package scoped function calls are supported. Update the parser
and elaboration to also allow method calls on packaged scoped variables.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-09-25 18:57:38 +02:00
parent 45bd0968c3
commit c1f2e0c21f
4 changed files with 14 additions and 20 deletions

View File

@ -238,8 +238,8 @@ static pform_name_t pn_from_ps(perm_string n)
return tmp;
}
PECallFunction::PECallFunction(PPackage*pkg, perm_string n, const list<PExpr *> &parms)
: package_(pkg), path_(pn_from_ps(n)), parms_(parms.size()), is_overridden_(false)
PECallFunction::PECallFunction(PPackage*pkg, const pform_name_t&n, const list<PExpr *> &parms)
: package_(pkg), path_(n), parms_(parms.size()), is_overridden_(false)
{
int tmp_idx = 0;
assert(parms_.size() == parms.size());

View File

@ -521,7 +521,8 @@ class PEIdent : public PExpr {
unsigned expr_wid,
unsigned flags) const;
unsigned test_width_method_(Design*des, NetScope*scope, width_mode_t&mode);
unsigned test_width_method_(const symbol_search_results &sr);
unsigned test_width_parameter_(const NetExpr *par, width_mode_t&mode);
@ -886,8 +887,7 @@ class PECallFunction : public PExpr {
public:
explicit PECallFunction(const pform_name_t&n, const std::vector<PExpr *> &parms);
// Call function defined in package.
explicit PECallFunction(PPackage*pkg, perm_string n, const std::vector<PExpr *> &parms);
explicit PECallFunction(PPackage*pkg, perm_string n, const std::list<PExpr *> &parms);
explicit PECallFunction(PPackage*pkg, const pform_name_t&n, const std::list<PExpr *> &parms);
// Used to convert a user function called as a task
explicit PECallFunction(PPackage*pkg, const pform_name_t&n, const std::vector<PExpr *> &parms);

View File

@ -3981,7 +3981,7 @@ NetExpr* PEIdent::calculate_up_do_base_(Design*des, NetScope*scope,
return tmp;
}
unsigned PEIdent::test_width_method_(Design*des, NetScope*scope, width_mode_t&)
unsigned PEIdent::test_width_method_(const symbol_search_results &sr)
{
if (!gn_system_verilog())
return 0;
@ -3998,12 +3998,7 @@ unsigned PEIdent::test_width_method_(Design*des, NetScope*scope, width_mode_t&)
<< " of signal " << use_path << endl;
}
NetNet*net = 0;
ivl_type_t cls_val = 0;
const NetExpr*par = 0;
ivl_type_t par_type = 0;
NetEvent*eve = 0;
symbol_search(this, des, scope, use_path, net, par, eve, par_type, cls_val);
NetNet *net = sr.net;
if (net == 0) {
if (debug_elaborate)
cerr << get_fileline() << ": PEIdent::test_width_method_: "
@ -4088,13 +4083,13 @@ unsigned PEIdent::test_width(Design*des, NetScope*scope, width_mode_t&mode)
ivl_assert(*this, use_scope);
}
if (unsigned tmp = test_width_method_(des, scope, mode)) {
return tmp;
}
symbol_search_results sr;
symbol_search(this, des, use_scope, path_, &sr);
if (unsigned tmp = test_width_method_(sr)) {
return tmp;
}
// If there is a part/bit select expression, then process it
// here. This constrains the results no matter what kind the
// name is.

View File

@ -3776,11 +3776,10 @@ expr_primary
delete $3;
$$ = tmp;
}
| package_scope IDENTIFIER { lex_in_package_scope(0); } '(' expression_list_with_nuls ')'
{ perm_string use_name = lex_strings.make($2);
PECallFunction*tmp = new PECallFunction($1, use_name, *$5);
| package_scope hierarchy_identifier { lex_in_package_scope(0); } '(' expression_list_with_nuls ')'
{ PECallFunction*tmp = new PECallFunction($1, *$2, *$5);
FILE_NAME(tmp, @2);
delete[]$2;
delete $2;
delete $5;
$$ = tmp;
}