From a3eb6868eac60fc042de922fc3bf7a5742729e0f Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 6 May 2002 02:30:27 +0000 Subject: [PATCH] Allow parameters in concatenation of widths are defined. --- elab_expr.cc | 7 +++++-- elab_pexpr.cc | 12 ++++++++++-- eval_tree.cc | 17 ++++++++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index 08e09977f..ff12ee23f 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -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.58 2002/05/05 21:11:49 steve Exp $" +#ident "$Id: elab_expr.cc,v 1.59 2002/05/06 02:30:27 steve Exp $" #endif # include "config.h" @@ -373,7 +373,7 @@ NetExpr* PEConcat::elaborate_expr(Design*des, NetScope*scope, bool) const /* Elaborate all the parameters and attach them to the concat node. */ for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { assert(parms_[idx]); - NetExpr*ex = parms_[idx]->elaborate_expr(des, scope); + NetExpr*ex = elab_and_eval(des, scope, parms_[idx]); if (ex == 0) continue; ex->set_line(*parms_[idx]); @@ -864,6 +864,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const /* * $Log: elab_expr.cc,v $ + * Revision 1.59 2002/05/06 02:30:27 steve + * Allow parameters in concatenation of widths are defined. + * * Revision 1.58 2002/05/05 21:11:49 steve * Put off evaluation of concatenation repeat expresions * until after parameters are defined. This allows parms diff --git a/elab_pexpr.cc b/elab_pexpr.cc index 0c41b1ff4..bc851a43e 100644 --- a/elab_pexpr.cc +++ b/elab_pexpr.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: elab_pexpr.cc,v 1.14 2002/05/05 21:11:50 steve Exp $" +#ident "$Id: elab_pexpr.cc,v 1.15 2002/05/06 02:30:27 steve Exp $" #endif # include "config.h" @@ -97,7 +97,12 @@ NetEConcat* PEConcat::elaborate_pexpr(Design*des, NetScope*scope) const ex->set_line(*parms_[idx]); - if (! ex->has_width()) { + if (dynamic_cast(ex)) { + + /* If this parameter is a NetEParam, then put off + the width check for later. */ + + } else if (! ex->has_width()) { cerr << ex->get_line() << ": error: operand of " << "concatenation has indefinite width: " << *ex << endl; @@ -217,6 +222,9 @@ NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const /* * $Log: elab_pexpr.cc,v $ + * Revision 1.15 2002/05/06 02:30:27 steve + * Allow parameters in concatenation of widths are defined. + * * Revision 1.14 2002/05/05 21:11:50 steve * Put off evaluation of concatenation repeat expresions * until after parameters are defined. This allows parms diff --git a/eval_tree.cc b/eval_tree.cc index eaed243e7..c59f162be 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -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.38 2002/05/05 21:11:50 steve Exp $" +#ident "$Id: eval_tree.cc,v 1.39 2002/05/06 02:30:27 steve Exp $" #endif # include "config.h" @@ -706,6 +706,7 @@ NetEConst* NetEBShift::eval_tree() NetEConst* NetEConcat::eval_tree() { unsigned repeat_val = repeat(); + unsigned local_errors = 0; unsigned gap = 0; for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) { @@ -731,10 +732,21 @@ NetEConst* NetEConcat::eval_tree() if (expr) { delete parms_[idx]; parms_[idx] = expr; + + if (! expr->has_width()) { + cerr << get_line() << ": error: concatenation " + << "operand has indefinite width: " + << *parms_[idx] << endl; + local_errors += 1; + } gap += expr->expr_width(); } + } + if (local_errors > 0) + return 0; + // Handle the special case that the repeat expression is // zero. In this case, just return a 0 value with the expected // width. @@ -1086,6 +1098,9 @@ NetEConst* NetEUReduce::eval_tree() /* * $Log: eval_tree.cc,v $ + * Revision 1.39 2002/05/06 02:30:27 steve + * Allow parameters in concatenation of widths are defined. + * * Revision 1.38 2002/05/05 21:11:50 steve * Put off evaluation of concatenation repeat expresions * until after parameters are defined. This allows parms