Permalink
Browse files

Support real valued specify delays, properly scaled.

  • Loading branch information...
1 parent cbe1a6a commit 69cd007a71d303ef634ea8c33d40947ffbcbfebe steve committed Oct 3, 2006
Showing with 104 additions and 22 deletions.
  1. +19 −3 design_dump.cc
  2. +18 −4 elab_expr.cc
  3. +40 −11 elaborate.cc
  4. +13 −2 netlist.h
  5. +9 −1 verireal.cc
  6. +5 −1 verireal.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.169 2006/09/26 19:48:40 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.170 2006/10/03 05:06:00 steve Exp $"
#endif
# include "config.h"
@@ -916,11 +916,24 @@ void NetScope::dump(ostream&o) const
}
// Dump specparams
- typedef map<perm_string,long>::const_iterator specparam_it_t;
+ typedef map<perm_string,spec_val_t>::const_iterator specparam_it_t;
for (specparam_it_t cur = specparams.begin()
; cur != specparams.end() ; cur ++ ) {
o << " specparam " << (*cur).first
- << " = " << (*cur).second << endl;
+ << " = ";
+ spec_val_t value = (*cur).second;
+ switch (value.type) {
+ case IVL_VT_REAL:
+ o << "R:" << value.real_val;
+ break;
+ case IVL_VT_BOOL:
+ o << "I:" << value.integer;
+ break;
+ default:
+ o << "<bad type>";
+ break;
+ }
+ o << endl;
}
switch (type_) {
@@ -1216,6 +1229,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.170 2006/10/03 05:06:00 steve
+ * Support real valued specify delays, properly scaled.
+ *
* Revision 1.169 2006/09/26 19:48:40 steve
* Missing PSpec.cc file.
*
View
@@ -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.111 2006/09/28 04:35:18 steve Exp $"
+#ident "$Id: elab_expr.cc,v 1.112 2006/10/03 05:06:00 steve Exp $"
#endif
# include "config.h"
@@ -674,12 +674,23 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
// specify blocks are disabled.
if (gn_specify_blocks_flag) {
- map<perm_string,long>::const_iterator specp;
+ map<perm_string,NetScope::spec_val_t>::const_iterator specp;
perm_string key = perm_string::literal(path_.peek_name(0));
if (path_.component_count() == 1
&& ((specp = scope->specparams.find(key)) != scope->specparams.end())) {
- verinum val ((*specp).second);
- NetEConst*tmp = new NetEConst(val);
+ NetScope::spec_val_t value = (*specp).second;
+ NetExpr*tmp;
+ switch (value.type) {
+ case IVL_VT_BOOL:
+ tmp = new NetEConst(verinum(value.integer));
+ break;
+ case IVL_VT_REAL:
+ tmp = new NetECReal(verireal(value.real_val));
+ break;
+ default:
+ break;
+ }
+ assert(tmp);
tmp->set_line(*this);
return tmp;
}
@@ -1416,6 +1427,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
/*
* $Log: elab_expr.cc,v $
+ * Revision 1.112 2006/10/03 05:06:00 steve
+ * Support real valued specify delays, properly scaled.
+ *
* Revision 1.111 2006/09/28 04:35:18 steve
* Support selective control of specify and xtypes features.
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elaborate.cc,v 1.345 2006/09/28 04:35:18 steve Exp $"
+#ident "$Id: elaborate.cc,v 1.346 2006/10/03 05:06:00 steve Exp $"
#endif
# include "config.h"
@@ -2887,13 +2887,22 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const
if (ndelays > 12)
ndelays = 12;
- /* Elaborate the delay values themselves. */
+ int shift = scope->time_unit() - des->get_precision();
+
+ /* Elaborate the delay values themselves. Remember to scale
+ them for the timescale/precision of the scope. */
for (unsigned idx = 0 ; idx < ndelays ; idx += 1) {
PExpr*exp = delays[idx];
NetExpr*cur = elab_and_eval(des, scope, exp, 0);
if (NetEConst*cur_con = dynamic_cast<NetEConst*> (cur)) {
delay_value[idx] = cur_con->value().as_ulong();
+ for (int tmp = 0 ; tmp < shift ; tmp += 1)
+ delay_value[idx] *= 10;
+
+ } else if (NetECReal*cur_rcon = dynamic_cast<NetECReal*>(cur)) {
+ delay_value[idx] = cur_rcon->value().as_long(shift);
+
} else {
cerr << get_line() << ": error: Path delay value "
<< "must be constant." << endl;
@@ -2994,21 +3003,38 @@ bool Module::elaborate(Design*des, NetScope*scope) const
; cur != specparams.end() ; cur ++ ) {
NetExpr*val = elab_and_eval(des, scope, (*cur).second, -1);
- NetEConst*val_c = dynamic_cast<NetEConst*> (val);
- if (! val_c ) {
+ NetScope::spec_val_t value;
+
+ if (NetECReal*val_c = dynamic_cast<NetECReal*> (val)) {
+
+ value.type = IVL_VT_REAL;
+ value.real_val = val_c->value().as_double();
+
+ if (debug_elaborate)
+ cerr << get_line() << ": debug: Elaborate "
+ << "specparam " << (*cur).first
+ << " value=" << value.real_val << endl;
+
+ } else if (NetEConst*val_c = dynamic_cast<NetEConst*> (val)) {
+
+ value.type = IVL_VT_BOOL;
+ value.integer = val_c->value().as_long();
+
+ if (debug_elaborate)
+ cerr << get_line() << ": debug: Elaborate "
+ << "specparam " << (*cur).first
+ << " value=" << value.integer << endl;
+
+ } else {
cerr << (*cur).second->get_line() << ": error: "
<< "specparam " << (*cur).first << " value"
<< " is not constant: " << *val << endl;
des->errors += 1;
- continue;
}
- scope->specparams[(*cur).first] = val_c->value().as_long();
-
- if (debug_elaborate)
- cerr << get_line() << ": debug: Elaborate "
- << "specparam " << (*cur).first
- << " value=" << val_c->value().as_long() << endl;
+ assert(val);
+ delete val;
+ scope->specparams[(*cur).first] = value;
}
@@ -3284,6 +3310,9 @@ Design* elaborate(list<perm_string>roots)
/*
* $Log: elaborate.cc,v $
+ * Revision 1.346 2006/10/03 05:06:00 steve
+ * Support real valued specify delays, properly scaled.
+ *
* Revision 1.345 2006/09/28 04:35:18 steve
* Support selective control of specify and xtypes features.
*
View
@@ -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.362 2006/09/26 19:48:40 steve Exp $"
+#ident "$Id: netlist.h,v 1.363 2006/10/03 05:06:00 steve Exp $"
#endif
/*
@@ -3369,7 +3369,15 @@ class NetScope : public Attrib {
};
map<perm_string,param_expr_t>parameters;
map<perm_string,param_expr_t>localparams;
- map<perm_string,long>specparams;
+
+ struct spec_val_t {
+ ivl_variable_type_t type;
+ union {
+ double real_val; // type == IVL_VT_REAL
+ long integer; // type == IVL_VT_BOOL
+ };
+ };
+ map<perm_string,spec_val_t>specparams;
/* Module instance arrays are collected here for access during
the multiple elaboration passes. */
@@ -3559,6 +3567,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
+ * Revision 1.363 2006/10/03 05:06:00 steve
+ * Support real valued specify delays, properly scaled.
+ *
* Revision 1.362 2006/09/26 19:48:40 steve
* Missing PSpec.cc file.
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: verireal.cc,v 1.17 2006/08/08 05:11:37 steve Exp $"
+#ident "$Id: verireal.cc,v 1.18 2006/10/03 05:06:00 steve Exp $"
#endif
# include "config.h"
@@ -56,6 +56,11 @@ verireal::verireal(long val)
value_ = (double)val;
}
+verireal::verireal(double val)
+{
+ value_ = val;
+}
+
verireal::~verireal()
{
}
@@ -156,6 +161,9 @@ ostream& operator<< (ostream&out, const verireal&v)
/*
* $Log: verireal.cc,v $
+ * Revision 1.18 2006/10/03 05:06:00 steve
+ * Support real valued specify delays, properly scaled.
+ *
* Revision 1.17 2006/08/08 05:11:37 steve
* Handle 64bit delay constants.
*
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: verireal.h,v 1.13 2006/08/08 05:11:37 steve Exp $"
+#ident "$Id: verireal.h,v 1.14 2006/10/03 05:06:00 steve Exp $"
#endif
#ifdef HAVE_IOSFWD
@@ -58,6 +58,7 @@ class verireal {
explicit verireal();
explicit verireal(const char*text);
explicit verireal(long val);
+ explicit verireal(double val);
~verireal();
/* Return the value of the floating point number as an
@@ -85,6 +86,9 @@ extern verireal operator- (const verireal&);
/*
* $Log: verireal.h,v $
+ * Revision 1.14 2006/10/03 05:06:00 steve
+ * Support real valued specify delays, properly scaled.
+ *
* Revision 1.13 2006/08/08 05:11:37 steve
* Handle 64bit delay constants.
*

0 comments on commit 69cd007

Please sign in to comment.