Evaluate magnitude compare with real operands.
This commit is contained in:
parent
8e97a0e4d4
commit
393102d43a
75
eval_tree.cc
75
eval_tree.cc
|
|
@ -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_tree.cc,v 1.62.2.2 2005/09/04 15:41:54 steve Exp $"
|
#ident "$Id: eval_tree.cc,v 1.62.2.3 2005/09/09 02:17:08 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -215,6 +215,11 @@ NetEConst* NetEBComp::eval_eqeq_()
|
||||||
|
|
||||||
NetEConst* NetEBComp::eval_less_()
|
NetEConst* NetEBComp::eval_less_()
|
||||||
{
|
{
|
||||||
|
if (right_->expr_type() == ET_REAL)
|
||||||
|
return eval_leeq_real_(false, false);
|
||||||
|
if (left_->expr_type() == ET_REAL)
|
||||||
|
return eval_leeq_real_(false, false);
|
||||||
|
|
||||||
NetEConst*r = dynamic_cast<NetEConst*>(right_);
|
NetEConst*r = dynamic_cast<NetEConst*>(right_);
|
||||||
if (r == 0) return 0;
|
if (r == 0) return 0;
|
||||||
|
|
||||||
|
|
@ -224,9 +229,6 @@ NetEConst* NetEBComp::eval_less_()
|
||||||
return new NetEConst(result);
|
return new NetEConst(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Detect the case where the right side is greater that or
|
|
||||||
equal to the largest value the left side can possibly
|
|
||||||
have. */
|
|
||||||
if (left_->expr_width() == 0) {
|
if (left_->expr_width() == 0) {
|
||||||
cerr << get_line() << ": internal error: "
|
cerr << get_line() << ": internal error: "
|
||||||
<< "Having trouble evaluating left expression of < op."
|
<< "Having trouble evaluating left expression of < op."
|
||||||
|
|
@ -237,6 +239,9 @@ NetEConst* NetEBComp::eval_less_()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Detect the case where the right side is greater that or
|
||||||
|
equal to the largest value the left side can possibly
|
||||||
|
have. */
|
||||||
assert(left_->expr_width() > 0);
|
assert(left_->expr_width() > 0);
|
||||||
verinum lv (verinum::V1, left_->expr_width());
|
verinum lv (verinum::V1, left_->expr_width());
|
||||||
if (lv < rv) {
|
if (lv < rv) {
|
||||||
|
|
@ -269,7 +274,7 @@ NetEConst* NetEBComp::eval_less_()
|
||||||
return new NetEConst(result);
|
return new NetEConst(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetEConst* NetEBComp::eval_leeq_real_()
|
NetEConst* NetEBComp::eval_leeq_real_(bool gt_flag, bool include_eq_flag)
|
||||||
{
|
{
|
||||||
NetEConst*vtmp;
|
NetEConst*vtmp;
|
||||||
NetECReal*rtmp;
|
NetECReal*rtmp;
|
||||||
|
|
@ -318,7 +323,16 @@ NetEConst* NetEBComp::eval_leeq_real_()
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
verinum result((lv <= rv)? verinum::V1 : verinum::V0, 1);
|
/* This function supports < and <=. If the eq_flag is true,
|
||||||
|
then include <=. Otherwise, include only <. */
|
||||||
|
bool flag;
|
||||||
|
if (gt_flag)
|
||||||
|
flag = include_eq_flag? (lv >= rv) : (lv > rv);
|
||||||
|
else
|
||||||
|
flag = include_eq_flag? (lv <= rv) : (lv < rv);
|
||||||
|
|
||||||
|
|
||||||
|
verinum result(flag? verinum::V1 : verinum::V0, 1);
|
||||||
vtmp = new NetEConst(result);
|
vtmp = new NetEConst(result);
|
||||||
vtmp->set_line(*this);
|
vtmp->set_line(*this);
|
||||||
|
|
||||||
|
|
@ -328,9 +342,9 @@ NetEConst* NetEBComp::eval_leeq_real_()
|
||||||
NetEConst* NetEBComp::eval_leeq_()
|
NetEConst* NetEBComp::eval_leeq_()
|
||||||
{
|
{
|
||||||
if (right_->expr_type() == ET_REAL)
|
if (right_->expr_type() == ET_REAL)
|
||||||
return eval_leeq_real_();
|
return eval_leeq_real_(false, true);
|
||||||
if (left_->expr_type() == ET_REAL)
|
if (left_->expr_type() == ET_REAL)
|
||||||
return eval_leeq_real_();
|
return eval_leeq_real_(false, true);
|
||||||
|
|
||||||
NetEConst*r = dynamic_cast<NetEConst*>(right_);
|
NetEConst*r = dynamic_cast<NetEConst*>(right_);
|
||||||
if (r == 0) return 0;
|
if (r == 0) return 0;
|
||||||
|
|
@ -384,23 +398,10 @@ NetEConst* NetEBComp::eval_leeq_()
|
||||||
|
|
||||||
NetEConst* NetEBComp::eval_gt_()
|
NetEConst* NetEBComp::eval_gt_()
|
||||||
{
|
{
|
||||||
if ((left_->expr_type() == NetExpr::ET_REAL)
|
if (right_->expr_type() == ET_REAL)
|
||||||
&& (right_->expr_type() == NetExpr::ET_REAL)) {
|
return eval_leeq_real_(true, false);
|
||||||
|
if (left_->expr_type() == ET_REAL)
|
||||||
NetECReal*tmpl = dynamic_cast<NetECReal*>(left_);
|
return eval_leeq_real_(true, false);
|
||||||
if (tmpl == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
NetECReal*tmpr = dynamic_cast<NetECReal*>(right_);
|
|
||||||
if (tmpr == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
double ll = tmpl->value().as_double();
|
|
||||||
double rr = tmpr->value().as_double();
|
|
||||||
|
|
||||||
verinum result ((ll > rr)? verinum::V1 : verinum::V0, 1, true);
|
|
||||||
return new NetEConst(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetEConst*l = dynamic_cast<NetEConst*>(left_);
|
NetEConst*l = dynamic_cast<NetEConst*>(left_);
|
||||||
if (l == 0) return 0;
|
if (l == 0) return 0;
|
||||||
|
|
@ -460,23 +461,10 @@ NetEConst* NetEBComp::eval_gt_()
|
||||||
|
|
||||||
NetEConst* NetEBComp::eval_gteq_()
|
NetEConst* NetEBComp::eval_gteq_()
|
||||||
{
|
{
|
||||||
if ((left_->expr_type() == NetExpr::ET_REAL)
|
if (right_->expr_type() == ET_REAL)
|
||||||
&& (right_->expr_type() == NetExpr::ET_REAL)) {
|
return eval_leeq_real_(true, true);
|
||||||
|
if (left_->expr_type() == ET_REAL)
|
||||||
NetECReal*tmpl = dynamic_cast<NetECReal*>(left_);
|
return eval_leeq_real_(true, true);
|
||||||
if (tmpl == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
NetECReal*tmpr = dynamic_cast<NetECReal*>(right_);
|
|
||||||
if (tmpr == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
double ll = tmpl->value().as_double();
|
|
||||||
double rr = tmpr->value().as_double();
|
|
||||||
|
|
||||||
verinum result ((ll >= rr)? verinum::V1 : verinum::V0, 1, true);
|
|
||||||
return new NetEConst(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetEConst*l = dynamic_cast<NetEConst*>(left_);
|
NetEConst*l = dynamic_cast<NetEConst*>(left_);
|
||||||
if (l == 0) return 0;
|
if (l == 0) return 0;
|
||||||
|
|
@ -1561,6 +1549,9 @@ NetEConst* NetEUReduce::eval_tree()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: eval_tree.cc,v $
|
* $Log: eval_tree.cc,v $
|
||||||
|
* Revision 1.62.2.3 2005/09/09 02:17:08 steve
|
||||||
|
* Evaluate magnitude compare with real operands.
|
||||||
|
*
|
||||||
* Revision 1.62.2.2 2005/09/04 15:41:54 steve
|
* Revision 1.62.2.2 2005/09/04 15:41:54 steve
|
||||||
* More explicit internal error message.
|
* More explicit internal error message.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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.321.2.3 2005/08/22 01:00:41 steve Exp $"
|
#ident "$Id: netlist.h,v 1.321.2.4 2005/09/09 02:17:08 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -2533,7 +2533,7 @@ class NetEBComp : public NetEBinary {
|
||||||
NetEConst*eval_eqeq_();
|
NetEConst*eval_eqeq_();
|
||||||
NetEConst*eval_less_();
|
NetEConst*eval_less_();
|
||||||
NetEConst*eval_leeq_();
|
NetEConst*eval_leeq_();
|
||||||
NetEConst*eval_leeq_real_();
|
NetEConst*eval_leeq_real_(bool gt_flag, bool include_eq_flag);
|
||||||
NetEConst*eval_gt_();
|
NetEConst*eval_gt_();
|
||||||
NetEConst*eval_gteq_();
|
NetEConst*eval_gteq_();
|
||||||
NetEConst*eval_neeq_();
|
NetEConst*eval_neeq_();
|
||||||
|
|
@ -3367,6 +3367,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: netlist.h,v $
|
* $Log: netlist.h,v $
|
||||||
|
* Revision 1.321.2.4 2005/09/09 02:17:08 steve
|
||||||
|
* Evaluate magnitude compare with real operands.
|
||||||
|
*
|
||||||
* Revision 1.321.2.3 2005/08/22 01:00:41 steve
|
* Revision 1.321.2.3 2005/08/22 01:00:41 steve
|
||||||
* Add support for implicit defaults in case and conditions.
|
* Add support for implicit defaults in case and conditions.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue