Permalink
Browse files

Redo handling of assignment internal delays.

 Leave it possible for them to be calculated
 at run time.
  • Loading branch information...
1 parent 52ea138 commit 5882c6a48172e607e997934cfc85cdc7ac12480b steve committed Apr 21, 2002
Showing with 178 additions and 79 deletions.
  1. +9 −2 Statement.cc
  2. +7 −2 Statement.h
  3. +67 −12 elaborate.cc
  4. +16 −35 net_assign.cc
  5. +10 −12 netlist.h
  6. +22 −4 t-dll-proc.cc
  7. +47 −12 tgt-vvp/vvp_process.c
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: Statement.cc,v 1.26 2002/04/21 04:59:07 steve Exp $"
+#ident "$Id: Statement.cc,v 1.27 2002/04/21 22:31:02 steve Exp $"
#endif
# include "config.h"
@@ -32,17 +32,19 @@ Statement::~Statement()
PAssign_::PAssign_(PExpr*lval, PExpr*ex)
: event_(0), lval_(lval), rval_(ex)
{
+ delay_ = 0;
}
PAssign_::PAssign_(PExpr*lval, PExpr*de, PExpr*ex)
: event_(0), lval_(lval), rval_(ex)
{
- if (de) delay_.set_delay(de);
+ delay_ = de;
}
PAssign_::PAssign_(PExpr*lval, PEventStatement*ev, PExpr*ex)
: event_(ev), lval_(lval), rval_(ex)
{
+ delay_ = 0;
}
PAssign_::~PAssign_()
@@ -293,6 +295,11 @@ PWhile::~PWhile()
/*
* $Log: Statement.cc,v $
+ * Revision 1.27 2002/04/21 22:31:02 steve
+ * Redo handling of assignment internal delays.
+ * Leave it possible for them to be calculated
+ * at run time.
+ *
* Revision 1.26 2002/04/21 04:59:07 steve
* Add support for conbinational events by finding
* the inputs to expressions and some statements.
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: Statement.h,v 1.32 2002/04/21 04:59:07 steve Exp $"
+#ident "$Id: Statement.h,v 1.33 2002/04/21 22:31:02 steve Exp $"
#endif
# include <string>
@@ -97,7 +97,7 @@ class PAssign_ : public Statement {
protected:
NetAssign_* elaborate_lval(Design*, NetScope*scope) const;
- PDelays delay_;
+ PExpr* delay_;
PEventStatement*event_;
private:
@@ -453,6 +453,11 @@ class PWhile : public Statement {
/*
* $Log: Statement.h,v $
+ * Revision 1.33 2002/04/21 22:31:02 steve
+ * Redo handling of assignment internal delays.
+ * Leave it possible for them to be calculated
+ * at run time.
+ *
* Revision 1.32 2002/04/21 04:59:07 steve
* Add support for conbinational events by finding
* the inputs to expressions and some statements.
View
@@ -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.243 2002/04/21 04:59:07 steve Exp $"
+#ident "$Id: elaborate.cc,v 1.244 2002/04/21 22:31:02 steve Exp $"
#endif
# include "config.h"
@@ -875,6 +875,57 @@ NetAssign_* PAssign_::elaborate_lval(Design*des, NetScope*scope) const
return lval_->elaborate_lval(des, scope);
}
+/*
+ * This function elaborates delay expressions. This is a little
+ * different from normal elaboration because the result may need to be
+ * scaled.
+ */
+static NetExpr*elaborate_delay_expr(PExpr*expr, Design*des, NetScope*scope)
+{
+
+ if (verireal*dr = expr->eval_rconst(des, scope)) {
+ int shift = scope->time_unit() - des->get_precision();
+ long val = dr->as_long(shift);
+ delete dr;
+ return new NetEConst(verinum(val));
+
+ }
+
+ if (verinum*dv = expr->eval_const(des, scope)) {
+ unsigned long val = dv->as_ulong();
+ val = des->scale_to_precision(val, scope);
+ return new NetEConst(verinum(val));
+
+ }
+
+ NetExpr*delay = expr->elaborate_expr(des, scope);
+
+ int shift = scope->time_unit() - des->get_precision();
+ if (shift > 0) {
+ unsigned long scale = 1;
+ while (shift > 0) {
+ scale *= 10;
+ shift -= 1;
+ }
+
+ NetExpr*scal_val = new NetEConst(verinum(scale));
+ delay = new NetEBMult('*', delay, scal_val);
+ }
+
+ if (shift < 0) {
+ unsigned long scale = 1;
+ while (shift < 0) {
+ scale *= 10;
+ shift += 1;
+ }
+
+ NetExpr*scal_val = new NetEConst(verinum(scale));
+ delay = new NetEBDiv('/', delay, scal_val);
+ }
+
+ return delay;
+}
+
NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
{
assert(scope);
@@ -900,9 +951,10 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
NetAssign_*lv = elaborate_lval(des, scope);
if (lv == 0) return 0;
- /* If there is a delay expression, elaborate it. */
- unsigned long rise_time, fall_time, decay_time;
- delay_.eval_delays(des, scope, rise_time, fall_time, decay_time);
+ /* If there is an internal delay expression, elaborate it. */
+ NetExpr*delay = 0;
+ if (delay_ != 0)
+ delay = elaborate_delay_expr(delay_, des, scope);
/* Elaborate the r-value expression. */
@@ -947,7 +999,7 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
actually and literally represent the delayed assign in the
netlist. The compound statement is exactly equivalent. */
- if (rise_time || event_) {
+ if (delay || event_) {
string n = scope->local_hsymbol();
unsigned wid = lv->lwidth();
@@ -995,7 +1047,7 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
assert(st);
} else {
- NetPDelay*de = new NetPDelay(rise_time, a2);
+ NetPDelay*de = new NetPDelay(delay, a2);
st = de;
}
@@ -1091,15 +1143,13 @@ NetProc* PAssignNB::elaborate(Design*des, NetScope*scope) const
rv = pad_to_width(rv, wid);
}
-
- unsigned long rise_time, fall_time, decay_time;
- delay_.eval_delays(des, scope, rise_time, fall_time, decay_time);
+ NetExpr*delay = 0;
+ if (delay_ != 0)
+ delay = elaborate_delay_expr(delay_, des, scope);
/* All done with this node. mark its line number and check it in. */
NetAssignNB*cur = new NetAssignNB(lv, rv);
- cur->rise_time(rise_time);
- cur->fall_time(fall_time);
- cur->decay_time(decay_time);
+ cur->set_delay(delay);
cur->set_line(*this);
return cur;
}
@@ -2454,6 +2504,11 @@ Design* elaborate(list<const char*>roots)
/*
* $Log: elaborate.cc,v $
+ * Revision 1.244 2002/04/21 22:31:02 steve
+ * Redo handling of assignment internal delays.
+ * Leave it possible for them to be calculated
+ * at run time.
+ *
* Revision 1.243 2002/04/21 04:59:07 steve
* Add support for conbinational events by finding
* the inputs to expressions and some statements.
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: net_assign.cc,v 1.8 2001/08/25 23:50:03 steve Exp $"
+#ident "$Id: net_assign.cc,v 1.9 2002/04/21 22:31:02 steve Exp $"
#endif
# include "config.h"
@@ -99,7 +99,7 @@ unsigned NetAssign_::get_loff() const
}
NetAssignBase::NetAssignBase(NetAssign_*lv, NetExpr*rv)
-: lval_(lv), rval_(rv)
+: lval_(lv), rval_(rv), delay_(0)
{
}
@@ -180,60 +180,41 @@ unsigned NetAssignBase::lwidth() const
return sum;
}
-
-NetAssign::NetAssign(NetAssign_*lv, NetExpr*rv)
-: NetAssignBase(lv, rv)
+void NetAssignBase::set_delay(NetExpr*expr)
{
+ delay_ = expr;
}
-NetAssign::~NetAssign()
+const NetExpr* NetAssignBase::get_delay() const
{
+ return delay_;
}
-NetAssignNB::NetAssignNB(NetAssign_*lv, NetExpr*rv)
+NetAssign::NetAssign(NetAssign_*lv, NetExpr*rv)
: NetAssignBase(lv, rv)
{
- rise_time_ = 0;
- fall_time_ = 0;
- decay_time_ = 0;
-}
-
-NetAssignNB::~NetAssignNB()
-{
-}
-
-void NetAssignNB::rise_time(unsigned t)
-{
- rise_time_ = t;
-}
-
-void NetAssignNB::fall_time(unsigned t)
-{
- fall_time_ = t;
-}
-
-void NetAssignNB::decay_time(unsigned t)
-{
- decay_time_ = t;
}
-unsigned NetAssignNB::rise_time() const
+NetAssign::~NetAssign()
{
- return rise_time_;
}
-unsigned NetAssignNB::fall_time() const
+NetAssignNB::NetAssignNB(NetAssign_*lv, NetExpr*rv)
+: NetAssignBase(lv, rv)
{
- return fall_time_;
}
-unsigned NetAssignNB::decay_time() const
+NetAssignNB::~NetAssignNB()
{
- return decay_time_;
}
/*
* $Log: net_assign.cc,v $
+ * Revision 1.9 2002/04/21 22:31:02 steve
+ * Redo handling of assignment internal delays.
+ * Leave it possible for them to be calculated
+ * at run time.
+ *
* Revision 1.8 2001/08/25 23:50:03 steve
* Change the NetAssign_ class to refer to the signal
* instead of link into the netlist. This is faster
View
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: netlist.h,v 1.234 2002/04/21 17:43:13 steve Exp $"
+#ident "$Id: netlist.h,v 1.235 2002/04/21 22:31:02 steve Exp $"
#endif
/*
@@ -1281,6 +1281,9 @@ class NetAssignBase : public NetProc {
const NetAssign_* l_val(unsigned) const;
unsigned l_val_count() const;
+ void set_delay(NetExpr*);
+ const NetExpr* get_delay() const;
+
virtual NexusSet* nex_input();
// This returns the total width of the accumulated l-value. It
@@ -1293,6 +1296,7 @@ class NetAssignBase : public NetProc {
private:
NetAssign_*lval_;
NetExpr *rval_;
+ NetExpr *delay_;
};
class NetAssign : public NetAssignBase {
@@ -1313,23 +1317,12 @@ class NetAssignNB : public NetAssignBase {
explicit NetAssignNB(NetAssign_*lv, NetExpr*rv);
~NetAssignNB();
- void rise_time(unsigned);
- void fall_time(unsigned);
- void decay_time(unsigned);
-
- unsigned rise_time() const;
- unsigned fall_time() const;
- unsigned decay_time() const;
virtual bool emit_proc(struct target_t*) const;
virtual int match_proc(struct proc_match_t*);
virtual void dump(ostream&, unsigned ind) const;
private:
-
- unsigned rise_time_;
- unsigned fall_time_;
- unsigned decay_time_;
};
/*
@@ -2984,6 +2977,11 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
+ * Revision 1.235 2002/04/21 22:31:02 steve
+ * Redo handling of assignment internal delays.
+ * Leave it possible for them to be calculated
+ * at run time.
+ *
* Revision 1.234 2002/04/21 17:43:13 steve
* implement nex_input for behavioral statements.
*
Oops, something went wrong.

0 comments on commit 5882c6a

Please sign in to comment.