Comparison operators do have defined width.

This commit is contained in:
steve 2003-03-15 18:08:43 +00:00
parent 7a752bd111
commit c602d94cef
4 changed files with 74 additions and 54 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: dup_expr.cc,v 1.12 2003/03/15 04:46:28 steve Exp $"
#ident "$Id: dup_expr.cc,v 1.13 2003/03/15 18:08:43 steve Exp $"
#endif
# include "config.h"
@ -25,6 +25,13 @@
# include "netlist.h"
# include <cassert>
NetEBComp* NetEBComp::dup_expr() const
{
NetEBComp*result = new NetEBComp(op_, left_->dup_expr(),
right_->dup_expr());
return result;
}
NetEConst* NetEConst::dup_expr() const
{
NetEConst*tmp = new NetEConst(value_);
@ -109,6 +116,9 @@ NetEVariable* NetEVariable::dup_expr() const
/*
* $Log: dup_expr.cc,v $
* Revision 1.13 2003/03/15 18:08:43 steve
* Comparison operators do have defined width.
*
* Revision 1.12 2003/03/15 04:46:28 steve
* Better organize the NetESFunc return type guesses.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: net_expr.cc,v 1.15 2003/03/15 04:46:29 steve Exp $"
#ident "$Id: net_expr.cc,v 1.16 2003/03/15 18:08:43 steve Exp $"
#endif
# include "config.h"
@ -107,6 +107,54 @@ NetExpr::TYPE NetEBAdd::expr_type() const
return ET_VECTOR;
}
/*
* Create a comparison operator with two sub-expressions.
*
* Handle the special case of an unsized constant on the left or right
* side by resizing the number to match the other
* expression. Otherwise, the netlist will have to allow the
* expressions to have different widths.
*/
NetEBComp::NetEBComp(char op, NetExpr*l, NetExpr*r)
: NetEBinary(op, l, r)
{
if (NetEConst*tmp = dynamic_cast<NetEConst*>(r)) do {
if (tmp->has_width())
break;
if (tmp->expr_width() == l->expr_width())
break;
tmp->set_width(l->expr_width());
} while (0);
if (NetEConst*tmp = dynamic_cast<NetEConst*>(l)) do {
if (tmp->has_width())
break;
if (tmp->expr_width() == r->expr_width())
break;
tmp->set_width(r->expr_width());
} while (0);
expr_width(1);
}
NetEBComp::~NetEBComp()
{
}
bool NetEBComp::has_width() const
{
return true;
}
NetEBDiv::NetEBDiv(char op, NetExpr*l, NetExpr*r)
: NetEBinary(op, l, r)
{
@ -408,6 +456,9 @@ NetExpr::TYPE NetESFunc::expr_type() const
/*
* $Log: net_expr.cc,v $
* Revision 1.16 2003/03/15 18:08:43 steve
* Comparison operators do have defined width.
*
* Revision 1.15 2003/03/15 04:46:29 steve
* Better organize the NetESFunc return type guesses.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: netlist.cc,v 1.208 2003/03/10 23:40:53 steve Exp $"
#ident "$Id: netlist.cc,v 1.209 2003/03/15 18:08:43 steve Exp $"
#endif
# include "config.h"
@ -1760,56 +1760,6 @@ NetEBBits* NetEBBits::dup_expr() const
return result;
}
/*
* Create a comparison operator with two sub-expressions.
*
* Handle the special case of an unsized constant on the left or right
* side by resizing the number to match the other
* expression. Otherwise, the netlist will have to allow the
* expressions to have different widths.
*/
NetEBComp::NetEBComp(char op, NetExpr*l, NetExpr*r)
: NetEBinary(op, l, r)
{
if (NetEConst*tmp = dynamic_cast<NetEConst*>(r)) do {
if (tmp->has_width())
break;
if (tmp->expr_width() == l->expr_width())
break;
tmp->set_width(l->expr_width());
} while (0);
if (NetEConst*tmp = dynamic_cast<NetEConst*>(l)) do {
if (tmp->has_width())
break;
if (tmp->expr_width() == r->expr_width())
break;
tmp->set_width(r->expr_width());
} while (0);
expr_width(1);
}
NetEBComp::~NetEBComp()
{
}
NetEBComp* NetEBComp::dup_expr() const
{
NetEBComp*result = new NetEBComp(op_, left_->dup_expr(),
right_->dup_expr());
return result;
}
NetEBinary::NetEBinary(char op, NetExpr*l, NetExpr*r)
: op_(op), left_(l), right_(r)
{
@ -2191,6 +2141,9 @@ const NetProc*NetTaskDef::proc() const
/*
* $Log: netlist.cc,v $
* Revision 1.209 2003/03/15 18:08:43 steve
* Comparison operators do have defined width.
*
* Revision 1.208 2003/03/10 23:40:53 steve
* Keep parameter constants for the ivl_target API.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: netlist.h,v 1.281 2003/03/15 04:46:29 steve Exp $"
#ident "$Id: netlist.h,v 1.282 2003/03/15 18:08:43 steve Exp $"
#endif
/*
@ -2428,6 +2428,9 @@ class NetEBComp : public NetEBinary {
~NetEBComp();
virtual bool set_width(unsigned w);
/* A compare expression has a definite width. */
virtual bool has_width() const;
virtual NetEBComp* dup_expr() const;
virtual NetEConst* eval_tree();
@ -3237,6 +3240,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.282 2003/03/15 18:08:43 steve
* Comparison operators do have defined width.
*
* Revision 1.281 2003/03/15 04:46:29 steve
* Better organize the NetESFunc return type guesses.
*