diff --git a/tgt-vhdl/scope.cc b/tgt-vhdl/scope.cc index faaadde83..b5a7de94d 100644 --- a/tgt-vhdl/scope.cc +++ b/tgt-vhdl/scope.cc @@ -401,12 +401,18 @@ int draw_function(ivl_scope_t scope, ivl_scope_t parent) std::string signame = make_safe_name(sig); vhdl_type *sigtype = get_signal_type(sig); - if (ivl_signal_type(sig) == IVL_SIT_REG) { + + switch (ivl_signal_port(sig)) { + case IVL_SIP_OUTPUT: + assert(func == NULL); func = new vhdl_function(funcname, sigtype); - - } - else { + break; + case IVL_SIP_INPUT: assert(func); + func->add_param(new vhdl_param_decl(signame.c_str(), sigtype)); + break; + default: + assert(false); } remember_signal(sig, func->get_scope()); diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index d8bdb95ed..4825b94e5 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -765,10 +765,10 @@ vhdl_function::vhdl_function(const char *name, vhdl_type *ret_type) void vhdl_function::emit(std::ofstream &of, int level) const { of << "function " << name_ << " ("; - emit_children(of, scope_.get_decls(), level, ","); - of << ") return "; - type_->emit(of, level); - of << " is"; + emit_children(of, scope_.get_decls(), level, ";"); + of << ") "; + newline(of, level); + of << "return " << type_->get_string() << " is"; emit_children(of, variables_.get_decls(), level); of << "begin"; stmts_.emit(of, level);