Generate function declarations
This commit is contained in:
parent
042f7ccbcd
commit
7773000c36
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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<vhdl_decl>(of, scope_.get_decls(), level, ",");
|
||||
of << ") return ";
|
||||
type_->emit(of, level);
|
||||
of << " is";
|
||||
emit_children<vhdl_decl>(of, scope_.get_decls(), level, ";");
|
||||
of << ") ";
|
||||
newline(of, level);
|
||||
of << "return " << type_->get_string() << " is";
|
||||
emit_children<vhdl_decl>(of, variables_.get_decls(), level);
|
||||
of << "begin";
|
||||
stmts_.emit(of, level);
|
||||
|
|
|
|||
Loading…
Reference in New Issue