diff --git a/alliance/src/nero/src/MDefs.h b/alliance/src/nero/src/MDefs.h index 3b03aeb9..5e927ca6 100644 --- a/alliance/src/nero/src/MDefs.h +++ b/alliance/src/nero/src/MDefs.h @@ -1,7 +1,7 @@ // -*- C++ -*- // -// $Id: MDefs.h,v 1.4 2002/10/29 18:46:03 jpc Exp $ +// $Id: MDefs.h,v 1.5 2002/11/04 14:43:08 jpc Exp $ // // /-----------------------------------------------------------------\ // | | @@ -534,6 +534,26 @@ + // --------------------------------------------------------------- + // Terminal merging exception. + + class merge_term : public except_done { + + // Attributes. + public: int id; + + // Constructor. + public: merge_term (int mergeid) { id = mergeid; } + + // Overridables. + public: const char* what () const throw () { + return ((char*)"Terminal must be merged."); + } + }; + + + + // --------------------------------------------------------------- // Terminal class. @@ -558,8 +578,9 @@ // Modifiers. public: CNode *newaccess (int x, int y, int z, int ident, CNet *net) - throw (dup_term, bad_grab); + throw (dup_term, bad_grab, merge_term); public: void newaccess (CRect &rect, int z, int ident, CNet *net); + public: void merge (CTerm *other, int ident, CNet *net); public: void lockalone (bool global=false); public: void setid (int ident); diff --git a/alliance/src/nero/src/MNet.cpp b/alliance/src/nero/src/MNet.cpp index d5bcc44d..9c45e0b1 100644 --- a/alliance/src/nero/src/MNet.cpp +++ b/alliance/src/nero/src/MNet.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // -// $Id: MNet.cpp,v 1.5 2002/10/29 18:46:03 jpc Exp $ +// $Id: MNet.cpp,v 1.6 2002/11/04 14:43:08 jpc Exp $ // // /----------------------------------------------------------------\ // | | @@ -50,11 +50,11 @@ CTerm::~CTerm (void) //list::iterator pNode; - //for (pNode = nodes.begin (); pNode != nodes.end (); pNode++) { - // if ((*pNode)->coord.z() == 0) delete (*pNode); - //} + //for (pNode = nodes.begin (); pNode != nodes.end (); pNode++) + // (*pNode)->ungrab (); nodes.clear (); + rects.clear (); } @@ -139,7 +139,7 @@ CDRGrid::iterator &CTerm::lowest (void) // Method : "CTerm::newaccess()". CNode *CTerm::newaccess (int x, int y, int z, int ident, CNet *net) - throw (dup_term, bad_grab) + throw (dup_term, bad_grab, merge_term) { list::iterator itNode; CDRGrid::iterator coord; @@ -150,30 +150,38 @@ CNode *CTerm::newaccess (int x, int y, int z, int ident, CNet *net) coord = net->_drgrid->origin; coord.set (x, y, z); - // Check if the node is already in the list... - for (itNode = nodes.begin (); itNode != nodes.end (); itNode++) { - if (*itNode == coord) { - throw dup_term (name, *itNode); - } - } - pNode = &coord.node (); if ((z == 0) && coord.isnodehole()) { pNode = &coord.addnode (); } - // Check if the node has already been took by another terminal. - if (pNode->data.owner && (pNode->data.owner != net)) - throw bad_grab ( pNode->data.owner->terms[pNode->getid()]->name - , net->name - , coord.x() - , coord.y() - , coord.z() - , 0 - , pNode->data.pri - , pNode->terminal() - , pNode->data.ident - ); + if (pNode->data.owner) { + // Check if the node has already been took by another terminal. + if (pNode->data.owner != net) + throw bad_grab ( pNode->data.owner->terms[pNode->getid()]->name + , net->name + , coord.x() + , coord.y() + , coord.z() + , 0 + , pNode->data.pri + , pNode->terminal() + , pNode->data.ident + ); + + // Check if the node belongs to another terminal of this net. + // If so, send a merging exception to CNet::newaccess (). + if (pNode->getid () != ident) throw merge_term ( pNode->getid () ); + + return (NULL); + } + + // Check if the node is already in the list (this should never appens !) + for (itNode = nodes.begin (); itNode != nodes.end (); itNode++) { + if (*itNode == coord) { + throw dup_term (name, *itNode); + } + } pNode->data.owner = net; pNode->data.obstacle = false; @@ -211,6 +219,23 @@ void CTerm::newaccess (CRect &rect, int z, int ident, CNet *net) +// ------------------------------------------------------------------- +// Method : "CTerm::merge()". + +void CTerm::merge (CTerm *other, int ident, CNet *Net) +{ + list::iterator coord; + + + for (coord = other->nodes.begin (); coord != other->nodes.end (); coord++) { + (*coord).node().setid (ident); + nodes.push_back (*coord); + } +} + + + + // ------------------------------------------------------------------- // Method : "CTerm::lockalone()". @@ -423,7 +448,7 @@ void CNet::newaccess (string termName, int x, int y, int z) void CNet::newaccess (string termName, CRect &rect, int z) { CCoord coord; - int id; + int id, mergeid; // Find the terminal in the table. @@ -440,7 +465,31 @@ void CNet::newaccess (string termName, CRect &rect, int z) } // Add the access to the terminal & update the bounding box. - terms[id]->newaccess (rect, z, id, this); + do { + mergeid = INT_MAX; + + try { + terms[id]->newaccess (rect, z, id, this); + } + + catch (merge_term &e) { + mergeid = e.id; + + // Merge terminals ... + terms[mergeid]->merge (terms[id], mergeid, this); + + // Erase the merged terminal. + delete terms[id]; + terms.erase (terms.begin () + id); + + size -= 1; + + // Re-computes the terminal's ids. + for (id = 0; id < size; id++) terms[id]->setid (id); + + id = mergeid; + } + } while (mergeid != INT_MAX); // Update the bounding box. bb.merge (coord.set (rect.x1, rect.y1, z)); diff --git a/alliance/src/nero/src/RBox.cpp b/alliance/src/nero/src/RBox.cpp index 5819b890..f0a40904 100644 --- a/alliance/src/nero/src/RBox.cpp +++ b/alliance/src/nero/src/RBox.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // -// $Id: RBox.cpp,v 1.2 2002/10/29 18:46:03 jpc Exp $ +// $Id: RBox.cpp,v 1.3 2002/11/04 14:43:08 jpc Exp $ // // /----------------------------------------------------------------\ // | | @@ -168,6 +168,46 @@ void CRBox::route (void) +// ------------------------------------------------------------------- +// Method : "CRBox::findnet()". + +CNet *CRBox::findnet (char *signame) +{ + string name; + + + name = signame; + + return (findnet(name)); +} + + + + +// ------------------------------------------------------------------- +// Method : "CRBox::findnet()". + +CNet *CRBox::findnet (string &signame) +{ + MNet::iterator itNet, endNet; + CNet *pNet; + + + endNet = nets.end (); + itNet = nets.find (signame); + + if (itNet == endNet) { + pNet = NULL; + } else + pNet = itNet->second; + + + return (pNet); +} + + + + // ------------------------------------------------------------------- // Method : "CRBox::getnet()". diff --git a/alliance/src/nero/src/RDefs.h b/alliance/src/nero/src/RDefs.h index 7d9acf0a..4d8fc333 100644 --- a/alliance/src/nero/src/RDefs.h +++ b/alliance/src/nero/src/RDefs.h @@ -1,7 +1,7 @@ // -*- C++ -*- // -// $Id: RDefs.h,v 1.2 2002/10/29 18:46:03 jpc Exp $ +// $Id: RDefs.h,v 1.3 2002/11/04 14:43:08 jpc Exp $ // // /-----------------------------------------------------------------\ // | | @@ -58,6 +58,8 @@ public: ~CRBox (void); // Modifiers. + public: CNet *findnet (string &signame); + public: CNet *findnet (char *signame); public: CNet *getnet (string &signame); public: CNet *getnet (char *signame); public: void mbkload (MBK::CFig *mbkfig, int z, int zup, int rtype); diff --git a/alliance/src/nero/src/RMBK.cpp b/alliance/src/nero/src/RMBK.cpp index cd453132..75c8c28e 100644 --- a/alliance/src/nero/src/RMBK.cpp +++ b/alliance/src/nero/src/RMBK.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // -// $Id: RMBK.cpp,v 1.5 2002/10/29 18:46:03 jpc Exp $ +// $Id: RMBK.cpp,v 1.6 2002/11/04 14:43:08 jpc Exp $ // // /----------------------------------------------------------------\ // | | @@ -111,6 +111,44 @@ void CRBox::mbkload (MBK::CFig *mbkfig, int z, int zup, int rtype) rect = new MBK::CXRect (fig->XAB1(), fig->YAB1()); + cmess2 << " o Loading external terminals.\n"; + + // Browse layout for terminals. + for (pPhcon = fig->phfig.fig->PHCON; pPhcon != NULL; pPhcon = pPhcon->NEXT) { + if (fig->lofig.signals.find(pPhcon->NAME) == endSig) { + cerr << hwarn ("") + << " The terminal \"" << pPhcon->NAME << "\" at (" + << MBK::UNSCALE (pPhcon->XCON) << "," + << MBK::UNSCALE (pPhcon->YCON) << ") layer " + << MBK::layer2a (pPhcon->LAYER) << "\n" + << " do not not belong to any logical signal : ignored.\n"; + + continue; + } + + pNet = getnet (pPhcon->NAME); + + term_name = "external."; + term_name += pPhcon->NAME; + + flatSeg.X1 = pPhcon->XCON; + flatSeg.Y1 = pPhcon->YCON; + flatSeg.X2 = pPhcon->XCON; + flatSeg.Y2 = pPhcon->YCON; + flatSeg.WIDTH = MBK::env.layer2width (pPhcon->LAYER); + flatSeg.LAYER = pPhcon->LAYER; + flatSeg.NAME = pPhcon->NAME; + + rect->setSeg (flatSeg); + + pNet->newaccess ( term_name + , rect->grid + , MBK::env.layer2z (pPhcon->LAYER) + ); + + } + + cmess2 << " o Finding obstacles.\n"; @@ -201,42 +239,6 @@ void CRBox::mbkload (MBK::CFig *mbkfig, int z, int zup, int rtype) } - // Browse layout for terminals. - for (pPhcon = fig->phfig.fig->PHCON; pPhcon != NULL; pPhcon = pPhcon->NEXT) { - if (fig->lofig.signals.find(pPhcon->NAME) == endSig) { - cerr << hwarn ("") - << " The terminal \"" << pPhcon->NAME << "\" at (" - << MBK::UNSCALE (pPhcon->XCON) << "," - << MBK::UNSCALE (pPhcon->YCON) << ") layer " - << MBK::layer2a (pPhcon->LAYER) << "\n" - << " do not not belong to any logical signal : ignored.\n"; - - continue; - } - - pNet = getnet (pPhcon->NAME); - - term_name = "external."; - term_name += pPhcon->NAME; - - flatSeg.X1 = pPhcon->XCON; - flatSeg.Y1 = pPhcon->YCON; - flatSeg.X2 = pPhcon->XCON; - flatSeg.Y2 = pPhcon->YCON; - flatSeg.WIDTH = MBK::env.layer2width (pPhcon->LAYER); - flatSeg.LAYER = pPhcon->LAYER; - flatSeg.NAME = pPhcon->NAME; - - rect->setSeg (flatSeg); - - pNet->newaccess ( term_name - , rect->grid - , MBK::env.layer2z (pPhcon->LAYER) - ); - - } - - // Browse instances & orphans for obstacles. for (itIns = fig->instances.begin(); ; itIns++) { if (itIns == endInstances) itIns = fig->orphans.begin (); diff --git a/alliance/src/nero/src/nero.cpp b/alliance/src/nero/src/nero.cpp index aaac0845..79538cad 100644 --- a/alliance/src/nero/src/nero.cpp +++ b/alliance/src/nero/src/nero.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // -// $Id: nero.cpp,v 1.3 2002/10/29 18:46:03 jpc Exp $ +// $Id: nero.cpp,v 1.4 2002/11/04 14:43:08 jpc Exp $ // // /----------------------------------------------------------------\ // | | @@ -94,7 +94,7 @@ static void help (void) static void serial (void) { - cout << " S/N 20021028.1\n"; + cout << " S/N 20021104.1\n"; }