Remove the useless sref template.

This commit is contained in:
steve 2000-04-02 04:26:06 +00:00
parent 67bdd433a9
commit b62a7ace5c
7 changed files with 123 additions and 217 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
/* /*
@ -388,7 +388,7 @@ void NetNEvent::dump_node(ostream&o, unsigned ind) const
break; break;
} }
o << name() << " --> " << fore_ptr()->name() << endl; o << name() << " --> " << event_->name() << endl;
dump_node_pins(o, ind+4); 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 void NetPEvent::dump(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "@("; o << setw(ind) << "" << "@(";
svector<const NetNEvent*>*list = back_list();
(*list)[0]->dump_proc(o); if (src_) {
for (unsigned idx = 1 ; idx < list->count() ; idx += 1) { const NetNEvent*cur = src_;
o << " or "; for (cur = src_->next_ ; cur ; cur = cur->next_) {
(*list)[idx]->dump_proc(o); o << " or ";
cur->dump_proc(o);
}
} }
delete list;
o << ") /* " << name_ << " */"; o << ") /* " << name_ << " */";
if (statement_) { if (statement_) {
@ -904,6 +906,9 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $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 * Revision 1.71 2000/04/01 21:40:22 steve
* Add support for integer division. * Add support for integer division.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include <cassert> # include <cassert>
@ -1756,8 +1756,12 @@ const NetNet* NetFuncDef::port(unsigned idx) const
} }
NetNEvent::NetNEvent(const string&ev, unsigned wid, Type e, NetPEvent*pe) NetNEvent::NetNEvent(const string&ev, unsigned wid, Type e, NetPEvent*pe)
: NetNode(ev, wid), sref<NetPEvent,NetNEvent>(pe), edge_(e) : NetNode(ev, wid), edge_(e)
{ {
event_ = pe;
next_ = pe->src_;
pe->src_ = next_;
for (unsigned idx = 0 ; idx < wid ; idx += 1) { for (unsigned idx = 0 ; idx < wid ; idx += 1) {
pin(idx).set_name("P", idx); pin(idx).set_name("P", idx);
} }
@ -1767,25 +1771,38 @@ NetNEvent::~NetNEvent()
{ {
} }
NetPEvent::NetPEvent(const string&n, NetProc*st) NetNEvent::Type NetNEvent::type() const
: name_(n), statement_(st)
{ {
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() NetPEvent::~NetPEvent()
{ {
svector<NetNEvent*>*back = back_list(); while (src_) {
if (back) { NetNEvent*cur = src_;
for (unsigned idx = 0 ; idx < back->count() ; idx += 1) { src_ = src_->next_;
NetNEvent*ne = (*back)[idx]; delete cur;
delete ne;
}
delete back;
} }
delete statement_; delete statement_;
} }
string NetPEvent::name() const
{
return name_;
}
NetProc* NetPEvent::statement() NetProc* NetPEvent::statement()
{ {
return statement_; return statement_;
@ -1796,6 +1813,32 @@ const NetProc* NetPEvent::statement() const
return statement_; 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<NetExpr*>&pa) NetSTask::NetSTask(const string&na, const svector<NetExpr*>&pa)
: name_(na), parms_(pa) : name_(na), parms_(pa)
{ {
@ -2597,6 +2640,9 @@ bool NetUDP::sequ_glob_(string input, char output)
/* /*
* $Log: netlist.cc,v $ * $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 * Revision 1.110 2000/04/01 21:40:22 steve
* Add support for integer division. * Add support for integer division.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
/* /*
@ -31,7 +31,6 @@
# include <string> # include <string>
# include <map> # include <map>
# include "verinum.h" # include "verinum.h"
# include "sref.h"
# include "LineInfo.h" # include "LineInfo.h"
# include "svector.h" # include "svector.h"
@ -1319,17 +1318,24 @@ class NetPDelay : public NetProc {
* *
* The NetPEvent is the procedural part of the event. * The NetPEvent is the procedural part of the event.
*/ */
class NetNEvent; class NetPEvent : public NetProc {
class NetPEvent : public NetProc, public sref_back<NetPEvent,NetNEvent> {
friend class NetNEvent;
public: public:
NetPEvent(const string&n, NetProc*st); NetPEvent(const string&n, NetProc*st);
~NetPEvent(); ~NetPEvent();
string name() const { return name_; } string name() const;
NetProc* statement(); NetProc* statement();
const NetProc* statement() const; 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 int match_proc(struct proc_match_t*);
virtual bool emit_proc(ostream&, struct target_t*) const; virtual bool emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const; virtual void dump(ostream&, unsigned ind) const;
@ -1339,6 +1345,9 @@ class NetPEvent : public NetProc, public sref_back<NetPEvent,NetNEvent> {
private: private:
string name_; string name_;
NetProc*statement_; 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<NetPEvent,NetNEvent> {
* The NetNEvent may have wide input if is is an ANYEDGE type * The NetNEvent may have wide input if is is an ANYEDGE type
* device. This allows detecting changes in wide expressions. * device. This allows detecting changes in wide expressions.
*/ */
class NetNEvent : public NetNode, public sref<NetPEvent,NetNEvent> { class NetNEvent : public NetNode {
friend class NetPEvent;
public: public:
enum Type { ANYEDGE, POSEDGE, NEGEDGE, POSITIVE }; enum Type { ANYEDGE, POSEDGE, NEGEDGE, POSITIVE };
@ -1357,7 +1368,8 @@ class NetNEvent : public NetNode, public sref<NetPEvent,NetNEvent> {
NetNEvent(const string&ev, unsigned wid, Type e, NetPEvent*pe); NetNEvent(const string&ev, unsigned wid, Type e, NetPEvent*pe);
~NetNEvent(); ~NetNEvent();
Type type() const { return edge_; } Type type() const;
const NetPEvent*pevent() const;
virtual void emit_node(ostream&, struct target_t*) const; virtual void emit_node(ostream&, struct target_t*) const;
@ -1366,6 +1378,8 @@ class NetNEvent : public NetNode, public sref<NetPEvent,NetNEvent> {
private: private:
Type edge_; Type edge_;
NetPEvent*event_;
NetNEvent*next_;
}; };
@ -2266,6 +2280,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $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 * Revision 1.116 2000/04/01 21:40:22 steve
* Add support for integer division. * Add support for integer division.
* *

167
sref.h
View File

@ -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 <assert.h>
# 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 T1, class T2> class sref;
template <class T1, class T2> class sref_back;
template <class T1, class T2> class sref_back {
friend class sref<T1,T2>;
public:
sref_back() : sback_(0) { }
~sref_back() { assert(sback_ == 0); }
svector<const T2*>* back_list() const;
svector<T2*>* back_list();
private:
void desert_(sref<T1,T2>*);
sref<T1,T2>*sback_;
};
template <class T1, class T2> class sref {
friend class sref_back<T1,T2>;
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<T1,T2>*next_;
void insert_()
{ if (dest_->sback_ == 0) {
next_ = this;
dest_->sback_ = this;
} else {
next_ = dest_->sback_->next_;
dest_->sback_->next_ = this;
}
}
};
template <class T1,class T2>
svector<const T2*>* sref_back<T1,T2>::back_list() const
{
if (sback_ == 0) return 0;
unsigned cnt = 1;
sref<T1,T2>*cur = sback_->next_;
while (cur != sback_) {
cnt += 1;
cur = cur->next_;
}
svector<const T2*>* result = new svector<const T2*>(cnt);
(*result)[0] = dynamic_cast<const T2*>(sback_);
cur = sback_->next_;
cnt = 1;
while (cur != sback_) {
(*result)[cnt] = dynamic_cast<const T2*>(cur);
cnt += 1;
cur = cur->next_;
}
return result;
}
template <class T1,class T2>
svector<T2*>* sref_back<T1,T2>::back_list()
{
if (sback_ == 0) return 0;
unsigned cnt = 1;
sref<T1,T2>*cur = sback_->next_;
while (cur != sback_) {
cnt += 1;
cur = cur->next_;
}
svector<T2*>* result = new svector<T2*>(cnt);
(*result)[0] = dynamic_cast<T2*>(sback_);
cur = sback_->next_;
cnt = 1;
while (cur != sback_) {
(*result)[cnt] = dynamic_cast<T2*>(cur);
cnt += 1;
cur = cur->next_;
}
return result;
}
template <class T1, class T2> void sref_back<T1,T2>::desert_(sref<T1,T2>*item)
{
if (item == sback_)
sback_ = item->next_;
if (item == sback_) {
sback_ = 0;
} else {
sref<T1,T2>*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

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
/* /*
@ -140,16 +140,13 @@ int match_dff::pevent(NetPEvent*pe)
pclk_ = pe; pclk_ = pe;
// ... there must be a single event source, ... NetNEvent*tmp = pclk_->first();
svector<class NetNEvent*>*neb = pclk_->back_list(); if (tmp == 0)
if (neb == 0)
return 0; return 0;
if (neb->count() != 1) { if (pclk_->next())
delete neb;
return 0; return 0;
}
nclk_ = (*neb)[0]; nclk_ = tmp;
delete neb;
return pclk_->statement()->match_proc(this); return pclk_->statement()->match_proc(this);
} }
@ -273,6 +270,9 @@ void synth(Design*des)
/* /*
* $Log: synth.cc,v $ * $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 * Revision 1.6 2000/02/23 02:56:55 steve
* Macintosh compilers do not support ident. * Macintosh compilers do not support ident.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
# include <iostream> # include <iostream>
@ -1746,7 +1746,7 @@ void target_vvm::net_const(ostream&os, const NetConst*gate)
*/ */
void target_vvm::net_event(ostream&os, const NetNEvent*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; os << " /* " << gate->name() << " */" << endl;
bool&printed = pevent_printed_flag[pevent]; 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 POSEDGE is replaced with the correct type for the desired
edge. */ edge. */
svector<const NetNEvent*>*list = proc->back_list(); const NetNEvent*tmp = proc->first();
if ((list->count()==1) && ((*list)[0]->type() == NetNEvent::POSITIVE)) { if (tmp && (tmp->type() == NetNEvent::POSITIVE)) {
defn << " if (B_IS1(" << mangle((*list)[0]->name()) << // POSITIVE can have only one input.
assert(0 == proc->next());
defn << " if (B_IS1(" << mangle(tmp->name()) <<
".get(0))) {" << endl; ".get(0))) {" << endl;
defn << " return true;" << endl; defn << " return true;" << endl;
defn << " } else {" << endl; defn << " } else {" << endl;
@ -2463,6 +2466,7 @@ void target_vvm::proc_event(ostream&os, const NetPEvent*proc)
".wait(this);" << endl; ".wait(this);" << endl;
defn << " return false;" << endl; defn << " return false;" << endl;
defn << " }" << endl; defn << " }" << endl;
} else { } else {
/* The canonical wait for an edge puts the thread into /* The canonical wait for an edge puts the thread into
the correct wait object, then returns false from the the correct wait object, then returns false from the
@ -2481,7 +2485,6 @@ void target_vvm::proc_event(ostream&os, const NetPEvent*proc)
"_() {" << endl; "_() {" << endl;
proc->emit_proc_recurse(os, this); proc->emit_proc_recurse(os, this);
delete list;
} }
/* /*
@ -2528,6 +2531,9 @@ extern const struct target tgt_vvm = {
}; };
/* /*
* $Log: t-vvm.cc,v $ * $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 * Revision 1.128 2000/04/01 21:40:23 steve
* Add support for integer division. * Add support for integer division.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #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 #endif
/* /*
@ -91,16 +91,12 @@ void xnfsyn_f::proc_always_(class Design*des)
if (pclk_ == 0) if (pclk_ == 0)
return; return;
// ... there must be a single event source, ... NetNEvent*tmp = pclk_->first();
svector<class NetNEvent*>*neb = pclk_->back_list(); if (tmp == 0)
if (neb == 0)
return; return;
if (neb->count() != 1) { if (pclk_->next())
delete neb;
return; return;
} nclk_ = tmp;
nclk_ = (*neb)[0];
delete neb;
// ... the event must be an edge, ... // ... the event must be an edge, ...
switch (nclk_->type()) { switch (nclk_->type()) {
@ -236,6 +232,9 @@ void xnfsyn(Design*des)
/* /*
* $Log: xnfsyn.cc,v $ * $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 * Revision 1.4 2000/02/23 02:56:56 steve
* Macintosh compilers do not support ident. * Macintosh compilers do not support ident.
* *