diff --git a/tgt-vhdl/expr.cc b/tgt-vhdl/expr.cc index 6eb4b42ca..0b928d4cb 100644 --- a/tgt-vhdl/expr.cc +++ b/tgt-vhdl/expr.cc @@ -533,7 +533,6 @@ static vhdl_expr *translate_ufunc(ivl_expr_t e) vhdl_fcall *fcall = new vhdl_fcall(funcname, rettype); int nparams = ivl_expr_parms(e); - int func_scope_sig = 0; for (int i = 0; i < nparams; i++) { vhdl_expr *param = translate_expr(ivl_expr_parm(e, i)); if (NULL == param) { @@ -542,10 +541,8 @@ static vhdl_expr *translate_ufunc(ivl_expr_t e) } // Ensure the parameter has the correct VHDL type - ivl_signal_t param_sig; - do { - param_sig = ivl_scope_sig(defscope, func_scope_sig++); - } while (ivl_signal_port(param_sig) != IVL_SIP_INPUT); + // Parameter number is i + 1 since 0th parameter is return value + ivl_signal_t param_sig = ivl_scope_port(defscope, i + 1); vhdl_type *param_type = vhdl_type::type_for(ivl_signal_width(param_sig), ivl_signal_signed(param_sig) != 0);