Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Globally merge redundant event objects.

  • Loading branch information...
commit c1c016889392779f8ae6bda5875f39ca3df02817 1 parent 9c65596
steve authored
Showing with 100 additions and 6 deletions.
  1. +4 −3 elaborate.cc
  2. +71 −1 net_event.cc
  3. +17 −1 netlist.h
  4. +8 −1 nodangle.cc
View
7 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<string,Module*>&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.
*
View
72 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.
*
View
18 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.
*
View
9 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.
Please sign in to comment.
Something went wrong with that request. Please try again.