eval_const uses scope instead of a string path.

This commit is contained in:
steve 2001-11-07 04:01:59 +00:00
parent fa23dafdae
commit bf72f39fe9
10 changed files with 87 additions and 310 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: PDelays.cc,v 1.5 2001/07/25 03:10:48 steve Exp $"
#ident "$Id: PDelays.cc,v 1.6 2001/11/07 04:01:59 steve Exp $"
#endif
# include "config.h"
@ -69,7 +69,7 @@ static unsigned long calculate_val(Design*des, const NetScope*scope,
delete dr;
} else {
verinum*dv = expr->eval_const(des, scope->name());
verinum*dv = expr->eval_const(des, scope);
if (dv == 0) {
cerr << expr->get_line() << ": sorry: non-constant "
<< "delays not supported here: " << *expr << endl;
@ -126,6 +126,9 @@ void PDelays::eval_delays(Design*des, const string&path,
/*
* $Log: PDelays.cc,v $
* Revision 1.6 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* 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)

196
PExpr.h
View File

@ -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.49 2001/11/06 06:11:55 steve Exp $"
#ident "$Id: PExpr.h,v 1.50 2001/11/07 04:01:59 steve Exp $"
#endif
# include <string>
@ -86,7 +86,7 @@ class PExpr : public LineInfo {
// This attempts to evaluate a constant expression, and return
// a verinum as a result. If the expression cannot be
// evaluated, return 0.
virtual verinum* eval_const(const Design*des, const string&path) const;
virtual verinum* eval_const(const Design*des, const NetScope*sc) const;
// This attempts to evaluate a constant expression as a
// decimal floating point. This is used when calculating delay
@ -182,7 +182,7 @@ class PEFNumber : public PExpr {
/* The eval_const method as applied to a floating point number
gets the *integer* value of the number. This accounts for
any rounding that is needed to get the value. */
virtual verinum* eval_const(const Design*des, const string&path) const;
virtual verinum* eval_const(const Design*des, const NetScope*sc) const;
/* This method returns the full floating point value. */
virtual verireal* eval_rconst(const Design*, const NetScope*) const;
@ -233,7 +233,7 @@ class PEIdent : public PExpr {
NetNet* elaborate_port(Design*des, NetScope*sc) const;
virtual bool is_constant(Module*) const;
verinum* eval_const(const Design*des, const string&path) const;
verinum* eval_const(const Design*des, const NetScope*sc) const;
verireal*eval_rconst(const Design*des, const NetScope*sc) const;
string name() const;
@ -275,7 +275,7 @@ 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 verinum* eval_const(const Design*des, const string&path) const;
virtual verinum* eval_const(const Design*des, const NetScope*sc) const;
virtual verireal*eval_rconst(const Design*, const NetScope*) const;
virtual bool is_the_same(const PExpr*that) const;
@ -318,7 +318,7 @@ class PEUnary : public PExpr {
Link::strength_t drive1) const;
virtual NetEUnary*elaborate_expr(Design*des, NetScope*) const;
virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual verinum* eval_const(const Design*des, const string&path) const;
virtual verinum* eval_const(const Design*des, const NetScope*sc) const;
virtual bool is_constant(Module*) const;
@ -345,7 +345,7 @@ class PEBinary : public PExpr {
Link::strength_t drive1) const;
virtual NetEBinary*elaborate_expr(Design*des, NetScope*) const;
virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual verinum* eval_const(const Design*des, const string&path) const;
virtual verinum* eval_const(const Design*des, const NetScope*sc) const;
virtual verireal*eval_rconst(const Design*des, const NetScope*sc) const;
private:
@ -419,7 +419,7 @@ class PETernary : public PExpr {
Link::strength_t drive1) const;
virtual NetETernary*elaborate_expr(Design*des, NetScope*) const;
virtual NetETernary*elaborate_pexpr(Design*des, NetScope*sc) const;
virtual verinum* eval_const(const Design*des, const string&path) const;
virtual verinum* eval_const(const Design*des, const NetScope*sc) const;
private:
PExpr*expr_;
@ -449,6 +449,9 @@ class PECallFunction : public PExpr {
/*
* $Log: PExpr.h,v $
* Revision 1.50 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* Revision 1.49 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*
@ -469,182 +472,5 @@ class PECallFunction : public PExpr {
*
* Revision 1.44 2000/09/17 21:26:15 steve
* Add support for modulus (Eric Aardoom)
*
* Revision 1.43 2000/09/09 15:21:26 steve
* move lval elaboration to PExpr virtual methods.
*
* Revision 1.42 2000/09/07 22:38:13 steve
* Support unary + and - in constants.
*
* Revision 1.41 2000/06/30 15:50:20 steve
* Allow unary operators in constant expressions.
*
* Revision 1.40 2000/06/13 05:22:16 steve
* Support concatenation in parameter expressions.
*
* Revision 1.39 2000/06/01 02:31:39 steve
* Parameters can be strings.
*
* Revision 1.38 2000/05/16 04:05:15 steve
* Module ports are really special PEIdent
* expressions, because a name can be used
* many places in the port list.
*
* Revision 1.37 2000/05/07 04:37:56 steve
* Carry strength values from Verilog source to the
* pform and netlist for gates.
*
* Change vvm constants to use the driver_t to drive
* a constant value. This works better if there are
* multiple drivers on a signal.
*
* Revision 1.36 2000/05/04 03:37:58 steve
* Add infrastructure for system functions, move
* $time to that structure and add $random.
*
* Revision 1.35 2000/04/12 04:23:57 steve
* Named events really should be expressed with PEIdent
* objects in the pform,
*
* Handle named events within the mix of net events
* and edges. As a unified lot they get caught together.
* wait statements are broken into more complex statements
* that include a conditional.
*
* Do not generate NetPEvent or NetNEvent objects in
* elaboration. NetEvent, NetEvWait and NetEvProbe
* take over those functions in the netlist.
*
* Revision 1.34 2000/04/01 21:40:22 steve
* Add support for integer division.
*
* Revision 1.33 2000/04/01 19:31:57 steve
* Named events as far as the pform.
*
* Revision 1.32 2000/03/12 18:22:11 steve
* Binary and unary operators in parameter expressions.
*
* Revision 1.31 2000/03/12 04:35:22 steve
* Allow parameter identifiers in parameter expressions.
*
* Revision 1.30 2000/03/08 04:36:53 steve
* Redesign the implementation of scopes and parameters.
* I now generate the scopes and notice the parameters
* in a separate pass over the pform. Once the scopes
* are generated, I can process overrides and evalutate
* paremeters before elaboration begins.
*
* Revision 1.29 2000/02/23 02:56:53 steve
* Macintosh compilers do not support ident.
*
* Revision 1.28 2000/02/16 03:58:27 steve
* Fix up width matching in structural bitwise operators.
*
* Revision 1.27 2000/01/13 03:35:35 steve
* Multiplication all the way to simulation.
*
* Revision 1.26 1999/12/16 03:46:39 steve
* Structural logical or.
*
* Revision 1.25 1999/11/21 00:13:08 steve
* Support memories in continuous assignments.
*
* Revision 1.24 1999/11/14 20:24:28 steve
* Add support for the LPM_CLSHIFT device.
*
* Revision 1.23 1999/11/05 21:45:19 steve
* Fix NetConst being set to zero width, and clean
* up elaborate_set_cmp_ for NetEBinary.
*
* Revision 1.22 1999/10/31 20:08:24 steve
* Include subtraction in LPM_ADD_SUB device.
*
* Revision 1.21 1999/10/31 04:11:27 steve
* Add to netlist links pin name and instance number,
* and arrange in vvm for pin connections by name
* and instance number.
*
* Revision 1.20 1999/09/25 02:57:29 steve
* Parse system function calls.
*
* Revision 1.19 1999/09/15 04:17:52 steve
* separate assign lval elaboration for error checking.
*
* Revision 1.18 1999/08/31 22:38:29 steve
* Elaborate and emit to vvm procedural functions.
*
* Revision 1.17 1999/08/01 21:18:55 steve
* elaborate rise/fall/decay for continuous assign.
*
* Revision 1.16 1999/07/31 19:14:47 steve
* Add functions up to elaboration (Ed Carter)
*
* Revision 1.15 1999/07/22 02:05:20 steve
* is_constant method for PEConcat.
*
* Revision 1.14 1999/07/17 19:50:59 steve
* netlist support for ternary operator.
*
* Revision 1.13 1999/06/16 03:13:29 steve
* More syntax parse with sorry stubs.
*
* Revision 1.12 1999/06/15 02:50:02 steve
* Add lexical support for real numbers.
*
* Revision 1.11 1999/06/10 04:03:52 steve
* Add support for the Ternary operator,
* Add support for repeat concatenation,
* Correct some seg faults cause by elaboration
* errors,
* Parse the casex anc casez statements.
*
* Revision 1.10 1999/06/09 03:00:05 steve
* Add support for procedural concatenation expression.
*
* Revision 1.9 1999/05/16 05:08:42 steve
* Redo constant expression detection to happen
* after parsing.
*
* Parse more operators and expressions.
*
* Revision 1.8 1999/05/10 00:16:57 steve
* Parse and elaborate the concatenate operator
* in structural contexts, Replace vector<PExpr*>
* and list<PExpr*> with svector<PExpr*>, evaluate
* constant expressions with parameters, handle
* memories as lvalues.
*
* Parse task declarations, integer types.
*
* Revision 1.7 1999/05/01 02:57:52 steve
* Handle much more complex event expressions.
*
* Revision 1.6 1999/04/29 02:16:26 steve
* Parse OR of event expressions.
*
* Revision 1.5 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.4 1998/11/11 00:01:51 steve
* Check net ranges in declarations.
*
* Revision 1.3 1998/11/09 18:55:33 steve
* Add procedural while loops,
* Parse procedural for loops,
* Add procedural wait statements,
* Add constant nodes,
* Add XNOR logic gate,
* Make vvm output look a bit prettier.
*
* Revision 1.2 1998/11/07 17:05:05 steve
* Handle procedural conditional, and some
* of the conditional expressions.
*
* Elaborate signals and identifiers differently,
* allowing the netlist to hold signal information.
*
* Revision 1.1 1998/11/03 23:28:54 steve
* Introduce verilog to CVS.
*
*/
#endif

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.42 2001/07/29 22:22:40 steve Exp $"
#ident "$Id: elab_expr.cc,v 1.43 2001/11/07 04:01:59 steve Exp $"
#endif
# include "config.h"
@ -394,8 +394,8 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const
// the foo[msb:lsb] expression in the original.
if (lsb_) {
assert(msb_);
verinum*lsn = lsb_->eval_const(des, scope->name());
verinum*msn = msb_->eval_const(des, scope->name());
verinum*lsn = lsb_->eval_const(des, scope);
verinum*msn = msb_->eval_const(des, scope);
if ((lsn == 0) || (msn == 0)) {
cerr << get_line() << ": error: "
"Part select expresions must be "
@ -460,7 +460,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const
// to the part select, so that I save the effort of
// making a mux part in the netlist.
verinum*msn;
if (msb_ && (msn = msb_->eval_const(des, scope->name()))) {
if (msb_ && (msn = msb_->eval_const(des, scope))) {
assert(idx_ == 0);
unsigned long msv = msn->as_ulong();
unsigned idx = net->sb_to_idx(msv);
@ -636,6 +636,9 @@ NetEUnary* PEUnary::elaborate_expr(Design*des, NetScope*scope) const
/*
* $Log: elab_expr.cc,v $
* Revision 1.43 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* Revision 1.42 2001/07/29 22:22:40 steve
* support local reference to scope in expressions.
*
@ -660,26 +663,5 @@ NetEUnary* PEUnary::elaborate_expr(Design*des, NetScope*scope) const
* Revision 1.36 2001/02/10 20:29:39 steve
* In the context of range declarations, use elab_and_eval instead
* of the less robust eval_const methods.
*
* Revision 1.35 2001/02/09 05:44:23 steve
* support evaluation of constant < in expressions.
*
* Revision 1.34 2001/01/14 23:04:55 steve
* Generalize the evaluation of floating point delays, and
* get it working with delay assignment statements.
*
* Allow parameters to be referenced by hierarchical name.
*
* Revision 1.33 2001/01/13 22:20:08 steve
* Parse parameters within nested scopes.
*
* Revision 1.32 2001/01/02 04:21:13 steve
* Support a bunch of unary operators in parameter expressions.
*
* Revision 1.31 2000/12/10 22:01:35 steve
* Support decimal constants in behavioral delays.
*
* Revision 1.30 2000/11/29 05:24:00 steve
* synthesis for unary reduction ! and N operators.
*/

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_lval.cc,v 1.14 2001/08/25 23:50:02 steve Exp $"
#ident "$Id: elab_lval.cc,v 1.15 2001/11/07 04:01:59 steve Exp $"
#endif
# include "config.h"
@ -168,7 +168,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, NetScope*scope) const
two bit select expressions, and both must be
constant. Evaluate them and pass the results back to
the caller. */
verinum*vl = lsb_->eval_const(des, scope->name());
verinum*vl = lsb_->eval_const(des, scope);
if (vl == 0) {
cerr << lsb_->get_line() << ": error: "
"Part select expressions must be constant: "
@ -176,7 +176,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, NetScope*scope) const
des->errors += 1;
return 0;
}
verinum*vm = msb_->eval_const(des, scope->name());
verinum*vm = msb_->eval_const(des, scope);
if (vl == 0) {
cerr << msb_->get_line() << ": error: "
"Part select expressions must be constant: "
@ -197,7 +197,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, NetScope*scope) const
expression it not constant, then return the
expression as a mux. */
assert(lsb_ == 0);
verinum*v = msb_->eval_const(des, scope->name());
verinum*v = msb_->eval_const(des, scope);
if (v == 0) {
NetExpr*m = msb_->elaborate_expr(des, scope);
assert(m);
@ -277,6 +277,9 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, NetScope*scope) const
/*
* $Log: elab_lval.cc,v $
* Revision 1.15 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* Revision 1.14 2001/08/25 23:50:02 steve
* Change the NetAssign_ class to refer to the signal
* instead of link into the netlist. This is faster

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_net.cc,v 1.77 2001/10/28 01:14:53 steve Exp $"
#ident "$Id: elab_net.cc,v 1.78 2001/11/07 04:01:59 steve Exp $"
#endif
# include "config.h"
@ -843,7 +843,7 @@ NetNet* PEBinary::elaborate_net_shift_(Design*des, const string&path,
is no reason in this case to create a gate at all, just
connect the lsig to the osig with the bit positions
shifted. */
if (verinum*rval = right_->eval_const(des, path)) {
if (verinum*rval = right_->eval_const(des, scope)) {
assert(rval->is_defined());
unsigned dist = rval->as_ulong();
if (dist > lwidth)
@ -959,7 +959,7 @@ NetNet* PEConcat::elaborate_net(Design*des, const string&path,
unsigned repeat = 1;
if (repeat_) {
verinum*rep = repeat_->eval_const(des, path);
verinum*rep = repeat_->eval_const(des, scope);
if (rep == 0) {
cerr << get_line() << ": internal error: Unable to "
<< "evaluate constant repeat expression." << endl;
@ -1091,7 +1091,7 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
assert(sig);
if (msb_ && lsb_) {
verinum*mval = msb_->eval_const(des, path);
verinum*mval = msb_->eval_const(des, scope);
if (mval == 0) {
cerr << msb_->get_line() << ": error: unable to "
"evaluate constant expression: " << *msb_ <<
@ -1100,7 +1100,7 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
return 0;
}
verinum*lval = lsb_->eval_const(des, path);
verinum*lval = lsb_->eval_const(des, scope);
if (lval == 0) {
cerr << lsb_->get_line() << ": error: unable to "
"evaluate constant expression: " << *lsb_ <<
@ -1160,7 +1160,7 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
} else if (msb_) {
verinum*mval = msb_->eval_const(des, path);
verinum*mval = msb_->eval_const(des, scope);
if (mval == 0) {
cerr << get_line() << ": error: index of " << text_ <<
" needs to be constant in this context." <<
@ -1275,9 +1275,9 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
/* Detect a part select. Evaluate the bits and elaborate
the l-value by creating a sub-net that links to just
the right pins. */
verinum*mval = msb_->eval_const(des, path);
verinum*mval = msb_->eval_const(des, scope);
assert(mval);
verinum*lval = lsb_->eval_const(des, path);
verinum*lval = lsb_->eval_const(des, scope);
assert(lval);
unsigned midx = sig->sb_to_idx(mval->as_long());
unsigned lidx = sig->sb_to_idx(lval->as_long());
@ -1316,7 +1316,7 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
}
} else if (msb_) {
verinum*mval = msb_->eval_const(des, path);
verinum*mval = msb_->eval_const(des, scope);
if (mval == 0) {
cerr << get_line() << ": error: index of " << text_ <<
" needs to be constant in l-value of assignment." <<
@ -1392,9 +1392,9 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
/* Detect a part select. Evaluate the bits and elaborate
the l-value by creating a sub-net that links to just
the right pins. */
verinum*mval = msb_->eval_const(des, path);
verinum*mval = msb_->eval_const(des, scope);
assert(mval);
verinum*lval = lsb_->eval_const(des, path);
verinum*lval = lsb_->eval_const(des, scope);
assert(lval);
unsigned midx = sig->sb_to_idx(mval->as_long());
unsigned lidx = sig->sb_to_idx(lval->as_long());
@ -1424,7 +1424,7 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
}
} else if (msb_) {
verinum*mval = msb_->eval_const(des, path);
verinum*mval = msb_->eval_const(des, scope);
if (mval == 0) {
cerr << get_line() << ": index of " << text_ <<
" needs to be constant in port context." <<
@ -1704,7 +1704,7 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
// value. This can be reduced to a no-op on a precalculated
// result.
if (op_ == '-') do {
verinum*val = expr_->eval_const(des, path);
verinum*val = expr_->eval_const(des, scope);
if (val == 0)
break;
@ -1899,6 +1899,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
/*
* $Log: elab_net.cc,v $
* Revision 1.78 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* Revision 1.77 2001/10/28 01:14:53 steve
* NetObj constructor finally requires a scope.
*

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_pexpr.cc,v 1.10 2001/10/07 03:38:08 steve Exp $"
#ident "$Id: elab_pexpr.cc,v 1.11 2001/11/07 04:01:59 steve Exp $"
#endif
# include "config.h"
@ -77,7 +77,7 @@ NetEConcat* PEConcat::elaborate_pexpr(Design*des, NetScope*scope) const
accurately evaluate such expressions. So eventually, I will
need to be able to defer the evaluation of the expression. */
if (repeat_) {
verinum*vrep = repeat_->eval_const(des, scope->name());
verinum*vrep = repeat_->eval_const(des, scope);
if (vrep == 0) {
cerr << get_line() << ": error: "
"concatenation repeat expression cannot be evaluated."
@ -218,6 +218,9 @@ NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const
/*
* $Log: elab_pexpr.cc,v $
* Revision 1.11 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* Revision 1.10 2001/10/07 03:38:08 steve
* parameter names do not have defined size.
*

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_sig.cc,v 1.16 2001/11/01 05:21:26 steve Exp $"
#ident "$Id: elab_sig.cc,v 1.17 2001/11/07 04:01:59 steve Exp $"
#endif
# include "config.h"
@ -443,8 +443,8 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
// If the register has indices, then this is a
// memory. Create the memory object.
verinum*lval = lidx_->eval_const(des, path);
verinum*rval = ridx_->eval_const(des, path);
verinum*lval = lidx_->eval_const(des, scope);
verinum*rval = ridx_->eval_const(des, scope);
if ((lval == 0) || (rval == 0)) {
cerr << get_line() << ": internal error: There is "
@ -476,6 +476,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
/*
* $Log: elab_sig.cc,v $
* Revision 1.17 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* Revision 1.16 2001/11/01 05:21:26 steve
* Catch ports that have no direction.
*

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: elaborate.cc,v 1.229 2001/11/04 23:12:29 steve Exp $"
#ident "$Id: elaborate.cc,v 1.230 2001/11/07 04:01:59 steve Exp $"
#endif
# include "config.h"
@ -220,8 +220,8 @@ void PGBuiltin::elaborate(Design*des, const string&path) const
gates, then I am expected to make more then one
gate. Figure out how many are desired. */
if (msb_) {
verinum*msb = msb_->eval_const(des, path);
verinum*lsb = lsb_->eval_const(des, path);
verinum*msb = msb_->eval_const(des, scope);
verinum*lsb = lsb_->eval_const(des, scope);
if (msb == 0) {
cerr << get_line() << ": error: Unable to evaluate "
@ -904,7 +904,7 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
NetExpr*rv;
if (verinum*val = rval()->eval_const(des,path)) {
if (verinum*val = rval()->eval_const(des, scope)) {
rv = new NetEConst(*val);
delete val;
@ -1568,7 +1568,7 @@ NetProc* PDelayStatement::elaborate(Design*des, const string&path) const
}
verinum*num = delay_->eval_const(des, path);
verinum*num = delay_->eval_const(des, scope);
if (num == 0) {
/* Ah, the delay is not constant. OK, elaborate the
expression and let the run-time handle it. */
@ -2409,6 +2409,9 @@ Design* elaborate(list<const char*>roots)
/*
* $Log: elaborate.cc,v $
* Revision 1.230 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* Revision 1.229 2001/11/04 23:12:29 steve
* Pad limited r-values in continuous assignments.
*

86
eval.cc
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.cc,v 1.22 2001/11/06 06:11:55 steve Exp $"
#ident "$Id: eval.cc,v 1.23 2001/11/07 04:01:59 steve Exp $"
#endif
# include "config.h"
@ -28,16 +28,16 @@
# include "netlist.h"
# include "compiler.h"
verinum* PExpr::eval_const(const Design*, const string&) const
verinum* PExpr::eval_const(const Design*, const NetScope*) const
{
return 0;
}
verinum* PEBinary::eval_const(const Design*des, const string&path) const
verinum* PEBinary::eval_const(const Design*des, const NetScope*scope) const
{
verinum*l = left_->eval_const(des, path);
verinum*l = left_->eval_const(des, scope);
if (l == 0) return 0;
verinum*r = right_->eval_const(des, path);
verinum*r = right_->eval_const(des, scope);
if (r == 0) {
delete l;
return 0;
@ -113,9 +113,8 @@ verinum* PEBinary::eval_const(const Design*des, const string&path) const
* Evaluate an identifier as a constant expression. This is only
* possible if the identifier is that of a parameter.
*/
verinum* PEIdent::eval_const(const Design*des, const string&path) const
verinum* PEIdent::eval_const(const Design*des, const NetScope*scope) const
{
const NetScope*scope = des->find_scope(path);
assert(scope);
const NetExpr*expr = des->find_parameter(scope, text_);
@ -135,20 +134,20 @@ verinum* PEIdent::eval_const(const Design*des, const string&path) const
return new verinum(eval->value());
}
verinum* PEFNumber::eval_const(const Design*, const string&) const
verinum* PEFNumber::eval_const(const Design*, const NetScope*) const
{
long val = value_->as_long();
return new verinum(val);
}
verinum* PENumber::eval_const(const Design*, const string&) const
verinum* PENumber::eval_const(const Design*, const NetScope*) const
{
return new verinum(value());
}
verinum* PETernary::eval_const(const Design*des, const string&path) const
verinum* PETernary::eval_const(const Design*des, const NetScope*scope) const
{
verinum*test = expr_->eval_const(des, path);
verinum*test = expr_->eval_const(des, scope);
if (test == 0)
return 0;
@ -156,9 +155,9 @@ verinum* PETernary::eval_const(const Design*des, const string&path) const
delete test;
switch (bit) {
case verinum::V0:
return fal_->eval_const(des, path);
return fal_->eval_const(des, scope);
case verinum::V1:
return tru_->eval_const(des, path);
return tru_->eval_const(des, scope);
default:
return 0;
// XXXX It is possible to handle this case if both fal_
@ -166,9 +165,9 @@ verinum* PETernary::eval_const(const Design*des, const string&path) const
}
}
verinum* PEUnary::eval_const(const Design*des, const string&path) const
verinum* PEUnary::eval_const(const Design*des, const NetScope*scope) const
{
verinum*val = expr_->eval_const(des, path);
verinum*val = expr_->eval_const(des, scope);
if (val == 0)
return 0;
@ -197,6 +196,9 @@ verinum* PEUnary::eval_const(const Design*des, const string&path) const
/*
* $Log: eval.cc,v $
* Revision 1.23 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* Revision 1.22 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*
@ -224,59 +226,5 @@ verinum* PEUnary::eval_const(const Design*des, const string&path) const
*
* Revision 1.15 2000/09/07 22:38:13 steve
* Support unary + and - in constants.
*
* Revision 1.14 2000/03/08 04:36:53 steve
* Redesign the implementation of scopes and parameters.
* I now generate the scopes and notice the parameters
* in a separate pass over the pform. Once the scopes
* are generated, I can process overrides and evalutate
* paremeters before elaboration begins.
*
* Revision 1.13 2000/02/23 02:56:54 steve
* Macintosh compilers do not support ident.
*
* Revision 1.12 1999/11/30 04:48:17 steve
* Handle evaluation of ternary during elaboration.
*
* Revision 1.11 1999/11/28 23:42:02 steve
* NetESignal object no longer need to be NetNode
* objects. Let them keep a pointer to NetNet objects.
*
* Revision 1.10 1999/11/21 20:03:24 steve
* Handle multiply in constant expressions.
*
* Revision 1.9 1999/10/08 17:48:09 steve
* Support + in constant expressions.
*
* Revision 1.8 1999/09/20 02:21:10 steve
* Elaborate parameters in phases.
*
* Revision 1.7 1999/09/18 01:52:48 steve
* Remove spurious message.
*
* Revision 1.6 1999/09/16 04:18:15 steve
* elaborate concatenation repeats.
*
* Revision 1.5 1999/08/06 04:05:28 steve
* Handle scope of parameters.
*
* Revision 1.4 1999/07/17 19:51:00 steve
* netlist support for ternary operator.
*
* Revision 1.3 1999/05/30 01:11:46 steve
* Exressions are trees that can duplicate, and not DAGS.
*
* Revision 1.2 1999/05/10 00:16:58 steve
* Parse and elaborate the concatenate operator
* in structural contexts, Replace vector<PExpr*>
* and list<PExpr*> with svector<PExpr*>, evaluate
* constant expressions with parameters, handle
* memories as lvalues.
*
* Parse task declarations, integer types.
*
* Revision 1.1 1998/11/03 23:28:58 steve
* Introduce verilog to CVS.
*
*/

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_rconst.cc,v 1.3 2001/11/06 06:11:55 steve Exp $"
#ident "$Id: eval_rconst.cc,v 1.4 2001/11/07 04:01:59 steve Exp $"
#endif
# include "config.h"
@ -70,7 +70,7 @@ verireal* PEBinary::eval_rconst(const Design*des, const NetScope*scope) const
verireal* PEIdent::eval_rconst(const Design*des, const NetScope*scope) const
{
verinum* val = eval_const(des, scope->name());
verinum* val = eval_const(des, scope);
if (val == 0)
return 0;
@ -81,6 +81,9 @@ verireal* PEIdent::eval_rconst(const Design*des, const NetScope*scope) const
/*
* $Log: eval_rconst.cc,v $
* Revision 1.4 2001/11/07 04:01:59 steve
* eval_const uses scope instead of a string path.
*
* Revision 1.3 2001/11/06 06:11:55 steve
* Support more real arithmetic in delay constants.
*