Skip to content

Commit

Permalink
Globally merge redundant event objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed May 31, 2000
1 parent 9c65596 commit c1c0168
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 6 deletions.
7 changes: 4 additions & 3 deletions elaborate.cc
Expand Up @@ -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

/*
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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.
*
Expand Down
72 changes: 71 additions & 1 deletion net_event.cc
Expand Up @@ -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"
Expand All @@ -30,6 +30,7 @@ NetEvent::NetEvent(const string&n)
probes_ = 0;
trig_ = 0;
waitref_ = 0;
wlist_ = 0;
}

NetEvent::~NetEvent()
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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_;
}
Expand Down Expand Up @@ -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
Expand All @@ -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.
*
Expand Down
18 changes: 17 additions & 1 deletion netlist.h
Expand Up @@ -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

/*
Expand Down Expand Up @@ -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_;

Expand All @@ -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&);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down
9 changes: 8 additions & 1 deletion nodangle.cc
Expand Up @@ -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

/*
Expand All @@ -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;

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit c1c0168

Please sign in to comment.