Support signed function return values.

This commit is contained in:
steve 2007-03-06 05:22:49 +00:00
parent e6fa72c318
commit 760f2182ba
5 changed files with 24 additions and 8 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: PTask.h,v 1.13 2004/05/31 23:34:36 steve Exp $" #ident "$Id: PTask.h,v 1.14 2007/03/06 05:22:49 steve Exp $"
#endif #endif
# include "LineInfo.h" # include "LineInfo.h"
@ -35,6 +35,7 @@ class PExpr;
enum PTaskFuncEnum { enum PTaskFuncEnum {
PTF_NONE, PTF_NONE,
PTF_REG, PTF_REG,
PTF_REG_S,
PTF_INTEGER, PTF_INTEGER,
PTF_REAL, PTF_REAL,
PTF_REALTIME, PTF_REALTIME,
@ -117,6 +118,9 @@ class PFunction : public LineInfo {
/* /*
* $Log: PTask.h,v $ * $Log: PTask.h,v $
* Revision 1.14 2007/03/06 05:22:49 steve
* Support signed function return values.
*
* Revision 1.13 2004/05/31 23:34:36 steve * Revision 1.13 2004/05/31 23:34:36 steve
* Rewire/generalize parsing an elaboration of * Rewire/generalize parsing an elaboration of
* function return values to allow for better * function return values to allow for better

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_expr.cc,v 1.119 2007/03/02 01:55:36 steve Exp $" #ident "$Id: elab_expr.cc,v 1.120 2007/03/06 05:22:49 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -531,6 +531,8 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
if (NetNet*res = dscope->find_signal(dscope->basename())) { if (NetNet*res = dscope->find_signal(dscope->basename())) {
NetESignal*eres = new NetESignal(res); NetESignal*eres = new NetESignal(res);
NetEUFunc*func = new NetEUFunc(dscope, eres, parms); NetEUFunc*func = new NetEUFunc(dscope, eres, parms);
func->set_line(*this);
func->cast_signed(res->get_signed());
return func; return func;
} }
@ -1606,6 +1608,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
/* /*
* $Log: elab_expr.cc,v $ * $Log: elab_expr.cc,v $
* Revision 1.120 2007/03/06 05:22:49 steve
* Support signed function return values.
*
* Revision 1.119 2007/03/02 01:55:36 steve * Revision 1.119 2007/03/02 01:55:36 steve
* Better error message when operating on array. * Better error message when operating on array.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_sig.cc,v 1.45 2007/02/01 05:24:08 steve Exp $" #ident "$Id: elab_sig.cc,v 1.46 2007/03/06 05:22:49 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -316,6 +316,7 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const
switch (return_type_.type) { switch (return_type_.type) {
case PTF_REG: case PTF_REG:
case PTF_REG_S:
if (return_type_.range) { if (return_type_.range) {
NetExpr*me = elab_and_eval(des, scope, NetExpr*me = elab_and_eval(des, scope,
(*return_type_.range)[0], -1); (*return_type_.range)[0], -1);
@ -349,6 +350,7 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const
ret_sig = new NetNet(scope, fname, NetNet::REG); ret_sig = new NetNet(scope, fname, NetNet::REG);
} }
ret_sig->set_line(*this); ret_sig->set_line(*this);
ret_sig->set_signed(return_type_.type == PTF_REG_S);
ret_sig->port_type(NetNet::POUTPUT); ret_sig->port_type(NetNet::POUTPUT);
ret_sig->data_type(IVL_VT_LOGIC); ret_sig->data_type(IVL_VT_LOGIC);
break; break;
@ -730,6 +732,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
/* /*
* $Log: elab_sig.cc,v $ * $Log: elab_sig.cc,v $
* Revision 1.46 2007/03/06 05:22:49 steve
* Support signed function return values.
*
* Revision 1.45 2007/02/01 05:24:08 steve * Revision 1.45 2007/02/01 05:24:08 steve
* Include type in signal create message. * Include type in signal create message.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: parse.y,v 1.229 2007/03/01 06:19:39 steve Exp $" #ident "$Id: parse.y,v 1.230 2007/03/06 05:22:49 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -2427,7 +2427,8 @@ range_opt
/* This is used to express the return type of a function. */ /* This is used to express the return type of a function. */
function_range_or_type_opt function_range_or_type_opt
: range { $$.range = $1; $$.type = PTF_REG; } : range { $$.range = $1; $$.type = PTF_REG; }
| K_signed range { $$.range = $2; $$.type = PTF_REG_S; }
| K_integer { $$.range = 0; $$.type = PTF_INTEGER; } | K_integer { $$.range = 0; $$.type = PTF_INTEGER; }
| K_real { $$.range = 0; $$.type = PTF_REAL; } | K_real { $$.range = 0; $$.type = PTF_REAL; }
| K_realtime { $$.range = 0; $$.type = PTF_REALTIME; } | K_realtime { $$.range = 0; $$.type = PTF_REALTIME; }

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: expression.c,v 1.3 2007/02/20 05:58:36 steve Exp $" #ident "$Id: expression.c,v 1.4 2007/03/06 05:22:49 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -77,10 +77,11 @@ static void show_binary_expression(ivl_expr_t net, unsigned ind)
static void show_function_call(ivl_expr_t net, unsigned ind) static void show_function_call(ivl_expr_t net, unsigned ind)
{ {
ivl_scope_t def = ivl_expr_def(net); ivl_scope_t def = ivl_expr_def(net);
const char*sign = ivl_expr_signed(net)? "signed" : "unsigned";
const char*vt = vt_type_string(net); const char*vt = vt_type_string(net);
fprintf(out, "%*s<%s function %s>\n", ind, "", fprintf(out, "%*s<%s %s function %s>\n", ind, "",
vt, ivl_scope_name(def)); vt, sign, ivl_scope_name(def));
} }
static void show_memory_expression(ivl_expr_t net, unsigned ind) static void show_memory_expression(ivl_expr_t net, unsigned ind)