From 74c43032b340a1dc6d100734df9670d01dede45f Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 18 Apr 2000 04:50:19 +0000 Subject: [PATCH] Clean up unneeded NetEvent objects. --- functor.cc | 25 ++++++++++++++++++++++++- functor.h | 11 ++++++++--- net_event.cc | 23 ++++++++++++++++++++++- net_scope.cc | 25 ++++++++++++++++++++++++- netlist.h | 14 +++++++++++++- nodangle.cc | 16 +++++++++++++++- 6 files changed, 106 insertions(+), 8 deletions(-) diff --git a/functor.cc b/functor.cc index 69599723a..6169aad16 100644 --- a/functor.cc +++ b/functor.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: functor.cc,v 1.15 2000/04/16 23:32:18 steve Exp $" +#ident "$Id: functor.cc,v 1.16 2000/04/18 04:50:19 steve Exp $" #endif # include "functor.h" @@ -27,6 +27,10 @@ functor_t::~functor_t() { } +void functor_t::event(class Design*, class NetEvent*) +{ +} + void functor_t::signal(class Design*, class NetNet*) { } @@ -59,8 +63,24 @@ void functor_t::lpm_mult(class Design*, class NetMult*) { } +void NetScope::run_functor(Design*des, functor_t*fun) +{ + for (NetScope*cur = sub_ ; cur ; cur = cur->sib_) { + cur->run_functor(des, fun); + } + + for (NetEvent*cur = events_ ; cur ; /* */) { + NetEvent*tmp = cur; + cur = cur->snext_; + fun->event(des, tmp); + } +} + void Design::functor(functor_t*fun) { + // Scan the scopes + root_scope_->run_functor(this, fun); + // apply to signals if (signals_) { NetNet*cur = signals_->sig_next_; @@ -188,6 +208,9 @@ int proc_match_t::event_wait(NetEvWait*) /* * $Log: functor.cc,v $ + * Revision 1.16 2000/04/18 04:50:19 steve + * Clean up unneeded NetEvent objects. + * * Revision 1.15 2000/04/16 23:32:18 steve * Synthesis of comparator in expressions. * diff --git a/functor.h b/functor.h index d8c7f2feb..19b75db33 100644 --- a/functor.h +++ b/functor.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: functor.h,v 1.11 2000/04/12 20:02:53 steve Exp $" +#ident "$Id: functor.h,v 1.12 2000/04/18 04:50:19 steve Exp $" #endif /* @@ -35,8 +35,10 @@ class NetProcTop; struct functor_t { virtual ~functor_t(); - /* Signals are scanned first. This is called once for each - signal in the design. */ + /* Events are scanned here. */ + virtual void event(class Design*des, class NetEvent*); + + /* This is called once for each signal in the design. */ virtual void signal(class Design*des, class NetNet*); /* This method is called for each process in the design. */ @@ -74,6 +76,9 @@ struct proc_match_t { /* * $Log: functor.h,v $ + * Revision 1.12 2000/04/18 04:50:19 steve + * Clean up unneeded NetEvent objects. + * * Revision 1.11 2000/04/12 20:02:53 steve * Finally remove the NetNEvent and NetPEvent classes, * Get synthesis working with the NetEvWait class, diff --git a/net_event.cc b/net_event.cc index a4bf351a2..f4642f1ea 100644 --- a/net_event.cc +++ b/net_event.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: net_event.cc,v 1.5 2000/04/16 23:32:18 steve Exp $" +#ident "$Id: net_event.cc,v 1.6 2000/04/18 04:50:20 steve Exp $" #endif # include "netlist.h" @@ -35,6 +35,12 @@ NetEvent::NetEvent(const string&n) NetEvent::~NetEvent() { assert(waitref_ == 0); + if (scope_) scope_->rem_event(this); + while (probes_) { + NetEvProbe*tmp = probes_->enext_; + delete probes_; + tmp = probes_; + } } string NetEvent::name() const @@ -70,6 +76,18 @@ NetEvProbe* NetEvent::probe(unsigned idx) return cur; } +unsigned NetEvent::ntrig() const +{ + unsigned cnt = 0; + NetEvTrig*cur = trig_; + while (cur) { + cnt += 1; + cur = cur->enext_; + } + + return cnt; +} + unsigned NetEvent::nwait() const { return waitref_; @@ -207,6 +225,9 @@ NetProc* NetEvWait::statement() /* * $Log: net_event.cc,v $ + * Revision 1.6 2000/04/18 04:50:20 steve + * Clean up unneeded NetEvent objects. + * * Revision 1.5 2000/04/16 23:32:18 steve * Synthesis of comparator in expressions. * diff --git a/net_scope.cc b/net_scope.cc index a64e1a034..e3d99bd7b 100644 --- a/net_scope.cc +++ b/net_scope.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: net_scope.cc,v 1.3 2000/04/10 05:26:06 steve Exp $" +#ident "$Id: net_scope.cc,v 1.4 2000/04/18 04:50:20 steve Exp $" #endif # include "netlist.h" @@ -105,6 +105,26 @@ void NetScope::add_event(NetEvent*ev) events_ = ev; } +void NetScope::rem_event(NetEvent*ev) +{ + assert(ev->scope_ == this); + ev->scope_ = 0; + if (events_ == ev) { + events_ = ev->snext_; + + } else { + NetEvent*cur = events_; + while (cur->snext_ != ev) { + assert(cur->snext_); + cur = cur->snext_; + } + cur->snext_ = ev->snext_; + } + + ev->snext_ = 0; +} + + NetEvent* NetScope::find_event(const string&name) { for (NetEvent*cur = events_; cur ; cur = cur->snext_) @@ -164,6 +184,9 @@ string NetScope::local_symbol() /* * $Log: net_scope.cc,v $ + * Revision 1.4 2000/04/18 04:50:20 steve + * Clean up unneeded NetEvent objects. + * * Revision 1.3 2000/04/10 05:26:06 steve * All events now use the NetEvent class. * diff --git a/netlist.h b/netlist.h index 36b9820dd..43246c31b 100644 --- a/netlist.h +++ b/netlist.h @@ -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.124 2000/04/18 01:02:54 steve Exp $" +#ident "$Id: netlist.h,v 1.125 2000/04/18 04:50:20 steve Exp $" #endif /* @@ -1305,6 +1305,8 @@ class NetEvent : public LineInfo { // Return the number of NetEvWait nodes that reference me. unsigned nwait() const; + unsigned ntrig() const; + NetScope* scope(); const NetScope* scope() const; @@ -1331,6 +1333,8 @@ class NetEvent : public LineInfo { class NetEvTrig : public NetProc { + friend class NetEvent; + public: explicit NetEvTrig(NetEvent*tgt); ~NetEvTrig(); @@ -2173,6 +2177,7 @@ class NetScope { scope. */ void add_event(NetEvent*); + void rem_event(NetEvent*); NetEvent*find_event(const string&name); /* The parent and child() methods allow users of NetScope @@ -2195,6 +2200,10 @@ class NetScope { void dump(ostream&) const; void emit_scope(ostream&o, struct target_t*tgt) const; + /* This method runs the functor on me. Recurse through the + children of this node as well. */ + void run_functor(Design*des, functor_t*fun); + /* This member is used during elaboration to pass defparam assignments from the scope pass to the parameter evaluation @@ -2381,6 +2390,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.125 2000/04/18 04:50:20 steve + * Clean up unneeded NetEvent objects. + * * Revision 1.124 2000/04/18 01:02:54 steve * Minor cleanup of NetTaskDef. * diff --git a/nodangle.cc b/nodangle.cc index e0409a354..6be201e0c 100644 --- a/nodangle.cc +++ b/nodangle.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: nodangle.cc,v 1.3 2000/02/23 02:56:55 steve Exp $" +#ident "$Id: nodangle.cc,v 1.4 2000/04/18 04:50:20 steve Exp $" #endif /* @@ -31,9 +31,20 @@ class nodangle_f : public functor_t { public: + void event(Design*des, NetEvent*ev); void signal(Design*des, NetNet*sig); }; +void nodangle_f::event(Design*des, NetEvent*ev) +{ + if (ev->nwait() != 0) + return; + + if (ev->ntrig() != 0) + return; + + delete ev; +} void nodangle_f::signal(Design*des, NetNet*sig) { @@ -73,6 +84,9 @@ void nodangle(Design*des) /* * $Log: nodangle.cc,v $ + * Revision 1.4 2000/04/18 04:50:20 steve + * Clean up unneeded NetEvent objects. + * * Revision 1.3 2000/02/23 02:56:55 steve * Macintosh compilers do not support ident. *