Handle case that strings are arguments of functions/tasks.

When strings are arguments to functions/tasks, that doesn't suddenly
make them implicitly scalar. Strings are vectors and should be treated
that was, even if they are IMPLICIT_REG.
This commit is contained in:
Stephen Williams 2019-10-29 22:58:48 -07:00
parent 16e8563c6e
commit d718e7b468
4 changed files with 40 additions and 5 deletions

View File

@ -238,7 +238,7 @@ ostream& netqueue_t::debug_dump(ostream&fd) const
ostream& netvector_t::debug_dump(ostream&o) const
{
o << type_ << (signed_? " signed" : " unsigned") << packed_dims_;
o << "netvector_t:" << type_ << (signed_? " signed" : " unsigned") << packed_dims_;
return o;
}

View File

@ -4013,6 +4013,9 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
cerr << get_fileline() << ": PEIdent::elaborate_expr: "
<< "Symbol search found base_path=" << base_path
<< ", member_path=" << member_path
<< ", par=" << par
<< ", net=" << net
<< ", eve=" << eve
<< endl;
}
@ -4816,6 +4819,13 @@ NetExpr* PEIdent::elaborate_expr_net_word_(Design*des, NetScope*scope,
const name_component_t&name_tail = path_.back();
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_net_word_: "
<< "expr_wid=" << expr_wid
<< ", net->get_scalar()==" << (net->get_scalar()?"true":"false")
<< endl;
}
// Special case: This is the entire array, and we are a direct
// argument of a system task.
if (name_tail.index.empty() && (SYS_TASK_ARG & flags)) {
@ -5510,6 +5520,15 @@ NetExpr* PEIdent::elaborate_expr_net(Design*des, NetScope*scope,
unsigned expr_wid,
unsigned flags) const
{
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_expr_net: "
<< "net=" << net->name()
<< ", net->unpacked_dimensions()=" << net->unpacked_dimensions()
<< ", net->get_scalar()=" << (net->get_scalar()?"true":"false")
<< ", net->net_type()=" << *net->net_type()
<< endl;
}
if (net->unpacked_dimensions() > 0)
return elaborate_expr_net_word_(des, scope, net, found_in,
expr_wid, flags);
@ -5523,8 +5542,7 @@ NetExpr* PEIdent::elaborate_expr_net(Design*des, NetScope*scope,
if (! path_.back().index.empty())
use_sel = path_.back().index.back().sel;
if (net->get_scalar() &&
use_sel != index_component_t::SEL_NONE) {
if (net->get_scalar() && use_sel != index_component_t::SEL_NONE) {
cerr << get_fileline() << ": error: can not select part of ";
if (node->expr_type() == IVL_VT_REAL) cerr << "real: ";
else cerr << "scalar: ";

View File

@ -932,9 +932,24 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
wtype = NetNet::WIRE;
is_implicit_scalar = true;
}
// Certain contexts, such as arguments to functions, presume
// "reg" instead of "wire". The parser reports these as
// IMPLICIT_REG. Also, certain cases, such as:
// fun(string arg1) ...
// are implicitly NOT scalar, so detect that case here.
if (wtype == NetNet::IMPLICIT_REG) {
wtype = NetNet::REG;
is_implicit_scalar = true;
if (data_type_!=IVL_VT_STRING)
is_implicit_scalar = true;
}
if (debug_elaborate) {
cerr << get_fileline() << ": PWire::elaborate_sig: "
<< "Signal " << basename()
<< ", wtype=" << wtype
<< ", data_type_=" << data_type_
<< ", is_implicit_scalar=" << (is_implicit_scalar?"true":"false")
<< endl;
}
unsigned wid = 1;

View File

@ -528,10 +528,12 @@ void PWire::dump(ostream&out, unsigned ind) const
if (signed_) {
out << " signed";
}
if (get_isint()) {
out << " integer";
}
if (get_scalar()) {
out << " scalar";
}
if (set_data_type_) {
out << " set_data_type_=" << typeid(*set_data_type_).name();
}