From c1c016889392779f8ae6bda5875f39ca3df02817 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 31 May 2000 02:26:49 +0000 Subject: [PATCH] Globally merge redundant event objects. --- elaborate.cc | 7 ++--- net_event.cc | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++- netlist.h | 18 ++++++++++++- nodangle.cc | 9 ++++++- 4 files changed, 100 insertions(+), 6 deletions(-) diff --git a/elaborate.cc b/elaborate.cc index 84a580994..2cecb985e 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -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.174 2000/05/27 19:33:23 steve Exp $" +#ident "$Id: elaborate.cc,v 1.175 2000/05/31 02:26:49 steve Exp $" #endif /* @@ -1833,8 +1833,6 @@ NetProc* PEventStatement::elaborate_st(Design*des, const string&path, event. Otherwise, we didn't use it so delete it. */ if (expr_count > 0) { if (NetEvent*match = ev->find_similar_event()) { - cerr << "XXXX Found similar event for " << - ev->name() << endl; delete ev; wa->add_event(match); @@ -2438,6 +2436,9 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.175 2000/05/31 02:26:49 steve + * Globally merge redundant event objects. + * * Revision 1.174 2000/05/27 19:33:23 steve * Merge similar probes within a module. * diff --git a/net_event.cc b/net_event.cc index 0f054bbc1..59d41ea81 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.7 2000/05/27 19:33:23 steve Exp $" +#ident "$Id: net_event.cc,v 1.8 2000/05/31 02:26:49 steve Exp $" #endif # include "netlist.h" @@ -30,6 +30,7 @@ NetEvent::NetEvent(const string&n) probes_ = 0; trig_ = 0; waitref_ = 0; + wlist_ = 0; } NetEvent::~NetEvent() @@ -160,6 +161,13 @@ NetEvent* NetEvent::find_similar_event() return 0; } +void NetEvent::replace_event(NetEvent*that) +{ + while (wlist_) { + wlist_->obj->replace_event(this, that); + } +} + NetEvTrig::NetEvTrig(NetEvent*ev) : event_(ev) { @@ -243,6 +251,20 @@ NetEvWait::~NetEvWait() for (unsigned idx = 0 ; idx < nevents_ ; idx += 1) { NetEvent*tgt = events_[idx]; tgt->waitref_ -= 1; + + struct NetEvent::wcell_*tmp = tgt->wlist_; + if (tmp->obj == this) { + tgt->wlist_ = tmp->next; + delete tmp; + } else { + assert(tmp->next); + while (tmp->next->obj != this) { + tmp = tmp->next; + assert(tmp->next); + } + tmp->next = tmp->next->next; + delete tmp; + } } delete[]events_; } @@ -271,6 +293,51 @@ void NetEvWait::add_event(NetEvent*tgt) // Remember to tell the NetEvent that there is someone // pointing to it. tgt->waitref_ += 1; + + struct NetEvent::wcell_*tmp = new NetEvent::wcell_; + tmp->obj = this; + tmp->next = tgt->wlist_; + tgt->wlist_ = tmp; +} + +void NetEvWait::replace_event(NetEvent*src, NetEvent*repl) +{ + unsigned idx; + for (idx = 0 ; idx < nevents_ ; idx += 1) { + if (events_[idx] == src) + break; + } + + assert(idx < nevents_); + + /* First, remove me from the list held by the src NetEvent. */ + assert(src->waitref_ > 0); + src->waitref_ -= 1; + struct NetEvent::wcell_*tmp = src->wlist_; + if (tmp->obj == this) { + src->wlist_ = tmp->next; + delete tmp; + } else { + assert(tmp->next); + while (tmp->next->obj != this) { + tmp = tmp->next; + assert(tmp->next); + } + tmp->next = tmp->next->next; + delete tmp; + } + + events_[idx] = repl; + + // Remember to tell the replacement NetEvent that there is + // someone pointing to it. + repl->waitref_ += 1; + + tmp = new NetEvent::wcell_; + tmp->obj = this; + tmp->next = repl->wlist_; + repl->wlist_ = tmp; + } unsigned NetEvWait::nevents() const @@ -297,6 +364,9 @@ NetProc* NetEvWait::statement() /* * $Log: net_event.cc,v $ + * Revision 1.8 2000/05/31 02:26:49 steve + * Globally merge redundant event objects. + * * Revision 1.7 2000/05/27 19:33:23 steve * Merge similar probes within a module. * diff --git a/netlist.h b/netlist.h index a7c648039..77d6922dc 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.139 2000/05/27 19:33:23 steve Exp $" +#ident "$Id: netlist.h,v 1.140 2000/05/31 02:26:49 steve Exp $" #endif /* @@ -1405,8 +1405,15 @@ class NetEvent : public LineInfo { NetScope* scope(); const NetScope* scope() const; + // Locate the first event that matches my behavior and + // monitors the same signals. NetEvent* find_similar_event(); + // This method replaces pointers to me with pointers to + // that. It is typically used to replace similar events + // located by the find_similar_event method. + void replace_event(NetEvent*that); + private: string name_; @@ -1422,6 +1429,11 @@ class NetEvent : public LineInfo { // Use This member to count references by NetEvWait objects. unsigned waitref_; + struct wcell_ { + NetEvWait*obj; + struct wcell_*next; + }; + struct wcell_ *wlist_; private: // not implemented NetEvent(const NetEvent&); @@ -1454,6 +1466,7 @@ class NetEvWait : public NetProc { ~NetEvWait(); void add_event(NetEvent*tgt); + void replace_event(NetEvent*orig, NetEvent*repl); unsigned nevents() const; const NetEvent*event(unsigned) const; @@ -2582,6 +2595,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.140 2000/05/31 02:26:49 steve + * Globally merge redundant event objects. + * * Revision 1.139 2000/05/27 19:33:23 steve * Merge similar probes within a module. * diff --git a/nodangle.cc b/nodangle.cc index 45a2aeccc..cb54e2bf6 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.6 2000/05/07 04:37:56 steve Exp $" +#ident "$Id: nodangle.cc,v 1.7 2000/05/31 02:26:49 steve Exp $" #endif /* @@ -37,6 +37,10 @@ class nodangle_f : public functor_t { void nodangle_f::event(Design*des, NetEvent*ev) { + if (NetEvent*match = ev->find_similar_event()) { + ev->replace_event(match); + } + if (ev->nwait() != 0) return; @@ -94,6 +98,9 @@ void nodangle(Design*des) /* * $Log: nodangle.cc,v $ + * Revision 1.7 2000/05/31 02:26:49 steve + * Globally merge redundant event objects. + * * Revision 1.6 2000/05/07 04:37:56 steve * Carry strength values from Verilog source to the * pform and netlist for gates.