Generate function calls with parameters
This commit is contained in:
parent
7773000c36
commit
d997397c38
|
|
@ -222,9 +222,17 @@ vhdl_expr *translate_ufunc(ivl_expr_t e)
|
|||
assert(fdecl);
|
||||
|
||||
vhdl_type *rettype = new vhdl_type(*fdecl->get_type());
|
||||
|
||||
vhdl_fcall *fcall = new vhdl_fcall(funcname, rettype);
|
||||
|
||||
int nparams = ivl_expr_parms(e);
|
||||
for (int i = 0; i < nparams; i++) {
|
||||
vhdl_expr *param = translate_expr(ivl_expr_parm(e, i));
|
||||
if (NULL == param)
|
||||
return NULL;
|
||||
|
||||
fcall->add_expr(param);
|
||||
}
|
||||
|
||||
return fcall;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -404,8 +404,15 @@ int draw_function(ivl_scope_t scope, ivl_scope_t parent)
|
|||
|
||||
switch (ivl_signal_port(sig)) {
|
||||
case IVL_SIP_OUTPUT:
|
||||
assert(func == NULL);
|
||||
func = new vhdl_function(funcname, sigtype);
|
||||
{
|
||||
assert(func == NULL);
|
||||
func = new vhdl_function(funcname, sigtype);
|
||||
|
||||
// The magic variable Verilog_Result holds the return value
|
||||
signame = "Verilog_Result";
|
||||
func->get_scope()->add_decl
|
||||
(new vhdl_var_decl(signame.c_str(), new vhdl_type(*sigtype)));
|
||||
}
|
||||
break;
|
||||
case IVL_SIP_INPUT:
|
||||
assert(func);
|
||||
|
|
@ -417,9 +424,9 @@ int draw_function(ivl_scope_t scope, ivl_scope_t parent)
|
|||
|
||||
remember_signal(sig, func->get_scope());
|
||||
rename_signal(sig, signame);
|
||||
}
|
||||
|
||||
assert(func);
|
||||
}
|
||||
|
||||
assert(func);
|
||||
ent->get_arch()->get_scope()->add_decl(func);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -772,6 +772,8 @@ void vhdl_function::emit(std::ofstream &of, int level) const
|
|||
emit_children<vhdl_decl>(of, variables_.get_decls(), level);
|
||||
of << "begin";
|
||||
stmts_.emit(of, level);
|
||||
of << " return Verilog_Result;";
|
||||
newline(of, level);
|
||||
of << "end function;";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue