From e2c27cc039c67b64c1173d14140532ea18d6e418 Mon Sep 17 00:00:00 2001 From: HoangAnhP Date: Tue, 14 Jun 2022 12:34:44 +0200 Subject: [PATCH] Seabreeze : add fonction build_from_Node(Node*, Segment*) --- Seabreeze/src/Seabreeze.cpp | 90 +++++++++++++++++++++-------- Seabreeze/src/Seabreeze/Seabreeze.h | 1 + Seabreeze/src/SeabreezeEngine.cpp | 2 +- Seabreeze/src/Tree.cpp | 2 +- 4 files changed, 70 insertions(+), 25 deletions(-) diff --git a/Seabreeze/src/Seabreeze.cpp b/Seabreeze/src/Seabreeze.cpp index 592c4a25..8d1a234f 100644 --- a/Seabreeze/src/Seabreeze.cpp +++ b/Seabreeze/src/Seabreeze.cpp @@ -72,18 +72,19 @@ namespace Seabreeze { return; } cerr << "Root contact : " << ct << endl; - cerr << "Start building tree..." << endl << endl;; + cerr << "Start building tree..." << endl; + Node* s = new Node(nullptr, ct); build_from_node(s); - cerr << endl << "Finished building tree !" << endl; + cerr << "Finished building tree !" << endl << endl; _tree->print(cerr); } void Elmore::build_from_node ( Node* s ) { //----------------------------------------------------------------------- - cerr << "Elmore::build_from_node" << endl; - cerr << "From contact : " << s->_contact << endl; +// cerr << "Elmore::build_from_node" << endl; +// cerr << "From contact : " << s->_contact << endl; //----------------------------------------------------------------------- if ( s->_contact == nullptr ) { cerr << "No contact found" << s->_contact << endl; @@ -102,13 +103,13 @@ namespace Seabreeze { if ( not seg ) continue; //----------------------------------------- - cerr << "Segment : " << seg << endl; +// cerr << "Segment : " << seg << endl; //----------------------------------------- Contact* ccont = dynamic_cast(seg->getOppositeAnchor(s->_contact)); //---------------------------------------------------------------- - cerr << "Target contc : " << ccont << endl; +// cerr << "Target contc : " << ccont << endl; //---------------------------------------------------------------- if ( not ccont || (s->Np && ccont == (s->Np)->_contact) ) @@ -120,14 +121,13 @@ namespace Seabreeze { } else { //----------------------------------------------------------------------- - cerr << "Contact found in the net" << endl; +// cerr << "Contact found in the net" << endl; //----------------------------------------------------------------------- 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 << endl; - cerr << endl; +// cerr << "Parent node : " << node->Np->_contact << endl; +// cerr << endl; //----------------------------------------------------------------------- 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(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(comp)) ? 1 : 0; + } + if ( count == 1 ){ + _tree->add_node(node); + } + else if ( count > 2 ) { + for ( Component* comp : ccont->getSlaveComponents() ) { + Segment* segmt = dynamic_cast(comp); + if ( not segmt ) continue; + build_from_Node(node, segmt); + } + } + } + Contact* Elmore::build_branch ( Contact* ct ) { int count = 0; checker.insert(ct); @@ -143,20 +177,30 @@ namespace Seabreeze { count += (dynamic_cast(cp)) ? 1 : 0; } - if ( count == 0 ) + Contact* cont = nullptr; + if ( count == 0 ) { cerr << "Something is not right here : Contact " << ct << " is isolated ?" << endl; - else if ( count != 2 ) - return ct; - - for ( Component* cp : ct->getSlaveComponents() ) { - Segment* sm = dynamic_cast(cp); - if ( not sm ) continue; - Contact* cct = dynamic_cast(sm->getOppositeAnchor(ct)); - if ( not cct || find(checker.begin(), checker.end(), cct) != checker.end() ) - continue; - else - build_branch(cct); } + else if ( count == 2 ) { + Segment* sm = nullptr; + for ( Component* cp : ct->getSlaveComponents() ) { + sm = dynamic_cast(cp); + if ( not sm ) continue; + } + + Contact* cct = dynamic_cast(sm->getOppositeAnchor(ct)); + if ( not cct || find(checker.begin(), checker.end(), cct) != checker.end() ) { + cerr << "This branch leads to no where ?" << endl; + } + else { + build_branch(cct); + } + } + else { + cont = ct; + } + + return cont; } void Elmore::clearTree () diff --git a/Seabreeze/src/Seabreeze/Seabreeze.h b/Seabreeze/src/Seabreeze/Seabreeze.h index 33f7b2c4..6d0279e1 100644 --- a/Seabreeze/src/Seabreeze/Seabreeze.h +++ b/Seabreeze/src/Seabreeze/Seabreeze.h @@ -35,6 +35,7 @@ namespace Seabreeze { void contFromNet ( Net* net ); void buildTree ( RoutingPad* rp ); void build_from_node ( Node* source ); + void build_from_Node ( Node* source, Segment* seg ); Contact* build_branch ( Contact* ct ); void clearTree (); Tree* getTree (); diff --git a/Seabreeze/src/SeabreezeEngine.cpp b/Seabreeze/src/SeabreezeEngine.cpp index 499cf509..5d86732a 100644 --- a/Seabreeze/src/SeabreezeEngine.cpp +++ b/Seabreeze/src/SeabreezeEngine.cpp @@ -109,7 +109,7 @@ namespace Seabreeze { elm->contFromNet(net); //------------------------------------------------------------------------- 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() ) { cerr << ct << endl; } diff --git a/Seabreeze/src/Tree.cpp b/Seabreeze/src/Tree.cpp index 4d0b2330..32c770c2 100644 --- a/Seabreeze/src/Tree.cpp +++ b/Seabreeze/src/Tree.cpp @@ -131,7 +131,7 @@ int Tree::Delay_Elmore ( RoutingPad* rp ) void Tree::print ( ostream& out ) { - out << "Start printing tree" << endl; + out << "Start printing tree..." << endl; out << "Tree has " << nodes.size() << " nodes :" << endl; out << nodes[0]->label << " -> "; for(Node* n : nodes[0]->Ne){