From ef8964c65ab8da788439f912a4a417b093b9cd2a Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 16 Mar 2006 05:40:18 +0000 Subject: [PATCH] Fix crash when memory exploding doesnot work --- netlist.cc | 35 ++++++++++++++++++++++++++++++++--- netlist.h | 12 +++++++++++- nodangle.cc | 8 +++++++- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/netlist.cc b/netlist.cc index 0a45e75ae..65b1d212d 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netlist.cc,v 1.226.2.3 2006/03/12 07:34:17 steve Exp $" +#ident "$Id: netlist.cc,v 1.226.2.4 2006/03/16 05:40:18 steve Exp $" #endif # include "config.h" @@ -229,7 +229,7 @@ NetNode::~NetNode() NetNet::NetNet(NetScope*s, perm_string n, Type t, unsigned npins) : NetObj(s, n, npins), sig_next_(0), sig_prev_(0), type_(t), port_type_(NOT_A_PORT), signed_(false), msb_(npins-1), lsb_(0), - local_flag_(false), eref_count_(0), lref_count_(0) + local_flag_(false), eref_count_(0), lref_count_(0), mref_(0) { assert(s); @@ -270,7 +270,7 @@ NetNet::NetNet(NetScope*s, perm_string n, Type t, long ms, long ls) : NetObj(s, n, ((ms>ls)?ms-ls:ls-ms) + 1), sig_next_(0), sig_prev_(0), type_(t), port_type_(NOT_A_PORT), signed_(false), msb_(ms), lsb_(ls), - local_flag_(false), eref_count_(0), lref_count_(0) + local_flag_(false), eref_count_(0), lref_count_(0), mref_(0) { assert(s); @@ -322,6 +322,14 @@ NetNet::~NetNet() dump_net(cerr, 4); } assert(lref_count_ == 0); + if (mref_ != 0) { + cerr << get_line() << ": internal error: attempt to delete " + << "signal ``" << name() << "'' which has " + << "memory explode references." << endl; + dump_net(cerr, 4); + } + assert(mref_ == 0); + if (scope()) scope()->rem_signal(this); @@ -462,6 +470,23 @@ unsigned NetNet::get_refs() const return lref_count_ + eref_count_; } +void NetNet::mref(NetMemory*mem) +{ + assert(mref_ == 0); + assert(mem != 0); + mref_ = mem; +} + +NetMemory*NetNet::mref() +{ + return mref_; +} + +const NetMemory* NetNet::mref() const +{ + return mref_; +} + NetSubnet::NetSubnet(NetNet*sig, unsigned off, unsigned wid) : NetNet(sig->scope(), sig->scope()->local_symbol(), sig->type(), wid) @@ -2103,6 +2128,7 @@ NetNet* NetMemory::explode_to_reg() return explode_; explode_ = new NetNet(scope_, name_, NetNet::REG, count()*width_); + explode_->mref(this); return explode_; } @@ -2362,6 +2388,9 @@ const NetProc*NetTaskDef::proc() const /* * $Log: netlist.cc,v $ + * Revision 1.226.2.4 2006/03/16 05:40:18 steve + * Fix crash when memory exploding doesnot work + * * Revision 1.226.2.3 2006/03/12 07:34:17 steve * Fix the memsynth1 case. * diff --git a/netlist.h b/netlist.h index 96d552e9e..6090485e4 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netlist.h,v 1.321.2.11 2006/03/12 07:34:17 steve Exp $" +#ident "$Id: netlist.h,v 1.321.2.12 2006/03/16 05:40:18 steve Exp $" #endif /* @@ -48,6 +48,7 @@ class ostream; class Design; class Link; class Nexus; +class NetMemory; class NetNode; class NetProc; class NetProcTop; @@ -434,6 +435,11 @@ class NetNet : public NetObj { unsigned get_refs() const; + /* This may be and explode of a memory. */ + void mref(NetMemory*ref); + NetMemory*mref(); + const NetMemory*mref() const; + virtual void dump_net(ostream&, unsigned) const; private: @@ -458,6 +464,7 @@ class NetNet : public NetObj { bool local_flag_; unsigned eref_count_; unsigned lref_count_; + NetMemory*mref_; }; /* @@ -3456,6 +3463,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.321.2.12 2006/03/16 05:40:18 steve + * Fix crash when memory exploding doesnot work + * * Revision 1.321.2.11 2006/03/12 07:34:17 steve * Fix the memsynth1 case. * diff --git a/nodangle.cc b/nodangle.cc index b90eee000..88ed57461 100644 --- a/nodangle.cc +++ b/nodangle.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: nodangle.cc,v 1.21 2004/02/20 18:53:35 steve Exp $" +#ident "$Id: nodangle.cc,v 1.21.2.1 2006/03/16 05:40:19 steve Exp $" #endif # include "config.h" @@ -109,6 +109,9 @@ void nodangle_f::signal(Design*des, NetNet*sig) if (sig->get_refs() > 0) return; + if (sig->mref()) + return; + /* Cannot delete the ports of tasks or functions. There are too many places where they are referenced. */ if ((sig->port_type() != NetNet::NOT_A_PORT) @@ -205,6 +208,9 @@ void nodangle(Design*des) /* * $Log: nodangle.cc,v $ + * Revision 1.21.2.1 2006/03/16 05:40:19 steve + * Fix crash when memory exploding doesnot work + * * Revision 1.21 2004/02/20 18:53:35 steve * Addtrbute keys are perm_strings. *