Seabreeze : add fonction build_from_Node(Node*, Segment*)

This commit is contained in:
HoangAnhP 2022-06-14 12:34:44 +02:00
parent e9147299b0
commit e2c27cc039
4 changed files with 70 additions and 25 deletions

View File

@ -72,18 +72,19 @@ namespace Seabreeze {
return; return;
} }
cerr << "Root contact : " << ct << endl; cerr << "Root contact : " << ct << endl;
cerr << "Start building tree..." << endl << endl;; cerr << "Start building tree..." << endl;
Node* s = new Node(nullptr, ct); Node* s = new Node(nullptr, ct);
build_from_node(s); build_from_node(s);
cerr << endl << "Finished building tree !" << endl; cerr << "Finished building tree !" << endl << endl;
_tree->print(cerr); _tree->print(cerr);
} }
void Elmore::build_from_node ( Node* s ) void Elmore::build_from_node ( Node* s )
{ {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
cerr << "Elmore::build_from_node" << endl; // cerr << "Elmore::build_from_node" << endl;
cerr << "From contact : " << s->_contact << endl; // cerr << "From contact : " << s->_contact << endl;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
if ( s->_contact == nullptr ) { if ( s->_contact == nullptr ) {
cerr << "No contact found" << s->_contact << endl; cerr << "No contact found" << s->_contact << endl;
@ -102,13 +103,13 @@ namespace Seabreeze {
if ( not seg ) continue; if ( not seg ) continue;
//----------------------------------------- //-----------------------------------------
cerr << "Segment : " << seg << endl; // cerr << "Segment : " << seg << endl;
//----------------------------------------- //-----------------------------------------
Contact* ccont = dynamic_cast<Contact*>(seg->getOppositeAnchor(s->_contact)); Contact* ccont = dynamic_cast<Contact*>(seg->getOppositeAnchor(s->_contact));
//---------------------------------------------------------------- //----------------------------------------------------------------
cerr << "Target contc : " << ccont << endl; // cerr << "Target contc : " << ccont << endl;
//---------------------------------------------------------------- //----------------------------------------------------------------
if ( not ccont || (s->Np && ccont == (s->Np)->_contact) ) if ( not ccont || (s->Np && ccont == (s->Np)->_contact) )
@ -120,14 +121,13 @@ namespace Seabreeze {
} }
else { else {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
cerr << "Contact found in the net" << endl; // cerr << "Contact found in the net" << endl;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
if ( not s->Np || ccont != (s->Np)->_contact ) { if ( not s->Np || ccont != (s->Np)->_contact ) {
Node* node = new Node(s, ccont); Node* node = new Node(s, ccont);
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
cerr << "Parent node : " << node->Np->_contact << endl; // cerr << "Parent node : " << node->Np->_contact << endl;
cerr << endl; // cerr << endl;
cerr << endl;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
build_from_node(node); build_from_node(node);
} }
@ -136,6 +136,40 @@ namespace Seabreeze {
} }
} }
void Elmore::build_from_Node ( Node* s, Segment* seg ) {
if ( s->_contact == nullptr ) {
cerr << "No contact found" << s->_contact << endl;
return;
}
_tree->add_node(s);
Contact* ccont = dynamic_cast<Contact*>(seg->getOppositeAnchor(s->_contact));
if ( not ccont || (s->Np && ccont == (s->Np)->_contact) )
return;
ccont = build_branch(ccont);
if ( not ccont )
return;
Node* node = new Node(s, ccont);
int count = 1;
for ( Component* comp : ccont->getSlaveComponents() ) {
count += (dynamic_cast<Segment*>(comp)) ? 1 : 0;
}
if ( count == 1 ){
_tree->add_node(node);
}
else if ( count > 2 ) {
for ( Component* comp : ccont->getSlaveComponents() ) {
Segment* segmt = dynamic_cast<Segment*>(comp);
if ( not segmt ) continue;
build_from_Node(node, segmt);
}
}
}
Contact* Elmore::build_branch ( Contact* ct ) { Contact* Elmore::build_branch ( Contact* ct ) {
int count = 0; int count = 0;
checker.insert(ct); checker.insert(ct);
@ -143,21 +177,31 @@ namespace Seabreeze {
count += (dynamic_cast<Segment*>(cp)) ? 1 : 0; count += (dynamic_cast<Segment*>(cp)) ? 1 : 0;
} }
if ( count == 0 ) Contact* cont = nullptr;
if ( count == 0 ) {
cerr << "Something is not right here : Contact " << ct << " is isolated ?" << endl; cerr << "Something is not right here : Contact " << ct << " is isolated ?" << endl;
else if ( count != 2 ) }
return ct; else if ( count == 2 ) {
Segment* sm = nullptr;
for ( Component* cp : ct->getSlaveComponents() ) { for ( Component* cp : ct->getSlaveComponents() ) {
Segment* sm = dynamic_cast<Segment*>(cp); sm = dynamic_cast<Segment*>(cp);
if ( not sm ) continue; if ( not sm ) continue;
}
Contact* cct = dynamic_cast<Contact*>(sm->getOppositeAnchor(ct)); Contact* cct = dynamic_cast<Contact*>(sm->getOppositeAnchor(ct));
if ( not cct || find(checker.begin(), checker.end(), cct) != checker.end() ) if ( not cct || find(checker.begin(), checker.end(), cct) != checker.end() ) {
continue; cerr << "This branch leads to no where ?" << endl;
else }
else {
build_branch(cct); build_branch(cct);
} }
} }
else {
cont = ct;
}
return cont;
}
void Elmore::clearTree () void Elmore::clearTree ()
{ {

View File

@ -35,6 +35,7 @@ namespace Seabreeze {
void contFromNet ( Net* net ); void contFromNet ( Net* net );
void buildTree ( RoutingPad* rp ); void buildTree ( RoutingPad* rp );
void build_from_node ( Node* source ); void build_from_node ( Node* source );
void build_from_Node ( Node* source, Segment* seg );
Contact* build_branch ( Contact* ct ); Contact* build_branch ( Contact* ct );
void clearTree (); void clearTree ();
Tree* getTree (); Tree* getTree ();

View File

@ -109,7 +109,7 @@ namespace Seabreeze {
elm->contFromNet(net); elm->contFromNet(net);
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
cerr << endl; cerr << endl;
cerr << "There are : " << (elm->get_conts()).size() << " contacts" << endl; cerr << "There are : " << (elm->get_conts()).size() << " routing pads presented by :" << endl;
for ( Contact* ct : elm->get_conts() ) { for ( Contact* ct : elm->get_conts() ) {
cerr << ct << endl; cerr << ct << endl;
} }

View File

@ -131,7 +131,7 @@ int Tree::Delay_Elmore ( RoutingPad* rp )
void Tree::print ( ostream& out ) void Tree::print ( ostream& out )
{ {
out << "Start printing tree" << endl; out << "Start printing tree..." << endl;
out << "Tree has " << nodes.size() << " nodes :" << endl; out << "Tree has " << nodes.size() << " nodes :" << endl;
out << nodes[0]->label << " -> "; out << nodes[0]->label << " -> ";
for(Node* n : nodes[0]->Ne){ for(Node* n : nodes[0]->Ne){