Port close cropping behavior from mcrgb

Move window array reset to libmc.
This commit is contained in:
steve 2001-11-19 01:54:14 +00:00
parent 659624c71f
commit cfed3933fa
4 changed files with 90 additions and 70 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: dup_expr.cc,v 1.5 2001/07/25 03:10:48 steve Exp $"
#ident "$Id: dup_expr.cc,v 1.6 2001/11/19 01:54:14 steve Exp $"
#endif
# include "config.h"
@ -34,14 +34,44 @@ NetEScope* NetEScope::dup_expr() const
NetESFunc* NetESFunc::dup_expr() const
{
NetESFunc*tmp = new NetESFunc(name_, expr_width(), nparms());
for (unsigned idx = 0 ; idx < nparms() ; idx += 1)
assert(tmp);
for (unsigned idx = 0 ; idx < nparms() ; idx += 1) {
assert(tmp->parm(idx));
tmp->parm(idx, tmp->parm(idx)->dup_expr());
}
return tmp;
}
NetESignal* NetESignal::dup_expr() const
{
NetESignal*tmp = new NetESignal(net_, msi_, lsi_);
assert(tmp);
tmp->expr_width(expr_width());
return tmp;
}
NetETernary* NetETernary::dup_expr() const
{
NetETernary*tmp = new NetETernary(cond_->dup_expr(),
true_val_->dup_expr(),
false_val_->dup_expr());
return tmp;
}
NetEUnary* NetEUnary::dup_expr() const
{
NetEUnary*tmp = new NetEUnary(op_, expr_->dup_expr());
assert(tmp);
return tmp;
}
/*
* $Log: dup_expr.cc,v $
* Revision 1.6 2001/11/19 01:54:14 steve
* Port close cropping behavior from mcrgb
* Move window array reset to libmc.
*
* Revision 1.5 2001/07/25 03:10:48 steve
* Create a config.h.in file to hold all the config
* junk, and support gcc 3.0. (Stephan Boettcher)

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elab_expr.cc,v 1.43 2001/11/07 04:01:59 steve Exp $"
#ident "$Id: elab_expr.cc,v 1.44 2001/11/19 01:54:14 steve Exp $"
#endif
# include "config.h"
@ -45,6 +45,10 @@ NetExpr* PExpr::elaborate_expr(Design*des, NetScope*) const
*/
NetEBinary* PEBinary::elaborate_expr(Design*des, NetScope*scope) const
{
assert(left_);
assert(right_);
NetExpr*lp = left_->elaborate_expr(des, scope);
NetExpr*rp = right_->elaborate_expr(des, scope);
if ((lp == 0) || (rp == 0)) {
@ -636,6 +640,10 @@ NetEUnary* PEUnary::elaborate_expr(Design*des, NetScope*scope) const
/*
* $Log: elab_expr.cc,v $
* Revision 1.44 2001/11/19 01:54:14 steve
* Port close cropping behavior from mcrgb
* Move window array reset to libmc.
*
* Revision 1.43 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: eval_tree.cc,v 1.28 2001/10/22 15:31:21 steve Exp $"
#ident "$Id: eval_tree.cc,v 1.29 2001/11/19 01:54:14 steve Exp $"
#endif
# include "config.h"
@ -807,48 +807,49 @@ NetExpr* NetETernary::eval_tree()
{
NetExpr*tmp;
/* Evaluate the cond_ to a constant. If it already is a
constant, then there is nothing to do. */
assert(cond_);
if (0 == dynamic_cast<NetEConst*>(cond_)) {
tmp = cond_->eval_tree();
if (tmp != 0) {
delete cond_;
cond_ = tmp;
}
}
assert(true_val_);
if (0 == dynamic_cast<NetEConst*>(true_val_)) {
tmp = true_val_->eval_tree();
if (tmp != 0) {
delete true_val_;
true_val_ = tmp;
}
}
assert(false_val_);
if (0 == dynamic_cast<NetEConst*>(false_val_)) {
tmp = false_val_->eval_tree();
if (tmp != 0) {
delete false_val_;
false_val_ = tmp;
}
}
NetEConst*c = dynamic_cast<NetEConst*>(cond_);
if (c == 0) {
tmp = cond_->eval_tree();
c = dynamic_cast<NetEConst*>(tmp);
if (c == 0)
return 0;
if (c == 0)
return 0;
assert(cond_ != c);
delete cond_;
cond_ = c;
}
/* If the condition is 1 or 0, return the true or false
expression. Try to evaluate the expression down as far as
we can. */
if (c->value().get(0) == verinum::V1) {
tmp = dynamic_cast<NetEConst*>(true_val_);
if (tmp) return tmp->dup_expr();
tmp = true_val_->eval_tree();
if (tmp) {
delete true_val_;
true_val_ = tmp;
}
if (c->value().get(0) == verinum::V1)
return true_val_->dup_expr();
}
if (c->value().get(0) == verinum::V0) {
tmp = dynamic_cast<NetEConst*>(false_val_);
if (tmp) return tmp->dup_expr();
tmp = false_val_->eval_tree();
if (tmp) {
delete false_val_;
false_val_ = tmp;
}
if (c->value().get(0) == verinum::V0)
return false_val_->dup_expr();
}
/* Here we have a more complex case. We need to evaluate both
@ -856,27 +857,14 @@ NetExpr* NetETernary::eval_tree()
build up a constant result. */
NetEConst*t = dynamic_cast<NetEConst*>(true_val_);
if (t == 0) {
tmp = true_val_->eval_tree();
t = dynamic_cast<NetEConst*>(tmp);
if (t == 0)
return 0;
delete true_val_;
true_val_ = t;
}
if (t == 0)
return 0;
NetEConst*f = dynamic_cast<NetEConst*>(false_val_);
if (f == 0) {
tmp = false_val_->eval_tree();
f = dynamic_cast<NetEConst*>(tmp);
if (f == 0)
return 0;
if (f == 0)
return 0;
delete false_val_;
false_val_ = f;
}
unsigned size = t->expr_width();
assert(size == f->expr_width());
@ -899,6 +887,7 @@ NetExpr* NetETernary::eval_tree()
void NetEUnary::eval_expr_()
{
assert(expr_);
if (dynamic_cast<NetEConst*>(expr_))
return;
@ -942,7 +931,6 @@ NetEConst* NetEUnary::eval_tree()
}
default:
delete rval;
return 0;
}
}
@ -1013,6 +1001,10 @@ NetEConst* NetEUReduce::eval_tree()
/*
* $Log: eval_tree.cc,v $
* Revision 1.29 2001/11/19 01:54:14 steve
* Port close cropping behavior from mcrgb
* Move window array reset to libmc.
*
* Revision 1.28 2001/10/22 15:31:21 steve
* fix constant overrun in | operands.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.cc,v 1.175 2001/11/06 04:32:37 steve Exp $"
#ident "$Id: netlist.cc,v 1.176 2001/11/19 01:54:14 steve Exp $"
#endif
# include "config.h"
@ -2033,8 +2033,9 @@ NetEConcat* NetEConcat::dup_expr() const
NetEConcat*dup = new NetEConcat(parms_.count(), repeat_);
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
if (parms_[idx]) {
assert(parms_[idx]->dup_expr());
dup->parms_[idx] = parms_[idx]->dup_expr();
NetExpr*tmp = parms_[idx]->dup_expr();
assert(tmp);
dup->parms_[idx] = tmp;
}
@ -2251,11 +2252,6 @@ Link& NetESignal::bit(unsigned idx)
return net_->pin(idx + lsi_);
}
NetESignal* NetESignal::dup_expr() const
{
assert(0);
}
const NetNet* NetESignal::sig() const
{
return net_;
@ -2327,11 +2323,6 @@ const NetExpr* NetETernary::false_expr() const
return false_val_;
}
NetETernary* NetETernary::dup_expr() const
{
assert(0);
}
NetEUnary::NetEUnary(char op, NetExpr*ex)
: NetExpr(ex->expr_width()), op_(op), expr_(ex)
{
@ -2342,11 +2333,6 @@ NetEUnary::~NetEUnary()
delete expr_;
}
NetEUnary* NetEUnary::dup_expr() const
{
assert(0);
}
NetEUBits::NetEUBits(char op, NetExpr*ex)
: NetEUnary(op, ex)
{
@ -2416,6 +2402,10 @@ const NetProc*NetTaskDef::proc() const
/*
* $Log: netlist.cc,v $
* Revision 1.176 2001/11/19 01:54:14 steve
* Port close cropping behavior from mcrgb
* Move window array reset to libmc.
*
* Revision 1.175 2001/11/06 04:32:37 steve
* shift expressions can have definite widths.
*