Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support parameters in real expressions and

 as real expressions, and fix multiply and
 divide with real results.
  • Loading branch information...
commit 5903f0744cfc2251e2e7e9f9ed1b02219205b5ab 1 parent e7b3168
steve authored
View
14 design_dump.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: design_dump.cc,v 1.139 2003/04/22 04:48:29 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.140 2003/05/30 02:55:32 steve Exp $"
#endif
# include "config.h"
@@ -915,6 +915,13 @@ void NetECReal::dump(ostream&o) const
o << value_;
}
+void NetECRealParam::dump(ostream&o) const
+{
+ o << "<" << name_ << "=";
+ NetECReal::dump(o);
+ o << ">";
+}
+
void NetEEvent::dump(ostream&o) const
{
o << "<event=" << event_->name() << ">";
@@ -1033,6 +1040,11 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.140 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.139 2003/04/22 04:48:29 steve
* Support event names as expressions elements.
*
View
14 dup_expr.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: dup_expr.cc,v 1.14 2003/04/22 04:48:29 steve Exp $"
+#ident "$Id: dup_expr.cc,v 1.15 2003/05/30 02:55:32 steve Exp $"
#endif
# include "config.h"
@@ -46,6 +46,13 @@ NetEConstParam* NetEConstParam::dup_expr() const
return tmp;
}
+NetECRealParam* NetECRealParam::dup_expr() const
+{
+ NetECRealParam*tmp = new NetECRealParam(scope_, name_, value());
+ tmp->set_line(*this);
+ return tmp;
+}
+
NetEEvent* NetEEvent::dup_expr() const
{
assert(0);
@@ -122,6 +129,11 @@ NetEVariable* NetEVariable::dup_expr() const
/*
* $Log: dup_expr.cc,v $
+ * Revision 1.15 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.14 2003/04/22 04:48:29 steve
* Support event names as expressions elements.
*
View
9 elab_expr.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_expr.cc,v 1.76 2003/04/22 04:48:29 steve Exp $"
+#ident "$Id: elab_expr.cc,v 1.77 2003/05/30 02:55:32 steve Exp $"
#endif
# include "config.h"
@@ -469,7 +469,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
NetExpr*tmp;
assert(ex);
- tmp = ex? ex->dup_expr() : new NetEParam(des, scope, path_);
+ tmp = ex->dup_expr();
if (msb_ && lsb_) {
/* If the parameter has a part select, we support
@@ -961,6 +961,11 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
/*
* $Log: elab_expr.cc,v $
+ * Revision 1.77 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.76 2003/04/22 04:48:29 steve
* Support event names as expressions elements.
*
View
8 elab_pexpr.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_pexpr.cc,v 1.19 2003/01/27 05:09:17 steve Exp $"
+#ident "$Id: elab_pexpr.cc,v 1.20 2003/05/30 02:55:32 steve Exp $"
#endif
# include "config.h"
@@ -146,6 +146,7 @@ NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const
}
NetExpr*res = new NetEParam(des, pscope, hname_t(name));
+ res->set_line(*this);
assert(res);
delete name;
@@ -228,6 +229,11 @@ NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const
/*
* $Log: elab_pexpr.cc,v $
+ * Revision 1.20 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.19 2003/01/27 05:09:17 steve
* Spelling fixes.
*
View
9 elab_scope.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_scope.cc,v 1.20 2003/03/06 00:28:41 steve Exp $"
+#ident "$Id: elab_scope.cc,v 1.21 2003/05/30 02:55:32 steve Exp $"
#endif
# include "config.h"
@@ -67,6 +67,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const
; cur != parameters.end() ; cur ++) {
NetEParam*tmp = new NetEParam;
+ tmp->set_line(*((*cur).second.expr));
if ((*cur).second.msb)
tmp->cast_signed( (*cur).second.signed_flag );
@@ -77,6 +78,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const
; cur != localparams.end() ; cur ++) {
NetEParam*tmp = new NetEParam;
+ tmp->set_line(*((*cur).second.expr));
if ((*cur).second.msb)
tmp->cast_signed( (*cur).second.signed_flag );
@@ -513,6 +515,11 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const
/*
* $Log: elab_scope.cc,v $
+ * Revision 1.21 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.20 2003/03/06 00:28:41 steve
* All NetObj objects have lex_string base names.
*
View
12 emit.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: emit.cc,v 1.73 2003/04/22 04:48:29 steve Exp $"
+#ident "$Id: emit.cc,v 1.74 2003/05/30 02:55:32 steve Exp $"
#endif
# include "config.h"
@@ -424,6 +424,11 @@ void NetECReal::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_creal(this);
}
+void NetECRealParam::expr_scan(struct expr_scan_t*tgt) const
+{
+ tgt->expr_rparam(this);
+}
+
void NetEMemory::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_memory(this);
@@ -502,6 +507,11 @@ bool emit(const Design*des, const char*type)
/*
* $Log: emit.cc,v $
+ * Revision 1.74 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.73 2003/04/22 04:48:29 steve
* Support event names as expressions elements.
*
View
96 eval_tree.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: eval_tree.cc,v 1.51 2003/04/15 05:06:56 steve Exp $"
+#ident "$Id: eval_tree.cc,v 1.52 2003/05/30 02:55:32 steve Exp $"
#endif
# include "config.h"
@@ -622,28 +622,40 @@ NetExpr* NetEBDiv::eval_tree()
verireal lval = lc->value();
if (NetECReal*rc = dynamic_cast<NetECReal*>(right_)) {
+ NetECReal*tmp = 0;
verireal rval = rc->value();
switch (op_) {
case '/':
- return new NetECReal(lval / rval);
+ tmp = new NetECReal(lval / rval);
+ break;
case '%':
- return new NetECReal(lval % rval);
+ tmp = new NetECReal(lval % rval);
}
+ assert(tmp);
+ tmp->set_line(*this);
+ return tmp;
+
} else if (NetEConst*rc = dynamic_cast<NetEConst*>(right_)) {
+ NetECReal*tmp = 0;
verinum rval = rc->value();
switch (op_) {
case '/':
- return new NetECReal(lval / rval);
+ tmp = new NetECReal(lval / rval);
+ break;
case '%':
- return new NetECReal(lval % rval);
+ tmp = new NetECReal(lval % rval);
}
+ assert(tmp);
+ tmp->set_line(*this);
+ return tmp;
+
}
@@ -735,10 +747,66 @@ NetEConst* NetEBLogic::eval_tree()
return new NetEConst(verinum(res, 1));
}
-NetEConst* NetEBMult::eval_tree()
+NetExpr* NetEBMult::eval_tree_real_()
+{
+ verireal lval;
+ verireal rval;
+
+ switch (left_->expr_type()) {
+ case ET_REAL: {
+ NetECReal*lc = dynamic_cast<NetECReal*> (left_);
+ if (lc == 0) return 0;
+ lval = lc->value();
+ break;
+ }
+
+ case ET_VECTOR: {
+ NetEConst*lc = dynamic_cast<NetEConst*>(left_);
+ if (lc == 0) return 0;
+ verinum tmp = lc->value();
+ lval = verireal(tmp.as_long());
+ break;
+ }
+
+ default:
+ assert(0);
+ }
+
+ switch (right_->expr_type()) {
+ case ET_REAL: {
+ NetECReal*rc = dynamic_cast<NetECReal*> (right_);
+ if (rc == 0) return 0;
+ rval = rc->value();
+ break;
+ }
+
+ case ET_VECTOR: {
+ NetEConst*rc = dynamic_cast<NetEConst*>(right_);
+ if (rc == 0) return 0;
+ verinum tmp = rc->value();
+ rval = verireal(tmp.as_long());
+ break;
+ }
+
+ default:
+ assert(0);
+ }
+
+
+ NetECReal*res = new NetECReal(lval * rval);
+ res->set_line(*this);
+ return res;
+}
+
+NetExpr* NetEBMult::eval_tree()
{
eval_sub_tree_();
+ if (expr_type() == ET_REAL)
+ return eval_tree_real_();
+
+ assert(expr_type() == ET_VECTOR);
+
NetEConst*lc = dynamic_cast<NetEConst*>(left_);
if (lc == 0) return 0;
NetEConst*rc = dynamic_cast<NetEConst*>(right_);
@@ -997,12 +1065,21 @@ NetExpr* NetEParam::eval_tree()
return ptmp;
}
+ if (NetECReal*tmp = dynamic_cast<NetECReal*>(nexpr)) {
+ verireal val = tmp->value();
+ const char*name = lex_strings.add(name_.peek_name(0));
+ NetECRealParam*ptmp = new NetECRealParam(scope_, name, val);
+ ptmp->set_line(*this);
+ delete nexpr;
+ return ptmp;
+ }
+
// 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) {
cerr << get_line() << ": internal error: Unable to evaluate "
- << " parameter " << name_ << " expression:"
+ << "parameter " << name_ << " expression: "
<< *nexpr << endl;
delete nexpr;
return 0;
@@ -1315,6 +1392,11 @@ NetEConst* NetEUReduce::eval_tree()
/*
* $Log: eval_tree.cc,v $
+ * Revision 1.52 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.51 2003/04/15 05:06:56 steve
* Handle real constants evaluation > and >=.
*
View
31 net_expr.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: net_expr.cc,v 1.17 2003/05/20 15:05:33 steve Exp $"
+#ident "$Id: net_expr.cc,v 1.18 2003/05/30 02:55:32 steve Exp $"
#endif
# include "config.h"
@@ -345,6 +345,26 @@ NetExpr::TYPE NetECReal::expr_type() const
return ET_REAL;
}
+NetECRealParam::NetECRealParam(NetScope*s, const char*n, const verireal&v)
+: NetECReal(v), scope_(s), name_(n)
+{
+}
+
+NetECRealParam::~NetECRealParam()
+{
+}
+
+const char* NetECRealParam::name() const
+{
+ return name_;
+}
+
+const NetScope* NetECRealParam::scope() const
+{
+ return scope_;
+}
+
+
NetEParam::NetEParam()
: des_(0), scope_(0)
{
@@ -366,7 +386,9 @@ bool NetEParam::has_width() const
NetEParam* NetEParam::dup_expr() const
{
- return new NetEParam(des_, scope_, name_);
+ NetEParam*tmp = new NetEParam(des_, scope_, name_);
+ tmp->set_line(*this);
+ return tmp;
}
NetESelect::NetESelect(NetExpr*exp, NetExpr*base, unsigned wid)
@@ -462,6 +484,11 @@ NetExpr::TYPE NetESFunc::expr_type() const
/*
* $Log: net_expr.cc,v $
+ * Revision 1.18 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.17 2003/05/20 15:05:33 steve
* Do not try to set constants to width 0.
*
View
32 netlist.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: netlist.h,v 1.287 2003/05/01 01:13:57 steve Exp $"
+#ident "$Id: netlist.h,v 1.288 2003/05/30 02:55:32 steve Exp $"
#endif
/*
@@ -1084,6 +1084,26 @@ class NetECReal : public NetExpr {
verireal value_;
};
+class NetECRealParam : public NetECReal {
+
+ public:
+ explicit NetECRealParam(NetScope*scope, const char*name,
+ const verireal&val);
+ ~NetECRealParam();
+
+ const char* name() const;
+ const NetScope*scope() const;
+
+ virtual void expr_scan(struct expr_scan_t*) const;
+ virtual void dump(ostream&) const;
+
+ virtual NetECRealParam* dup_expr() const;
+
+ private:
+ NetScope*scope_;
+ const char*name_;
+};
+
/*
* This is a special, magical NetNet object. It represents a constant
* bit or part select of another NetNet, so is used to return that
@@ -2499,9 +2519,12 @@ class NetEBMult : public NetEBinary {
virtual bool set_width(unsigned w);
virtual NetEBMult* dup_expr() const;
- virtual NetEConst* eval_tree();
+ virtual NetExpr* eval_tree();
private:
+
+ NetExpr* eval_tree_real_();
+
};
@@ -3280,6 +3303,11 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
+ * Revision 1.288 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.287 2003/05/01 01:13:57 steve
* More complete bit range internal error message,
* Better test of part select ranges on non-zero
View
12 target.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: target.cc,v 1.67 2003/04/22 04:48:30 steve Exp $"
+#ident "$Id: target.cc,v 1.68 2003/05/30 02:55:32 steve Exp $"
#endif
# include "config.h"
@@ -334,6 +334,11 @@ void expr_scan_t::expr_creal(const NetECReal*)
"unhandled expr_creal." << endl;
}
+void expr_scan_t::expr_rparam(const NetECRealParam*that)
+{
+ expr_creal(that);
+}
+
void expr_scan_t::expr_concat(const NetEConcat*that)
{
cerr << that->get_line() << ": expr_scan_t (" <<
@@ -414,6 +419,11 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
/*
* $Log: target.cc,v $
+ * Revision 1.68 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.67 2003/04/22 04:48:30 steve
* Support event names as expressions elements.
*
View
8 target.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: target.h,v 1.63 2003/04/22 04:48:30 steve Exp $"
+#ident "$Id: target.h,v 1.64 2003/05/30 02:55:32 steve Exp $"
#endif
# include "netlist.h"
@@ -132,6 +132,7 @@ struct expr_scan_t {
virtual ~expr_scan_t();
virtual void expr_const(const NetEConst*);
virtual void expr_param(const NetEConstParam*);
+ virtual void expr_rparam(const NetECRealParam*);
virtual void expr_creal(const NetECReal*);
virtual void expr_concat(const NetEConcat*);
virtual void expr_memory(const NetEMemory*);
@@ -169,6 +170,11 @@ extern const struct target *target_table[];
/*
* $Log: target.h,v $
+ * Revision 1.64 2003/05/30 02:55:32 steve
+ * Support parameters in real expressions and
+ * as real expressions, and fix multiply and
+ * divide with real results.
+ *
* Revision 1.63 2003/04/22 04:48:30 steve
* Support event names as expressions elements.
*
Please sign in to comment.
Something went wrong with that request. Please try again.