Evaluate nb-assign r-values using elab_and_eval.

This commit is contained in:
steve 2003-09-20 06:08:53 +00:00
parent 94a71fdee8
commit 6abe797963
1 changed files with 8 additions and 29 deletions

View File

@ -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: elaborate.cc,v 1.290 2003/09/20 06:00:37 steve Exp $" #ident "$Id: elaborate.cc,v 1.291 2003/09/20 06:08:53 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -1121,46 +1121,22 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
} }
/* /*
* The l-value of a procedural assignment is a very much constrained
* expression. To wit, only identifiers, bit selects and part selects
* are allowed. I therefore can elaborate the l-value by hand, without
* the help of recursive elaboration.
*
* (For now, this does not yet support concatenation in the l-value.)
*/ */
NetProc* PAssignNB::elaborate(Design*des, NetScope*scope) const NetProc* PAssignNB::elaborate(Design*des, NetScope*scope) const
{ {
assert(scope); assert(scope);
/* Elaborate the l-value. */
NetAssign_*lv = elaborate_lval(des, scope); NetAssign_*lv = elaborate_lval(des, scope);
if (lv == 0) return 0; if (lv == 0) return 0;
assert(rval()); assert(rval());
NetExpr*rv; /* Elaborate and precalculate the r-value. */
NetExpr*rv = elab_and_eval(des, scope, rval());
/* Evaluate the rval expression if possible, otherwise just if (rv == 0)
elaborate it. */
if (verinum*val = rval()->eval_const(des, scope)) {
rv = new NetEConst(*val);
delete val;
} else if ((rv = rval()->elaborate_expr(des, scope))) {
/* OK, go on. */
} else {
/* Unable to elaborate expression. Retreat. */
return 0; return 0;
}
assert(rv);
/* Try to evaluate the expression, at least as far as possible. */
if (NetExpr*tmp = rv->eval_tree()) {
delete rv;
rv = tmp;
}
{ unsigned wid = count_lval_width(lv); { unsigned wid = count_lval_width(lv);
rv->set_width(wid); rv->set_width(wid);
@ -2632,6 +2608,9 @@ Design* elaborate(list<const char*>roots)
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.291 2003/09/20 06:08:53 steve
* Evaluate nb-assign r-values using elab_and_eval.
*
* Revision 1.290 2003/09/20 06:00:37 steve * Revision 1.290 2003/09/20 06:00:37 steve
* Evaluate gate array index constants using elab_and_eval. * Evaluate gate array index constants using elab_and_eval.
* *