Handle unary minus of real valued expressions.

This commit is contained in:
steve 2007-02-20 05:58:36 +00:00
parent 2c32a81d91
commit 1f54f128c1
5 changed files with 64 additions and 9 deletions

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: netlist.cc,v 1.253 2007/02/14 05:59:46 steve Exp $" #ident "$Id: netlist.cc,v 1.254 2007/02/20 05:58:36 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -2105,6 +2105,11 @@ NetEUnary::~NetEUnary()
delete expr_; delete expr_;
} }
ivl_variable_type_t NetEUnary::expr_type() const
{
return expr_->expr_type();
}
NetEUBits::NetEUBits(char op, NetExpr*ex) NetEUBits::NetEUBits(char op, NetExpr*ex)
: NetEUnary(op, ex) : NetEUnary(op, ex)
{ {
@ -2114,6 +2119,11 @@ NetEUBits::~NetEUBits()
{ {
} }
ivl_variable_type_t NetEUBits::expr_type() const
{
return expr_->expr_type();
}
NetEUReduce::NetEUReduce(char op, NetExpr*ex) NetEUReduce::NetEUReduce(char op, NetExpr*ex)
: NetEUnary(op, ex) : NetEUnary(op, ex)
{ {
@ -2124,6 +2134,11 @@ NetEUReduce::~NetEUReduce()
{ {
} }
ivl_variable_type_t NetEUReduce::expr_type() const
{
return expr_->expr_type();
}
NetLogic::NetLogic(NetScope*s, perm_string n, unsigned pins, NetLogic::NetLogic(NetScope*s, perm_string n, unsigned pins,
TYPE t, unsigned wid) TYPE t, unsigned wid)
: NetNode(s, n, pins), type_(t), width_(wid) : NetNode(s, n, pins), type_(t), width_(wid)
@ -2205,6 +2220,9 @@ const NetProc*NetTaskDef::proc() const
/* /*
* $Log: netlist.cc,v $ * $Log: netlist.cc,v $
* Revision 1.254 2007/02/20 05:58:36 steve
* Handle unary minus of real valued expressions.
*
* Revision 1.253 2007/02/14 05:59:46 steve * Revision 1.253 2007/02/14 05:59:46 steve
* Handle type of ternary expressions properly. * Handle type of ternary expressions properly.
* *

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: netlist.h,v 1.368 2007/02/14 05:59:46 steve Exp $" #ident "$Id: netlist.h,v 1.369 2007/02/20 05:58:36 steve Exp $"
#endif #endif
/* /*
@ -3056,6 +3056,7 @@ class NetEUnary : public NetExpr {
virtual NetEUnary* dup_expr() const; virtual NetEUnary* dup_expr() const;
virtual NetEConst* eval_tree(); virtual NetEConst* eval_tree();
virtual ivl_variable_type_t expr_type() const;
virtual NexusSet* nex_input(); virtual NexusSet* nex_input();
virtual void expr_scan(struct expr_scan_t*) const; virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
@ -3076,6 +3077,7 @@ class NetEUBits : public NetEUnary {
virtual NetNet* synthesize(Design*); virtual NetNet* synthesize(Design*);
virtual NetEConst* eval_tree(); virtual NetEConst* eval_tree();
virtual ivl_variable_type_t expr_type() const;
}; };
class NetEUReduce : public NetEUnary { class NetEUReduce : public NetEUnary {
@ -3088,7 +3090,7 @@ class NetEUReduce : public NetEUnary {
virtual NetNet* synthesize(Design*); virtual NetNet* synthesize(Design*);
virtual NetEUReduce* dup_expr() const; virtual NetEUReduce* dup_expr() const;
virtual NetEConst* eval_tree(); virtual NetEConst* eval_tree();
virtual ivl_variable_type_t expr_type() const;
}; };
/* /*
@ -3473,6 +3475,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.369 2007/02/20 05:58:36 steve
* Handle unary minus of real valued expressions.
*
* Revision 1.368 2007/02/14 05:59:46 steve * Revision 1.368 2007/02/14 05:59:46 steve
* Handle type of ternary expressions properly. * Handle type of ternary expressions properly.
* *

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: t-dll-expr.cc,v 1.45 2007/02/14 05:59:46 steve Exp $" #ident "$Id: t-dll-expr.cc,v 1.46 2007/02/20 05:58:36 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -465,7 +465,7 @@ void dll_target::expr_unary(const NetEUnary*net)
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
expr_->type_ = IVL_EX_UNARY; expr_->type_ = IVL_EX_UNARY;
expr_->value_= IVL_VT_VECTOR; expr_->value_= net->expr_type();
expr_->width_ = net->expr_width(); expr_->width_ = net->expr_width();
expr_->signed_ = net->has_sign()? 1 : 0; expr_->signed_ = net->has_sign()? 1 : 0;
expr_->u_.unary_.op_ = net->op(); expr_->u_.unary_.op_ = net->op();
@ -474,6 +474,9 @@ void dll_target::expr_unary(const NetEUnary*net)
/* /*
* $Log: t-dll-expr.cc,v $ * $Log: t-dll-expr.cc,v $
* Revision 1.46 2007/02/20 05:58:36 steve
* Handle unary minus of real valued expressions.
*
* Revision 1.45 2007/02/14 05:59:46 steve * Revision 1.45 2007/02/14 05:59:46 steve
* Handle type of ternary expressions properly. * Handle type of ternary expressions properly.
* *

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.2 2007/02/14 05:57:51 steve Exp $" #ident "$Id: expression.c,v 1.3 2007/02/20 05:58:36 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -238,8 +238,8 @@ void show_expression(ivl_expr_t net, unsigned ind)
break; break;
case IVL_EX_UNARY: case IVL_EX_UNARY:
fprintf(out, "%*s<unary \"%c\" width=%u, %s>\n", ind, "", fprintf(out, "%*s<unary \"%c\" width=%u, %s, type=%s>\n", ind, "",
ivl_expr_opcode(net), width, sign); ivl_expr_opcode(net), width, sign, vt);
show_expression(ivl_expr_oper1(net), ind+4); show_expression(ivl_expr_oper1(net), ind+4);
break; break;

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: eval_real.c,v 1.18 2007/02/14 05:59:46 steve Exp $" #ident "$Id: eval_real.c,v 1.19 2007/02/20 05:58:36 steve Exp $"
#endif #endif
/* /*
@ -331,6 +331,28 @@ static int draw_ternary_real(ivl_expr_t exp)
return res; return res;
} }
static int draw_unary_real(ivl_expr_t exp)
{
ivl_expr_t sube = ivl_expr_oper1(exp);
int sub = draw_eval_real(sube);
if (ivl_expr_opcode(exp) == '+')
return sub;
if (ivl_expr_opcode(exp) == '-') {
int res = allocate_word();
fprintf(vvp_out, " %%loadi/wr %d, 0, 0; load 0.0\n", res);
fprintf(vvp_out, " %%sub/wr %d, %d;\n", res, sub);
clr_word(sub);
return res;
}
fprintf(vvp_out, "; XXXX unary (%c)\n", ivl_expr_opcode(exp));
fprintf(stderr, "XXXX evaluate unary (%c)\n", ivl_expr_opcode(exp));
return 0;
}
int draw_eval_real(ivl_expr_t exp) int draw_eval_real(ivl_expr_t exp)
{ {
int res = 0; int res = 0;
@ -365,6 +387,10 @@ int draw_eval_real(ivl_expr_t exp)
res = draw_ufunc_real(exp); res = draw_ufunc_real(exp);
break; break;
case IVL_EX_UNARY:
res = draw_unary_real(exp);
break;
default: default:
if (ivl_expr_value(exp) == IVL_VT_VECTOR) { if (ivl_expr_value(exp) == IVL_VT_VECTOR) {
struct vector_info sv = draw_eval_expr(exp, 0); struct vector_info sv = draw_eval_expr(exp, 0);
@ -393,6 +419,9 @@ int draw_eval_real(ivl_expr_t exp)
/* /*
* $Log: eval_real.c,v $ * $Log: eval_real.c,v $
* Revision 1.19 2007/02/20 05:58:36 steve
* Handle unary minus of real valued expressions.
*
* Revision 1.18 2007/02/14 05:59:46 steve * Revision 1.18 2007/02/14 05:59:46 steve
* Handle type of ternary expressions properly. * Handle type of ternary expressions properly.
* *