diff --git a/elab_sig.cc b/elab_sig.cc index b33e993b9..9b78b110f 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -715,16 +715,23 @@ void PTaskFunc::elaborate_sig_ports_(Design*des, NetScope*scope, continue; } - // If the port has a default expression that can be used - // as a value when the caller doesn't bind, then - // elaborate that expression here. This expression - // should evaluate down do a constant. + // If the port has a default expression, elaborate + // that expression here. if (ports_->at(idx).defe != 0) { - tmp_def = elab_and_eval(des, scope, ports_->at(idx).defe, -1, true); - if (tmp_def==0) { - cerr << get_fileline() << ": error: Unable to evaluate " - << *ports_->at(idx).defe - << " as a port default (constant) expression." << endl; + if (tmp->port_type() == NetNet::PINPUT) { + tmp_def = elab_and_eval(des, scope, ports_->at(idx).defe, + -1, scope->need_const_func()); + if (tmp_def == 0) { + cerr << get_fileline() + << ": error: Unable to evaluate " + << *ports_->at(idx).defe + << " as a port default expression." << endl; + des->errors += 1; + } + } else { + cerr << get_fileline() << ": sorry: Default arguments " + "for subroutine output or inout ports are not " + "yet supported." << endl; des->errors += 1; } } diff --git a/elaborate.cc b/elaborate.cc index 974312c9e..01fafbc8e 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -3740,9 +3740,9 @@ NetProc* PCallTask::elaborate_build_call_(Design*des, NetScope*scope, } else if (def->port_defe(idx)) { if (! gn_system_verilog()) { - cerr << get_fileline() << ": internal error: " + cerr << get_fileline() << ": error: " << "Found (and using) default task expression " - << " requires SystemVerilog." << endl; + "requires SystemVerilog." << endl; des->errors += 1; } rv = def->port_defe(idx); diff --git a/net_design.cc b/net_design.cc index dfaf51d56..2862815c6 100644 --- a/net_design.cc +++ b/net_design.cc @@ -847,6 +847,7 @@ NetFuncDef* Design::find_function(NetScope*scope, const pform_name_t&name) // the function's signals have been elaborated. If this is // the case, elaborate them now. if (func->elab_stage() < 2) { + func->need_const_func(true); const PFunction*pfunc = func->func_pform(); assert(pfunc); pfunc->elaborate_sig(this, func);