From b62a7ace5ca91e74fa99252a89f248cb4062a548 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 2 Apr 2000 04:26:06 +0000 Subject: [PATCH] Remove the useless sref template. --- design_dump.cc | 21 ++++--- netlist.cc | 68 ++++++++++++++++---- netlist.h | 31 ++++++--- sref.h | 167 ------------------------------------------------- synth.cc | 18 +++--- t-vvm.cc | 18 ++++-- xnfsyn.cc | 17 +++-- 7 files changed, 123 insertions(+), 217 deletions(-) delete mode 100644 sref.h diff --git a/design_dump.cc b/design_dump.cc index 66056b172..434b8f595 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: design_dump.cc,v 1.71 2000/04/01 21:40:22 steve Exp $" +#ident "$Id: design_dump.cc,v 1.72 2000/04/02 04:26:06 steve Exp $" #endif /* @@ -388,7 +388,7 @@ void NetNEvent::dump_node(ostream&o, unsigned ind) const break; } - o << name() << " --> " << fore_ptr()->name() << endl; + o << name() << " --> " << event_->name() << endl; dump_node_pins(o, ind+4); } @@ -556,13 +556,15 @@ void NetPDelay::dump(ostream&o, unsigned ind) const void NetPEvent::dump(ostream&o, unsigned ind) const { o << setw(ind) << "" << "@("; - svector*list = back_list(); - (*list)[0]->dump_proc(o); - for (unsigned idx = 1 ; idx < list->count() ; idx += 1) { - o << " or "; - (*list)[idx]->dump_proc(o); + + if (src_) { + const NetNEvent*cur = src_; + for (cur = src_->next_ ; cur ; cur = cur->next_) { + o << " or "; + cur->dump_proc(o); + } } - delete list; + o << ") /* " << name_ << " */"; if (statement_) { @@ -904,6 +906,9 @@ void Design::dump(ostream&o) const /* * $Log: design_dump.cc,v $ + * Revision 1.72 2000/04/02 04:26:06 steve + * Remove the useless sref template. + * * Revision 1.71 2000/04/01 21:40:22 steve * Add support for integer division. * diff --git a/netlist.cc b/netlist.cc index 2ac924cec..03f828ecf 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: netlist.cc,v 1.110 2000/04/01 21:40:22 steve Exp $" +#ident "$Id: netlist.cc,v 1.111 2000/04/02 04:26:06 steve Exp $" #endif # include @@ -1756,8 +1756,12 @@ const NetNet* NetFuncDef::port(unsigned idx) const } NetNEvent::NetNEvent(const string&ev, unsigned wid, Type e, NetPEvent*pe) -: NetNode(ev, wid), sref(pe), edge_(e) +: NetNode(ev, wid), edge_(e) { + event_ = pe; + next_ = pe->src_; + pe->src_ = next_; + for (unsigned idx = 0 ; idx < wid ; idx += 1) { pin(idx).set_name("P", idx); } @@ -1767,25 +1771,38 @@ NetNEvent::~NetNEvent() { } -NetPEvent::NetPEvent(const string&n, NetProc*st) -: name_(n), statement_(st) +NetNEvent::Type NetNEvent::type() const { + return edge_; +} + +const NetPEvent* NetNEvent::pevent() const +{ + return event_; +} + +NetPEvent::NetPEvent(const string&n, NetProc*st) +: name_(n), statement_(st), src_(0) +{ + idx_ = 0; } NetPEvent::~NetPEvent() { - svector*back = back_list(); - if (back) { - for (unsigned idx = 0 ; idx < back->count() ; idx += 1) { - NetNEvent*ne = (*back)[idx]; - delete ne; - } - delete back; + while (src_) { + NetNEvent*cur = src_; + src_ = src_->next_; + delete cur; } delete statement_; } +string NetPEvent::name() const +{ + return name_; +} + NetProc* NetPEvent::statement() { return statement_; @@ -1796,6 +1813,32 @@ const NetProc* NetPEvent::statement() const return statement_; } +NetNEvent* NetPEvent::first() +{ + idx_ = src_; + return idx_; +} + +NetNEvent* NetPEvent::next() +{ + assert(idx_); + idx_ = idx_->next_; + return idx_; +} + +const NetNEvent* NetPEvent::first() const +{ + idx_ = src_; + return idx_; +} + +const NetNEvent* NetPEvent::next() const +{ + assert(idx_); + idx_ = idx_->next_; + return idx_; +} + NetSTask::NetSTask(const string&na, const svector&pa) : name_(na), parms_(pa) { @@ -2597,6 +2640,9 @@ bool NetUDP::sequ_glob_(string input, char output) /* * $Log: netlist.cc,v $ + * Revision 1.111 2000/04/02 04:26:06 steve + * Remove the useless sref template. + * * Revision 1.110 2000/04/01 21:40:22 steve * Add support for integer division. * diff --git a/netlist.h b/netlist.h index 1c5371e1e..2432e6d78 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.116 2000/04/01 21:40:22 steve Exp $" +#ident "$Id: netlist.h,v 1.117 2000/04/02 04:26:06 steve Exp $" #endif /* @@ -31,7 +31,6 @@ # include # include # include "verinum.h" -# include "sref.h" # include "LineInfo.h" # include "svector.h" @@ -1319,17 +1318,24 @@ class NetPDelay : public NetProc { * * The NetPEvent is the procedural part of the event. */ -class NetNEvent; -class NetPEvent : public NetProc, public sref_back { +class NetPEvent : public NetProc { + + friend class NetNEvent; public: NetPEvent(const string&n, NetProc*st); ~NetPEvent(); - string name() const { return name_; } + string name() const; NetProc* statement(); const NetProc* statement() const; + NetNEvent* first(); + NetNEvent* next(); + + const NetNEvent* first() const; + const NetNEvent* next() const; + virtual int match_proc(struct proc_match_t*); virtual bool emit_proc(ostream&, struct target_t*) const; virtual void dump(ostream&, unsigned ind) const; @@ -1339,6 +1345,9 @@ class NetPEvent : public NetProc, public sref_back { private: string name_; NetProc*statement_; + // This is a list of the source events that can trigger me. + NetNEvent*src_; + mutable NetNEvent*idx_; }; /* @@ -1349,7 +1358,9 @@ class NetPEvent : public NetProc, public sref_back { * The NetNEvent may have wide input if is is an ANYEDGE type * device. This allows detecting changes in wide expressions. */ -class NetNEvent : public NetNode, public sref { +class NetNEvent : public NetNode { + + friend class NetPEvent; public: enum Type { ANYEDGE, POSEDGE, NEGEDGE, POSITIVE }; @@ -1357,7 +1368,8 @@ class NetNEvent : public NetNode, public sref { NetNEvent(const string&ev, unsigned wid, Type e, NetPEvent*pe); ~NetNEvent(); - Type type() const { return edge_; } + Type type() const; + const NetPEvent*pevent() const; virtual void emit_node(ostream&, struct target_t*) const; @@ -1366,6 +1378,8 @@ class NetNEvent : public NetNode, public sref { private: Type edge_; + NetPEvent*event_; + NetNEvent*next_; }; @@ -2266,6 +2280,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.117 2000/04/02 04:26:06 steve + * Remove the useless sref template. + * * Revision 1.116 2000/04/01 21:40:22 steve * Add support for integer division. * diff --git a/sref.h b/sref.h deleted file mode 100644 index e566d88b6..000000000 --- a/sref.h +++ /dev/null @@ -1,167 +0,0 @@ -#ifndef __sref_H -#define __sref_H -/* - * Copyright (c) 1999 Stephen Williams (steve@icarus.com) - * - * This source code is free software; you can redistribute it - * and/or modify it in source code form under the terms of the GNU - * General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. In order to redistribute the software in - * binary form, you will need a Picture Elements Binary Software - * License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ -#if !defined(WINNT) && !defined(macintosh) -#ident "$Id: sref.h,v 1.5 2000/02/23 02:56:55 steve Exp $" -#endif - -# include -# include "svector.h" - -/* - * The sref class is a reference with automatic reference counting. It - * implementes a many-to-one linkage where T1 is the many type and T2 - * is the one type. - */ - -template class sref; -template class sref_back; - -template class sref_back { - - friend class sref; - - public: - sref_back() : sback_(0) { } - ~sref_back() { assert(sback_ == 0); } - - svector* back_list() const; - svector* back_list(); - - private: - void desert_(sref*); - sref*sback_; -}; - -template class sref { - - friend class sref_back; - - public: - sref(T1*d) : dest_(d) { insert_(); } - virtual ~sref() { dest_->desert_(this); } - - T1*fore_ptr() { return dest_; } - const T1*fore_ptr() const { return dest_; } - - private: - T1*dest_; - sref*next_; - - void insert_() - { if (dest_->sback_ == 0) { - next_ = this; - dest_->sback_ = this; - } else { - next_ = dest_->sback_->next_; - dest_->sback_->next_ = this; - } - } - -}; - -template -svector* sref_back::back_list() const -{ - if (sback_ == 0) return 0; - unsigned cnt = 1; - sref*cur = sback_->next_; - while (cur != sback_) { - cnt += 1; - cur = cur->next_; - } - - svector* result = new svector(cnt); - (*result)[0] = dynamic_cast(sback_); - cur = sback_->next_; - cnt = 1; - while (cur != sback_) { - (*result)[cnt] = dynamic_cast(cur); - cnt += 1; - cur = cur->next_; - } - return result; -} - -template -svector* sref_back::back_list() -{ - if (sback_ == 0) return 0; - unsigned cnt = 1; - sref*cur = sback_->next_; - while (cur != sback_) { - cnt += 1; - cur = cur->next_; - } - - svector* result = new svector(cnt); - (*result)[0] = dynamic_cast(sback_); - cur = sback_->next_; - cnt = 1; - while (cur != sback_) { - (*result)[cnt] = dynamic_cast(cur); - cnt += 1; - cur = cur->next_; - } - return result; -} - -template void sref_back::desert_(sref*item) -{ - if (item == sback_) - sback_ = item->next_; - - if (item == sback_) { - sback_ = 0; - - } else { - sref*cur = sback_; - while (cur->next_ != item) { - assert(cur->next_); - cur = cur->next_; - } - - cur->next_ = item->next_; - } -} - -/* - * $Log: sref.h,v $ - * Revision 1.5 2000/02/23 02:56:55 steve - * Macintosh compilers do not support ident. - * - * Revision 1.4 1999/08/05 04:58:17 steve - * Fix compile error with gcc 2.95 - * - * Revision 1.3 1999/07/18 21:17:51 steve - * Add support for CE input to XNF DFF, and do - * complete cleanup of replaced design nodes. - * - * Revision 1.2 1999/07/18 05:52:47 steve - * xnfsyn generates DFF objects for XNF output, and - * properly rewrites the Design netlist in the process. - * - * Revision 1.1 1999/05/01 02:57:53 steve - * Handle much more complex event expressions. - * - */ -#endif diff --git a/synth.cc b/synth.cc index b2c6d83c1..1b1fd2fb5 100644 --- a/synth.cc +++ b/synth.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: synth.cc,v 1.6 2000/02/23 02:56:55 steve Exp $" +#ident "$Id: synth.cc,v 1.7 2000/04/02 04:26:07 steve Exp $" #endif /* @@ -140,16 +140,13 @@ int match_dff::pevent(NetPEvent*pe) pclk_ = pe; - // ... there must be a single event source, ... - svector*neb = pclk_->back_list(); - if (neb == 0) + NetNEvent*tmp = pclk_->first(); + if (tmp == 0) return 0; - if (neb->count() != 1) { - delete neb; + if (pclk_->next()) return 0; - } - nclk_ = (*neb)[0]; - delete neb; + + nclk_ = tmp; return pclk_->statement()->match_proc(this); } @@ -273,6 +270,9 @@ void synth(Design*des) /* * $Log: synth.cc,v $ + * Revision 1.7 2000/04/02 04:26:07 steve + * Remove the useless sref template. + * * Revision 1.6 2000/02/23 02:56:55 steve * Macintosh compilers do not support ident. * diff --git a/t-vvm.cc b/t-vvm.cc index 0899ee467..bae6681d1 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-vvm.cc,v 1.128 2000/04/01 21:40:23 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.129 2000/04/02 04:26:07 steve Exp $" #endif # include @@ -1746,7 +1746,7 @@ void target_vvm::net_const(ostream&os, const NetConst*gate) */ void target_vvm::net_event(ostream&os, const NetNEvent*gate) { - string pevent = mangle(gate->fore_ptr()->name()); + string pevent = mangle(gate->pevent()->name()); os << " /* " << gate->name() << " */" << endl; bool&printed = pevent_printed_flag[pevent]; @@ -2453,9 +2453,12 @@ void target_vvm::proc_event(ostream&os, const NetPEvent*proc) POSEDGE is replaced with the correct type for the desired edge. */ - svector*list = proc->back_list(); - if ((list->count()==1) && ((*list)[0]->type() == NetNEvent::POSITIVE)) { - defn << " if (B_IS1(" << mangle((*list)[0]->name()) << + const NetNEvent*tmp = proc->first(); + if (tmp && (tmp->type() == NetNEvent::POSITIVE)) { + // POSITIVE can have only one input. + assert(0 == proc->next()); + + defn << " if (B_IS1(" << mangle(tmp->name()) << ".get(0))) {" << endl; defn << " return true;" << endl; defn << " } else {" << endl; @@ -2463,6 +2466,7 @@ void target_vvm::proc_event(ostream&os, const NetPEvent*proc) ".wait(this);" << endl; defn << " return false;" << endl; defn << " }" << endl; + } else { /* The canonical wait for an edge puts the thread into the correct wait object, then returns false from the @@ -2481,7 +2485,6 @@ void target_vvm::proc_event(ostream&os, const NetPEvent*proc) "_() {" << endl; proc->emit_proc_recurse(os, this); - delete list; } /* @@ -2528,6 +2531,9 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.129 2000/04/02 04:26:07 steve + * Remove the useless sref template. + * * Revision 1.128 2000/04/01 21:40:23 steve * Add support for integer division. * diff --git a/xnfsyn.cc b/xnfsyn.cc index 5ed2697d8..cb40d99f1 100644 --- a/xnfsyn.cc +++ b/xnfsyn.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: xnfsyn.cc,v 1.4 2000/02/23 02:56:56 steve Exp $" +#ident "$Id: xnfsyn.cc,v 1.5 2000/04/02 04:26:07 steve Exp $" #endif /* @@ -91,16 +91,12 @@ void xnfsyn_f::proc_always_(class Design*des) if (pclk_ == 0) return; - // ... there must be a single event source, ... - svector*neb = pclk_->back_list(); - if (neb == 0) + NetNEvent*tmp = pclk_->first(); + if (tmp == 0) return; - if (neb->count() != 1) { - delete neb; + if (pclk_->next()) return; - } - nclk_ = (*neb)[0]; - delete neb; + nclk_ = tmp; // ... the event must be an edge, ... switch (nclk_->type()) { @@ -236,6 +232,9 @@ void xnfsyn(Design*des) /* * $Log: xnfsyn.cc,v $ + * Revision 1.5 2000/04/02 04:26:07 steve + * Remove the useless sref template. + * * Revision 1.4 2000/02/23 02:56:56 steve * Macintosh compilers do not support ident. *