Seabreeze : Step 1 - Building Tree is done. Going to step 2 - Compute RC
This commit is contained in:
parent
9b59c50efc
commit
d9db42447d
|
@ -49,7 +49,7 @@ namespace Seabreeze {
|
|||
for ( Component* c : rp->getSlaveComponents() ) {
|
||||
Contact* cont = dynamic_cast<Contact*>(c);
|
||||
|
||||
if ( cont ) {//&& find(_conts.begin(), _conts.end(), cont) != _conts.end() ) {
|
||||
if ( cont ) {
|
||||
ct = cont;
|
||||
break;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ namespace Seabreeze {
|
|||
cerr << "Start building tree..." << endl;
|
||||
|
||||
Node* s = new Node(nullptr, ct);
|
||||
// build_from_node(s);
|
||||
|
||||
Segment* seg = nullptr;
|
||||
int c = 0;
|
||||
for ( Component* comp : ct->getSlaveComponents() ) {
|
||||
|
@ -81,56 +81,17 @@ namespace Seabreeze {
|
|||
|
||||
cerr << endl << "Finished building tree !" << endl << endl;
|
||||
_tree->print(cerr);
|
||||
// cerr << "Tree built succesfully !" << endl;
|
||||
}
|
||||
|
||||
void Elmore::build_from_node ( Node* s )
|
||||
{
|
||||
if ( s->_contact == nullptr ) {
|
||||
cerr << "No contact found" << s->_contact << endl;
|
||||
cerr << "Tree build failed" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
_tree->add_node(s);
|
||||
|
||||
// To check for circle
|
||||
checker.insert(s->_contact);
|
||||
|
||||
for ( Component* comp : (s->_contact)->getSlaveComponents() ) {
|
||||
|
||||
Segment* seg = dynamic_cast<Segment*>(comp);
|
||||
|
||||
if ( not seg ) continue;
|
||||
|
||||
Contact* ccont = dynamic_cast<Contact*>(seg->getOppositeAnchor(s->_contact));
|
||||
if ( not ccont || (s->Np && ccont == (s->Np)->_contact) )
|
||||
continue;
|
||||
else{
|
||||
if ( find( checker.begin(), checker.end(), ccont) != checker.end() ) {
|
||||
cerr << "Net contains a circle. Cannot apply Elmore's delay here !" << endl;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if ( not s->Np || ccont != (s->Np)->_contact ) {
|
||||
Node* node = new Node(s, ccont);
|
||||
build_from_node(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Elmore::build_from_Node ( Node* s, Segment* seg ) {
|
||||
if ( s->_contact == nullptr ) {
|
||||
cerr << "No contact found" << s->_contact << endl;
|
||||
cerr << "Tree build failed" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
_tree->add_node(s);
|
||||
//----------------------------------------------------------------------------------------
|
||||
cerr << "Build from contact : " << s->_contact << endl;
|
||||
cerr << endl << endl << "Build from contact : " << s->_contact << endl;
|
||||
cerr << "With segment : " << seg << endl;
|
||||
//----------------------------------------------------------------------------------------
|
||||
Contact* ccont = dynamic_cast<Contact*>(seg->getOppositeAnchor(s->_contact));
|
||||
if ( not ccont || (s->Np && ccont == (s->Np)->_contact) )
|
||||
|
@ -138,127 +99,55 @@ namespace Seabreeze {
|
|||
//----------------------------------------------------------------------------------------
|
||||
cerr << "Target contact : " << ccont << endl;
|
||||
//----------------------------------------------------------------------------------------
|
||||
// ccont = build_branch(ccont);
|
||||
Contact* ctr = nullptr;
|
||||
build_branch(ctr, ccont);
|
||||
ccont = build_branch(ccont);
|
||||
//----------------------------------------------------------------------------------------
|
||||
cerr << "Found a node : " << ctr << endl;
|
||||
cerr << "Found a node : " << ccont << endl;
|
||||
//----------------------------------------------------------------------------------------
|
||||
// if ( not ccont ) {
|
||||
if ( not ctr ) {
|
||||
if ( not ccont ) {
|
||||
cerr << "This branch leads to a NULL contact ?" << endl;
|
||||
cerr << "Tree build failed" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Node* node = new Node(s, ccont);
|
||||
int count = 1;
|
||||
// for ( Component* comp : ccont->getSlaveComponents() ) {
|
||||
for ( Component* comp : ctr->getSlaveComponents() ) {
|
||||
int count = 0;
|
||||
for ( Component* comp : ccont->getSlaveComponents() ) {
|
||||
count += (dynamic_cast<Segment*>(comp)) ? 1 : 0;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------
|
||||
cerr << "This contact has : " << count << " segments" << endl;
|
||||
//-----------------------------------------------------------------------------------------
|
||||
if ( count == 1 ){
|
||||
_tree->add_node(node);
|
||||
}
|
||||
else if ( count > 2 ) {
|
||||
// for ( Component* comp : ccont->getSlaveComponents() ) {
|
||||
for ( Component* comp : ctr->getSlaveComponents() ) {
|
||||
for ( Component* comp : ccont->getSlaveComponents() ) {
|
||||
Segment* segmt = dynamic_cast<Segment*>(comp);
|
||||
if ( not segmt ) continue;
|
||||
build_from_Node(node, segmt);
|
||||
if ( not segmt )
|
||||
continue;
|
||||
//----------------------------------------------------------------------
|
||||
cerr << "Segment : " << segmt << endl;
|
||||
//----------------------------------------------------------------------
|
||||
Contact* target = dynamic_cast<Contact*>(segmt->getOppositeAnchor(ccont));
|
||||
if ( not target ) {
|
||||
cerr << "Wait... How can this happen ?" << endl;
|
||||
continue;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
cerr << "Target is : " << target << endl;
|
||||
//----------------------------------------------------------------------
|
||||
if ( checker.count(target) == 0 ){
|
||||
build_from_Node(node, segmt);
|
||||
cerr << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Elmore::build_branch ( Contact* ctr, Contact* ct ) {
|
||||
int count = 0;
|
||||
checker.insert(ct);
|
||||
//-----------------------------------------------------------------------------------
|
||||
cerr << "Build branch from contact : " << ct << endl;
|
||||
//-----------------------------------------------------------------------------------
|
||||
for ( Component* cp : ct->getSlaveComponents() ) {
|
||||
count += (dynamic_cast<Segment*>(cp)) ? 1 : 0;
|
||||
}
|
||||
|
||||
if ( count == 0 ) {
|
||||
cerr << "Something is not right here : Contact " << ct << " is isolated ?" << endl;
|
||||
}
|
||||
else if ( count == 2 ) {
|
||||
Segment* sm = nullptr;
|
||||
for ( Component* cp : ct->getSlaveComponents() ) {
|
||||
sm = dynamic_cast<Segment*>(cp);
|
||||
if ( not sm ) continue;
|
||||
}
|
||||
|
||||
Contact* cct = dynamic_cast<Contact*>(sm->getOppositeAnchor(ct));
|
||||
//------------------------------------------------------------------------------------
|
||||
cerr << "To contact : " << cct << endl;
|
||||
//------------------------------------------------------------------------------------
|
||||
if ( not cct || find(checker.begin(), checker.end(), cct) != checker.end() ) {
|
||||
cerr << "This branch leads to no where ?" << endl;
|
||||
}
|
||||
else {
|
||||
build_branch(ctr, cct);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ctr = ct;
|
||||
//-------------------------------------------------------------------
|
||||
cerr << "Return contact : " << ctr << endl;
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Contact* Elmore::build_branch ( Contact* ct ) {
|
||||
int count = 0;
|
||||
checker.insert(ct);
|
||||
//-----------------------------------------------------------------------------------
|
||||
cerr << "Build branch from contact : " << ct << endl;
|
||||
//-----------------------------------------------------------------------------------
|
||||
for ( Component* cp : ct->getSlaveComponents() ) {
|
||||
count += (dynamic_cast<Segment*>(cp)) ? 1 : 0;
|
||||
}
|
||||
|
||||
Contact* cont = nullptr;
|
||||
if ( count == 0 ) {
|
||||
cerr << "Something is not right here : Contact " << ct << " is isolated ?" << endl;
|
||||
}
|
||||
else if ( count == 2 ) {
|
||||
Segment* sm = nullptr;
|
||||
for ( Component* cp : ct->getSlaveComponents() ) {
|
||||
sm = dynamic_cast<Segment*>(cp);
|
||||
if ( not sm ) continue;
|
||||
}
|
||||
|
||||
Contact* cct = dynamic_cast<Contact*>(sm->getOppositeAnchor(ct));
|
||||
//------------------------------------------------------------------------------------
|
||||
cerr << "To contact : " << cct << endl;
|
||||
//------------------------------------------------------------------------------------
|
||||
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;
|
||||
//-------------------------------------------------------------------
|
||||
cerr << "Return contact : " << cont << endl;
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
cerr << "After the else : " << cont << endl;
|
||||
cerr << "Is this line printed twice ?" << endl;
|
||||
//-------------------------------------------------------------------
|
||||
return cont;
|
||||
}
|
||||
*/
|
||||
|
||||
Contact* Elmore::build_branch ( Contact* ct ) {
|
||||
Contact* tmp = ct;
|
||||
|
||||
//------------------------------------------------------
|
||||
cerr << endl << "Start building branch with contact : " << ct << endl;
|
||||
//------------------------------------------------------
|
||||
int count;
|
||||
do {
|
||||
checker.insert(tmp);
|
||||
|
@ -275,12 +164,25 @@ namespace Seabreeze {
|
|||
}
|
||||
else {
|
||||
Segment* sm = nullptr;
|
||||
Contact* cct = nullptr;
|
||||
for ( Component* cp : tmp->getSlaveComponents() ) {
|
||||
sm = dynamic_cast<Segment*>(cp);
|
||||
if ( not sm ) continue;
|
||||
if ( not sm )
|
||||
continue;
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
cerr << "Sm : " << sm << endl;
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
Contact* tar = dynamic_cast<Contact*>(sm->getOppositeAnchor(tmp));
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
cerr << "tar : " << tar << endl;
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
if ( tar && checker.count(tar) == 0 )
|
||||
cct = tar;
|
||||
}
|
||||
|
||||
Contact* cct = dynamic_cast<Contact*>(sm->getOppositeAnchor(ct));
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
cerr << "cct : " << cct << endl;
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
if ( not cct || checker.count(cct) != 0 ) {
|
||||
cerr << "This branch leads to no where ?" << endl;
|
||||
tmp = nullptr;
|
||||
|
@ -290,7 +192,9 @@ namespace Seabreeze {
|
|||
tmp = cct;
|
||||
}
|
||||
} while ( count == 2 );
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
cerr << "Branch done !" << endl;
|
||||
//----------------------------------------------------------------------------------------------
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,9 @@ namespace Seabreeze {
|
|||
Elmore ( Net* net = NULL );
|
||||
~Elmore ();
|
||||
void contFromNet ( Net* net );
|
||||
void buildTree ( RoutingPad* rp );
|
||||
void build_from_node ( Node* source );
|
||||
void buildTree ( RoutingPad* rp );
|
||||
void build_from_Node ( Node* source, Segment* seg );
|
||||
Contact* build_branch ( Contact* contact );
|
||||
void build_branch ( Contact* ctr, Contact* contact );
|
||||
void clearTree ();
|
||||
Tree* getTree ();
|
||||
inline const set<Contact*>& get_conts () const;
|
||||
|
|
|
@ -46,7 +46,8 @@ void Tree::new_node ()
|
|||
void Tree::add_node ( Node* node )
|
||||
{
|
||||
node->label = nodes.size();
|
||||
nodes.push_back(node);
|
||||
if ( find(nodes.begin(), nodes.end(), node) == nodes.end() )
|
||||
nodes.push_back(node);
|
||||
}
|
||||
|
||||
void Tree::After_i ( Node *ni )
|
||||
|
@ -133,21 +134,21 @@ void Tree::print ( ostream& out )
|
|||
{
|
||||
out << "Start printing tree..." << endl;
|
||||
out << "Tree has " << nodes.size() << " nodes :" << endl;
|
||||
out << nodes[0]->label << " -> ";
|
||||
out << nodes[0]->_contact << " -> ";
|
||||
for(Node* n : nodes[0]->Ne){
|
||||
out << n->label << ", ";
|
||||
out << n->_contact << ", ";
|
||||
}
|
||||
out << std::endl;
|
||||
|
||||
for ( size_t i = 1; i < nodes.size(); i++ ) {
|
||||
out << nodes[i]->Np->label
|
||||
<< " -> " << nodes[i]->label
|
||||
out << nodes[i]->Np->_contact
|
||||
<< " -> " << nodes[i]->_contact
|
||||
<< " : R = " << nodes[i]->R
|
||||
<< ", C = " << nodes[i]->C;
|
||||
if ( !(nodes[i]->Ne).empty() ) {
|
||||
out << " -> ";
|
||||
for ( Node* n : nodes[i]->Ne ) {
|
||||
out << n->label << ", ";
|
||||
out << n->_contact << ", ";
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue