Permalink
Browse files

Keep parameter constants for the ivl_target API.

  • Loading branch information...
steve
steve committed Mar 10, 2003
1 parent 7e9095a commit 1222153cdfa392ed1601fc59050d5c31c5b5a6a3
Showing with 541 additions and 154 deletions.
  1. +15 −5 design_dump.cc
  2. +18 −1 dup_expr.cc
  3. +23 −8 elab_expr.cc
  4. +7 −2 elab_net.cc
  5. +9 −1 emit.cc
  6. +5 −1 eval.cc
  7. +25 −4 eval_tree.cc
  8. +62 −82 ivl_target.h
  9. +41 −4 net_design.cc
  10. +11 −8 net_scope.cc
  11. +21 −5 netlist.cc
  12. +43 −12 netlist.h
  13. +49 −1 t-dll-api.cc
  14. +19 −1 t-dll-expr.cc
  15. +80 −1 t-dll.cc
  16. +26 −2 t-dll.h
  17. +9 −1 target.cc
  18. +5 −1 target.h
  19. +36 −7 tgt-stub/stub.c
  20. +13 −4 tgt-vvp/draw_vpi.c
  21. +19 −2 tgt-vvp/vvp_scope.c
  22. +5 −1 vpi_user.h
View
@@ -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.137 2003/01/27 05:09:17 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.138 2003/03/10 23:40:53 steve Exp $"
#endif
# include "config.h"
@@ -703,8 +703,8 @@ void NetScope::dump(ostream&o) const
/* Dump the parameters for this scope. */
{
map<string,param_expr_t>::const_iterator pp;
- for (pp = parameters_.begin()
- ; pp != parameters_.end() ; pp ++) {
+ for (pp = parameters.begin()
+ ; pp != parameters.end() ; pp ++) {
o << " parameter ";
if ((*pp).second.signed_flag)
@@ -718,8 +718,8 @@ void NetScope::dump(ostream&o) const
*(*pp).second.expr << ";" << endl;
}
- for (pp = localparams_.begin()
- ; pp != localparams_.end() ; pp ++) {
+ for (pp = localparams.begin()
+ ; pp != localparams.end() ; pp ++) {
o << " localparam " << (*pp).first << " = " <<
*(*pp).second.expr << ";" << endl;
}
@@ -903,6 +903,13 @@ void NetEConst::dump(ostream&o) const
o << value_;
}
+void NetEConstParam::dump(ostream&o) const
+{
+ o << "<" << name_ << "=";
+ NetEConst::dump(o);
+ o << ">";
+}
+
void NetECReal::dump(ostream&o) const
{
o << value_;
@@ -1021,6 +1028,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.138 2003/03/10 23:40:53 steve
+ * Keep parameter constants for the ivl_target API.
+ *
* Revision 1.137 2003/01/27 05:09:17 steve
* Spelling fixes.
*
View
@@ -17,14 +17,28 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: dup_expr.cc,v 1.10 2003/01/26 21:15:58 steve Exp $"
+#ident "$Id: dup_expr.cc,v 1.11 2003/03/10 23:40:53 steve Exp $"
#endif
# include "config.h"
# include "netlist.h"
# include <cassert>
+NetEConst* NetEConst::dup_expr() const
+{
+ NetEConst*tmp = new NetEConst(value_);
+ tmp->set_line(*this);
+ return tmp;
+}
+
+NetEConstParam* NetEConstParam::dup_expr() const
+{
+ NetEConstParam*tmp = new NetEConstParam(scope_, name_, value());
+ tmp->set_line(*this);
+ return tmp;
+}
+
NetEScope* NetEScope::dup_expr() const
{
assert(0);
@@ -95,6 +109,9 @@ NetEVariable* NetEVariable::dup_expr() const
/*
* $Log: dup_expr.cc,v $
+ * Revision 1.11 2003/03/10 23:40:53 steve
+ * Keep parameter constants for the ivl_target API.
+ *
* Revision 1.10 2003/01/26 21:15:58 steve
* Rework expression parsing and elaboration to
* accommodate real/realtime values and expressions.
View
@@ -17,11 +17,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_expr.cc,v 1.70 2003/03/07 02:44:34 steve Exp $"
+#ident "$Id: elab_expr.cc,v 1.71 2003/03/10 23:40:53 steve Exp $"
#endif
# include "config.h"
-
+# include "compiler.h"
# include "pform.h"
# include "netlist.h"
@@ -428,15 +428,15 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
bool sys_task_arg) const
{
assert(scope);
+ NetScope*found_in;
// If the identifier name is a parameter name, then return
// a reference to the parameter expression.
- if (const NetExpr*ex = des->find_parameter(scope, path_)) {
+ if (const NetExpr*ex = des->find_parameter(scope, path_, found_in)) {
NetExpr*tmp;
- if (dynamic_cast<const NetExpr*>(ex))
- tmp = ex->dup_expr();
- else
- tmp = new NetEParam(des, scope, path_);
+
+ assert(ex);
+ tmp = ex? ex->dup_expr() : new NetEParam(des, scope, path_);
if (msb_ && lsb_) {
/* If the parameter has a part select, we support
@@ -549,8 +549,20 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
tmp->set_line(*this);
tmp = stmp;
}
- }
+ } else {
+ /* No bit or part select. Make the constant into a
+ NetEConstParam if possible. */
+ NetEConst*ctmp = dynamic_cast<NetEConst*>(tmp);
+ if (ctmp != 0) {
+ const char*name
+ = lex_strings.add(path_.peek_name(0));
+ NetEConstParam*ptmp
+ = new NetEConstParam(found_in, name, ctmp->value());
+ delete tmp;
+ tmp = ptmp;
+ }
+ }
tmp->set_line(*this);
return tmp;
@@ -902,6 +914,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
/*
* $Log: elab_expr.cc,v $
+ * Revision 1.71 2003/03/10 23:40:53 steve
+ * Keep parameter constants for the ivl_target API.
+ *
* Revision 1.70 2003/03/07 02:44:34 steve
* Implement $realtobits.
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_net.cc,v 1.108 2003/03/06 00:28:41 steve Exp $"
+#ident "$Id: elab_net.cc,v 1.109 2003/03/10 23:40:53 steve Exp $"
#endif
# include "config.h"
@@ -1260,14 +1260,16 @@ NetNet* PEIdent::elaborate_net(Design*des, NetScope*scope,
NetNet*sig = des->find_signal(scope, path_);
if (sig == 0) {
+ NetScope*found_in;
+
/* If the identifier is a memory instead of a signal,
then handle it elsewhere. Create a RAM. */
if (NetMemory*mem = des->find_memory(scope, path_))
return elaborate_net_ram_(des, scope, mem, lwidth,
rise, fall, decay);
- if (const NetExpr*pe = des->find_parameter(scope, path_)) {
+ if (const NetExpr*pe = des->find_parameter(scope, path_, found_in)) {
const NetEConst*pc = dynamic_cast<const NetEConst*>(pe);
assert(pc);
@@ -2277,6 +2279,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
/*
* $Log: elab_net.cc,v $
+ * Revision 1.109 2003/03/10 23:40:53 steve
+ * Keep parameter constants for the ivl_target API.
+ *
* Revision 1.108 2003/03/06 00:28:41 steve
* All NetObj objects have lex_string base names.
*
View
10 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.71 2003/01/26 21:15:58 steve Exp $"
+#ident "$Id: emit.cc,v 1.72 2003/03/10 23:40:53 steve Exp $"
#endif
# include "config.h"
@@ -414,6 +414,11 @@ void NetEConst::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_const(this);
}
+void NetEConstParam::expr_scan(struct expr_scan_t*tgt) const
+{
+ tgt->expr_param(this);
+}
+
void NetECReal::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_creal(this);
@@ -492,6 +497,9 @@ bool emit(const Design*des, const char*type)
/*
* $Log: emit.cc,v $
+ * Revision 1.72 2003/03/10 23:40:53 steve
+ * Keep parameter constants for the ivl_target API.
+ *
* Revision 1.71 2003/01/26 21:15:58 steve
* Rework expression parsing and elaboration to
* accommodate real/realtime values and expressions.
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: eval.cc,v 1.32 2002/10/19 22:59:49 steve Exp $"
+#ident "$Id: eval.cc,v 1.33 2003/03/10 23:40:53 steve Exp $"
#endif
# include "config.h"
@@ -136,6 +136,7 @@ verinum* PEBinary::eval_const(const Design*des, const NetScope*scope) const
*/
verinum* PEIdent::eval_const(const Design*des, const NetScope*scope) const
{
+ NetScope*found_in;
assert(scope);
const NetExpr*expr = des->find_parameter(scope, path_);
@@ -226,6 +227,9 @@ verinum* PEUnary::eval_const(const Design*des, const NetScope*scope) const
/*
* $Log: eval.cc,v $
+ * Revision 1.33 2003/03/10 23:40:53 steve
+ * Keep parameter constants for the ivl_target API.
+ *
* Revision 1.32 2002/10/19 22:59:49 steve
* Redo the parameter vector support to allow
* parameter names in range expressions.
View
@@ -17,10 +17,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: eval_tree.cc,v 1.47 2003/02/07 02:47:58 steve Exp $"
+#ident "$Id: eval_tree.cc,v 1.48 2003/03/10 23:40:53 steve Exp $"
#endif
# include "config.h"
+# include "compiler.h"
# include <iostream>
@@ -912,21 +913,38 @@ NetExpr* NetEParam::eval_tree()
// If the parameter that I refer to is already evaluated, then
// return the constant value.
- if (dynamic_cast<NetEConst*>(nexpr))
- return nexpr;
+ if (NetEConst*tmp = dynamic_cast<NetEConst*>(nexpr)) {
+ verinum val = tmp->value();
+ const char*name = lex_strings.add(name_.peek_name(0));
+ NetEConstParam*ptmp = new NetEConstParam(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:"
+ << *nexpr << endl;
delete nexpr;
return 0;
}
// The result can be saved as the value of the parameter for
// future reference, and return a copy to the caller.
scope_->replace_parameter(name_.peek_name(0), res);
- return res->dup_expr();
+
+ NetEConst*tmp = dynamic_cast<NetEConst*>(res);
+ assert(tmp);
+
+ verinum val = tmp->value();
+ const char*name = lex_strings.add(name_.peek_name(0));
+ NetEConstParam*ptmp = new NetEConstParam(scope_, name, val);
+
+ return ptmp;
}
NetEConst* NetESelect::eval_tree()
@@ -1222,6 +1240,9 @@ NetEConst* NetEUReduce::eval_tree()
/*
* $Log: eval_tree.cc,v $
+ * Revision 1.48 2003/03/10 23:40:53 steve
+ * Keep parameter constants for the ivl_target API.
+ *
* Revision 1.47 2003/02/07 02:47:58 steve
* NetEBDiv handles real value constant expressions.
*
Oops, something went wrong.

0 comments on commit 1222153

Please sign in to comment.