From 3d646aa92cdcdf6f42300113227ff5fcfb0a424b Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 9 Mar 2002 04:02:26 +0000 Subject: [PATCH] Constant expressions are not l-values for task ports. --- PExpr.h | 7 ++++++- elab_lval.cc | 15 +++++++++++++-- elaborate.cc | 26 ++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/PExpr.h b/PExpr.h index 86e0e4df0..e9bc0036d 100644 --- a/PExpr.h +++ b/PExpr.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: PExpr.h,v 1.55 2002/03/09 02:10:22 steve Exp $" +#ident "$Id: PExpr.h,v 1.56 2002/03/09 04:02:26 steve Exp $" #endif # include @@ -275,6 +275,8 @@ class PENumber : public PExpr { Link::strength_t drive1) const; virtual NetEConst*elaborate_expr(Design*des, NetScope*) const; virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const; + virtual NetAssign_* elaborate_lval(Design*des, NetScope*scope) const; + virtual verinum* eval_const(const Design*des, const NetScope*sc) const; virtual verireal*eval_rconst(const Design*, const NetScope*) const; @@ -473,6 +475,9 @@ class PECallFunction : public PExpr { /* * $Log: PExpr.h,v $ + * Revision 1.56 2002/03/09 04:02:26 steve + * Constant expressions are not l-values for task ports. + * * Revision 1.55 2002/03/09 02:10:22 steve * Add the NetUserFunc netlist node. * diff --git a/elab_lval.cc b/elab_lval.cc index 2ab20f3f9..81fec6c0a 100644 --- a/elab_lval.cc +++ b/elab_lval.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_lval.cc,v 1.17 2001/12/03 04:47:14 steve Exp $" +#ident "$Id: elab_lval.cc,v 1.18 2002/03/09 04:02:26 steve Exp $" #endif # include "config.h" @@ -67,7 +67,7 @@ */ NetAssign_* PExpr::elaborate_lval(Design*des, NetScope*scope) const { - NetNet*ll = elaborate_net(des, scope, 0, 0, 0, 0); + NetNet*ll = 0; //XXXXelaborate_net(des, scope, 0, 0, 0, 0); if (ll == 0) { cerr << get_line() << ": Assignment l-value too complex." << endl; @@ -275,8 +275,19 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, NetScope*scope) const return lv; } +NetAssign_* PENumber::elaborate_lval(Design*des, NetScope*) const +{ + cerr << get_line() << ": error: Constant values not allowed " + << "in l-value expressions." << endl; + des->errors += 1; + return 0; +} + /* * $Log: elab_lval.cc,v $ + * Revision 1.18 2002/03/09 04:02:26 steve + * Constant expressions are not l-values for task ports. + * * Revision 1.17 2001/12/03 04:47:14 steve * Parser and pform use hierarchical names as hname_t * objects instead of encoded strings. diff --git a/elaborate.cc b/elaborate.cc index cfb1bd440..494031550 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: elaborate.cc,v 1.240 2002/01/23 05:56:22 steve Exp $" +#ident "$Id: elaborate.cc,v 1.241 2002/03/09 04:02:26 steve Exp $" #endif # include "config.h" @@ -1487,9 +1487,24 @@ NetProc* PCallTask::elaborate_usr(Design*des, NetScope*scope) const } - NetAssign_*lv = parms_[idx] - ? parms_[idx]->elaborate_lval(des, scope) - : 0; + /* Elaborate an l-value version of the port expression + for output and inout ports. If the expression does + not exist then quietly skip it, but if the expression + is not a valid l-value print an error message. Note + that the elaborate_lval method already printed a + detailed message. */ + NetAssign_*lv; + if (parms_[idx]) { + lv = parms_[idx]->elaborate_lval(des, scope); + if (lv == 0) { + cerr << parms_[idx]->get_line() << ": error: " + << "I give up on task port " << (idx+1) + << " expression: " << *parms_[idx] << endl; + } + } else { + lv = 0; + } + if (lv == 0) continue; @@ -2408,6 +2423,9 @@ Design* elaborate(listroots) /* * $Log: elaborate.cc,v $ + * Revision 1.241 2002/03/09 04:02:26 steve + * Constant expressions are not l-values for task ports. + * * Revision 1.240 2002/01/23 05:56:22 steve * elaborate deassign lval as done for assign. *