Support parameters that reference other paramters.
This commit is contained in:
parent
3a5e55b229
commit
349f9ae302
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: design_dump.cc,v 1.42 1999/09/20 02:21:10 steve Exp $"
|
||||
#ident "$Id: design_dump.cc,v 1.43 1999/09/21 00:13:40 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -605,9 +605,17 @@ void NetEConcat::dump(ostream&o) const
|
|||
if (repeat_ != 1)
|
||||
o << repeat_;
|
||||
|
||||
o << "{" << *parms_[0];
|
||||
for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1)
|
||||
o << ", " << *parms_[idx];
|
||||
if (parms_[0])
|
||||
o << "{" << *parms_[0];
|
||||
else
|
||||
o << "{";
|
||||
|
||||
for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
|
||||
if (parms_[idx])
|
||||
o << ", " << *parms_[idx];
|
||||
else
|
||||
o << ", ";
|
||||
}
|
||||
o << "}";
|
||||
}
|
||||
|
||||
|
|
@ -753,6 +761,9 @@ void Design::dump(ostream&o) const
|
|||
|
||||
/*
|
||||
* $Log: design_dump.cc,v $
|
||||
* Revision 1.43 1999/09/21 00:13:40 steve
|
||||
* Support parameters that reference other paramters.
|
||||
*
|
||||
* Revision 1.42 1999/09/20 02:21:10 steve
|
||||
* Elaborate parameters in phases.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: elab_expr.cc,v 1.1 1999/09/20 02:21:10 steve Exp $"
|
||||
#ident "$Id: elab_expr.cc,v 1.2 1999/09/21 00:13:40 steve Exp $"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, const string&path) const
|
|||
if (dynamic_cast<const NetExpr*>(ex))
|
||||
tmp = ex->dup_expr();
|
||||
else
|
||||
tmp = new NetEParam(path, text_);
|
||||
tmp = new NetEParam(des, path, text_);
|
||||
|
||||
tmp->set_line(*this);
|
||||
return tmp;
|
||||
|
|
@ -150,6 +150,9 @@ NetExpr* PEIdent::elaborate_expr(Design*des, const string&path) const
|
|||
|
||||
/*
|
||||
* $Log: elab_expr.cc,v $
|
||||
* Revision 1.2 1999/09/21 00:13:40 steve
|
||||
* Support parameters that reference other paramters.
|
||||
*
|
||||
* Revision 1.1 1999/09/20 02:21:10 steve
|
||||
* Elaborate parameters in phases.
|
||||
*
|
||||
|
|
|
|||
47
eval_tree.cc
47
eval_tree.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: eval_tree.cc,v 1.1 1999/09/20 02:21:10 steve Exp $"
|
||||
#ident "$Id: eval_tree.cc,v 1.2 1999/09/21 00:13:40 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "netlist.h"
|
||||
|
|
@ -109,10 +109,20 @@ NetExpr* NetEBComp::eval_tree()
|
|||
NetExpr* NetEConcat::eval_tree()
|
||||
{
|
||||
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) {
|
||||
// If this parameter is already a constant, go on.
|
||||
|
||||
// Parameter not here? This is an error, but presumably
|
||||
// already caught and we are here just to catch more.
|
||||
if (parms_[idx] == 0)
|
||||
continue;
|
||||
|
||||
// If this parameter is already a constant, all is well
|
||||
// so go on.
|
||||
if (dynamic_cast<NetEConst*>(parms_[idx]))
|
||||
continue;
|
||||
|
||||
// Finally, try to evaluate the parameter expression
|
||||
// that is here. If I succeed, reset the parameter to
|
||||
// the evaluated value.
|
||||
assert(parms_[idx]);
|
||||
NetExpr*expr = parms_[idx]->eval_tree();
|
||||
if (expr) {
|
||||
|
|
@ -144,8 +154,41 @@ NetExpr* NetEConcat::eval_tree()
|
|||
return res;
|
||||
}
|
||||
|
||||
NetExpr* NetEParam::eval_tree()
|
||||
{
|
||||
if (des_ == 0)
|
||||
return 0;
|
||||
|
||||
const NetExpr*expr = des_->find_parameter(path_, name_);
|
||||
assert(expr);
|
||||
|
||||
NetExpr*nexpr = expr->dup_expr();
|
||||
assert(nexpr);
|
||||
|
||||
// If the parameter that I refer to is already evaluated, then
|
||||
// return the constant value.
|
||||
if (dynamic_cast<NetEConst*>(nexpr))
|
||||
return nexpr;
|
||||
|
||||
// Try to evaluate the expression. If I cannot, then the
|
||||
// expression is not a constant expression and I fail here.
|
||||
NetExpr*res = nexpr->eval_tree();
|
||||
if (res == 0) {
|
||||
delete nexpr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The result can be saved as the value of the parameter for
|
||||
// future reference, and return a copy to the caller.
|
||||
des_->set_parameter(path_+"."+name_, res);
|
||||
return res->dup_expr();
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: eval_tree.cc,v $
|
||||
* Revision 1.2 1999/09/21 00:13:40 steve
|
||||
* Support parameters that reference other paramters.
|
||||
*
|
||||
* Revision 1.1 1999/09/20 02:21:10 steve
|
||||
* Elaborate parameters in phases.
|
||||
*
|
||||
|
|
|
|||
10
netlist.cc
10
netlist.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: netlist.cc,v 1.66 1999/09/20 02:21:10 steve Exp $"
|
||||
#ident "$Id: netlist.cc,v 1.67 1999/09/21 00:13:40 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <cassert>
|
||||
|
|
@ -1061,11 +1061,12 @@ NetEMemory* NetEMemory::dup_expr() const
|
|||
}
|
||||
|
||||
NetEParam::NetEParam()
|
||||
: des_(0)
|
||||
{
|
||||
}
|
||||
|
||||
NetEParam::NetEParam(const string&p, const string&n)
|
||||
: path_(p), name_(n)
|
||||
NetEParam::NetEParam(Design*d, const string&p, const string&n)
|
||||
: des_(d), path_(p), name_(n)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1818,6 +1819,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
|
|||
|
||||
/*
|
||||
* $Log: netlist.cc,v $
|
||||
* Revision 1.67 1999/09/21 00:13:40 steve
|
||||
* Support parameters that reference other paramters.
|
||||
*
|
||||
* Revision 1.66 1999/09/20 02:21:10 steve
|
||||
* Elaborate parameters in phases.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: netlist.h,v 1.67 1999/09/20 02:21:10 steve Exp $"
|
||||
#ident "$Id: netlist.h,v 1.68 1999/09/21 00:13:40 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -1288,16 +1288,18 @@ class NetEConst : public NetExpr {
|
|||
class NetEParam : public NetExpr {
|
||||
public:
|
||||
NetEParam();
|
||||
NetEParam(const string&path, const string&name);
|
||||
NetEParam(class Design*des, const string&path, const string&name);
|
||||
~NetEParam();
|
||||
|
||||
virtual bool set_width(unsigned w);
|
||||
virtual void expr_scan(struct expr_scan_t*) const;
|
||||
virtual NetExpr* eval_tree();
|
||||
virtual NetEParam* dup_expr() const;
|
||||
|
||||
virtual void dump(ostream&) const;
|
||||
|
||||
private:
|
||||
Design*des_;
|
||||
string path_;
|
||||
string name_;
|
||||
};
|
||||
|
|
@ -1611,6 +1613,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
|||
|
||||
/*
|
||||
* $Log: netlist.h,v $
|
||||
* Revision 1.68 1999/09/21 00:13:40 steve
|
||||
* Support parameters that reference other paramters.
|
||||
*
|
||||
* Revision 1.67 1999/09/20 02:21:10 steve
|
||||
* Elaborate parameters in phases.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue