From d718e7b4688a6e364aa6252e119465b37e26d503 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Tue, 29 Oct 2019 22:58:48 -0700 Subject: [PATCH] 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. --- design_dump.cc | 2 +- elab_expr.cc | 22 ++++++++++++++++++++-- elab_sig.cc | 17 ++++++++++++++++- pform_dump.cc | 4 +++- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/design_dump.cc b/design_dump.cc index cf8c1d4f3..3491f274a 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -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; } diff --git a/elab_expr.cc b/elab_expr.cc index 630a037c4..c0ccc2d7b 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -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: "; diff --git a/elab_sig.cc b/elab_sig.cc index 4b50fc466..8815ebded 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -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; diff --git a/pform_dump.cc b/pform_dump.cc index 099271d0c..486df19ae 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -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(); }