Merge branch 'devel' of gitlab.lip6.fr:vlsi-eda/coriolis into devel

This commit is contained in:
Jean-Paul Chaput 2022-07-13 11:48:48 +02:00
commit db0ecb878d
12 changed files with 471 additions and 72 deletions

27
Seabreeze/README.txt Normal file
View File

@ -0,0 +1,27 @@
Fonctions dans Seabreeze.cpp :
---------------------------------------------------------------------
contFromNet ( Net* net )
{
ajouter les contacts dans net au set<Contact*> _conts;
}
buildTree ( RoutingPad* rp )
{
Construire l'arbre de rp, ça veux dire le contact trouvé dans rp sera la racine de l'arbre
}
build_from_Node ( Node* source, Segment* seg )
{
Après avoir crée le premier node / la racine dans buildTree, on va l'utiliser pour construire l'arbre.
}
build_branch ( double* R, double* C, Contact* contact )
{
Parcourir la branche et trouver le Node suivant de l'arbre
}
Set_RC ( double* R, double* C, Contact* ct, Segment* sm )
{
Calculer le RC de la branche ct-sm et ajouter la valeur dans R et C
}

View File

@ -20,6 +20,7 @@
Seabreeze.cpp Seabreeze.cpp
Node.cpp Node.cpp
Tree.cpp Tree.cpp
Configuration.cpp
#GraphicSeabreezeEngine.cpp #GraphicSeabreezeEngine.cpp
) )
set( pyCpps PySeabreeze.cpp set( pyCpps PySeabreeze.cpp

View File

@ -0,0 +1,83 @@
#include <iostream>
#include <iomanip>
#include "hurricane/configuration/Configuration.h"
#include "hurricane/Warning.h"
#include "hurricane/Error.h"
#include "hurricane/Technology.h"
#include "hurricane/DataBase.h"
#include "hurricane/RoutingPad.h"
#include "hurricane/Contact.h"
#include "hurricane/Net.h"
#include "hurricane/Segment.h"
#include "hurricane/Cell.h"
#include "crlcore/Utilities.h"
#include "Seabreeze/Configuration.h"
namespace Seabreeze {
using std::string;
using Hurricane::Warning;
using Hurricane::Error;
using Hurricane::Technology;
using Hurricane::RoutingPad;
using Hurricane::Contact;
using Hurricane::Segment;
using Hurricane::Cell;
using Hurricane::Net;
using Hurricane::DataBase;
using Hurricane::Record;
using Hurricane::Name;
using Hurricane::Layer;
using Hurricane::DbU;
//------------------------------------------------------------------------
// Class : "Seabreeze::Configuration"
Configuration::Configuration ()
: _Rct (1)
, _Rsm (1)
, _Csm (1)
{}
Configuration::~Configuration ()
{}
Configuration::Configuration ( const Configuration& other )
: _Rct (other._Rct)
, _Rsm (other._Rsm)
, _Csm (other._Csm)
{}
Configuration* Configuration::clone () const
{ return new Configuration(*this); }
double Configuration::getRct ()
{
return _Rct;
}
double Configuration::getRsm ()
{
return _Rsm;
}
double Configuration::getCsm ()
{
return _Csm;
}
/*
Record* Configuration::_getRecord () const
{
}
string Configuration::_getString () const
{
}
*/
string Configuration::_getTypeName () const
{
return "Configuration";
}
}

View File

@ -16,7 +16,10 @@ Node::Node ( Node* p, Contact* ct )
, _contact(ct) , _contact(ct)
, label(-1) , label(-1)
, ap(0) , ap(0)
{ (p->Ne).push_back(this); } {
if( p != nullptr)
(p->Ne).push_back(this);
}
Node::~Node () Node::~Node ()
{} {}

View File

@ -1,23 +1,29 @@
#include "Seabreeze/Seabreeze.h" #include "Seabreeze/Seabreeze.h"
#include "hurricane/Net.h" #include "hurricane/Net.h"
#include "hurricane/Segment.h"
#include "hurricane/DebugSession.h"
namespace Seabreeze { namespace Seabreeze {
using namespace std; using namespace std;
using Hurricane::DBo; using Hurricane::DBo;
using Hurricane::DbU;
using Hurricane::Net; using Hurricane::Net;
using Hurricane::Cell; using Hurricane::Cell;
using Hurricane::Instance; using Hurricane::Instance;
using Hurricane::PrivateProperty; using Hurricane::PrivateProperty;
using Hurricane::Component; using Hurricane::Component;
using Hurricane::Segment;
using Hurricane::DebugSession;
//--------------------------------------------------------- //---------------------------------------------------------
// Class : "Elmore" // Class : "Elmore"
Elmore::Elmore ( Net* net ) Elmore::Elmore ( Net* net )
: _conts() : _config (new Configuration())
, checker() , _conts ()
, _tree() , checker ()
, _tree (new Tree())
{} {}
Elmore::~Elmore () Elmore::~Elmore ()
@ -27,12 +33,9 @@ namespace Seabreeze {
void Elmore::contFromNet ( Net* net ) { void Elmore::contFromNet ( Net* net ) {
for ( RoutingPad* rp : net->getRoutingPads() ) { for ( RoutingPad* rp : net->getRoutingPads() ) {
for ( Component* comp : rp->getSlaveComponents() ) {
for ( Component* c : rp->getSlaveComponents() ) { Contact* ct = dynamic_cast<Contact*>(comp);
Contact* ct = dynamic_cast<Contact*>(c);
if ( not ct ) continue; if ( not ct ) continue;
_conts.insert(ct); _conts.insert(ct);
} }
} }
@ -42,50 +45,227 @@ namespace Seabreeze {
{ {
if ( rp == nullptr ) { if ( rp == nullptr ) {
cerr << "Input RoutingPad is NULL. Please select a RoutingPad !" << endl; cerr << "Input RoutingPad is NULL. Please select a RoutingPad !" << endl;
cerr << "Cannot build tree" << endl;
return; return;
} }
Contact* ct = dynamic_cast<Contact*>(rp);
if ( not ct ) { Contact* ct = nullptr;
for ( Component* c : rp->getSlaveComponents() ) {
Contact* cont = dynamic_cast<Contact*>(c);
if ( cont ) {
ct = cont;
break;
}
}
if ( ct == nullptr ) {
cerr << "No contact found" << endl; cerr << "No contact found" << endl;
cerr << "Cannot build tree" << endl;
return; return;
} }
cerr << "Root contact : " << ct->getId() << endl;
cerr << "Start building tree..." << endl;
checker.insert(ct);
Node* s = new Node(nullptr, ct); Node* s = new Node(nullptr, ct);
build_from_node(s); //---------------------------------------------------------
double R = 0;
double C = 0;
Set_RC(&R, &C, ct, nullptr);
s->R = R;
if ( C == 0 )
s->C = 0;
else
s->C = 1/C;
//---------------------------------------------------------
Segment* seg = nullptr;
int c = 0;
for ( Component* comp : ct->getSlaveComponents() ) {
seg = dynamic_cast<Segment*>(comp);
if ( not seg ) continue;
c++;
} }
if ( c != 1 ) {
void Elmore::build_from_node ( Node* s ) cerr << "Not begin with a RoutingPad ? Something doesn't seem right : " << c << " linked segments" << endl;
{ cerr << "Tree build failed" << endl;
if ( s->_contact == nullptr || find(_conts.begin(), _conts.end(), s->_contact) == _conts.end() ) {
return; return;
} }
build_from_Node(s, seg);
cerr << endl << "Finished building tree !" << endl << endl;
_tree->print(cerr);
}
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); _tree->add_node(s);
// To check for circle cdebug_log(199,0) << endl
checker.insert(s->_contact); << endl
<< "Build from contact : " << s->_contact->getId() << endl
<< "With segment : " << seg->getId() << endl;
for ( Component* c : (s->_contact)->getSlaveComponents() ) { Contact* ccont = dynamic_cast<Contact*>(seg->getOppositeAnchor(s->_contact));
if ( not ccont || (s->Np && ccont == (s->Np)->_contact) )
return;
Contact* ccont = dynamic_cast<Contact*>(c); cdebug_log(199,0) << "Target contact : " << ccont->getId() << endl;
//-----------------------------------------------------------------------
double Rb = 0;
double Cb = 0;
//-----------------------------------------------------------------------
ccont = build_branch(&Rb, &Cb, ccont);
if ( not ccont ) cdebug_log(199, 0) << "Found a node : " << ccont->getId() << endl;
continue;
else{
if ( find( _conts.begin(), _conts.end(), ccont) != _conts.end() ) {
if ( find( checker.begin(), checker.end(), ccont) != checker.end() ) { if ( not ccont ) {
cerr << "Net contains a circle. Cannot apply Elmore's delay here !" << endl; cerr << "This branch leads to a NULL contact ?" << endl;
return; return;
} }
Node* node = new Node(s, ccont);
//-----------------------------------------------------------------------
node->R = Rb;
if ( Cb == 0 )
node->C = 0;
else
node->C = 1/Cb;
cdebug_log(199,0) << "R = " << Rb << "; C = " << Cb << endl;
//-----------------------------------------------------------------------
int count = 0;
for ( Component* comp : ccont->getSlaveComponents() ) {
count += (dynamic_cast<Segment*>(comp)) ? 1 : 0;
}
cdebug_log(199,0) << "This node's contact has : " << count << " segments" << endl;
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;
cdebug_log(199,1) << "Segment : " << segmt->getId() << endl;
cdebug_tabw(199,-1);
Contact* target = dynamic_cast<Contact*>(segmt->getOppositeAnchor(ccont));
if ( not target ) {
cerr << "Wait... How can this happen ?" << endl;
continue;
}
cdebug_log(199,0) << "Target is : " << target->getId() << endl;
cdebug_tabw(199,-1);
if ( checker.count(target) == 0 ){
build_from_Node(node, segmt);
cdebug_log(199,0) << endl;
}
}
}
}
Contact* Elmore::build_branch ( double* R, double* C, Contact* ct )
{
Contact* tmp = ct;
cdebug_log(199,1) << endl << "Start building branch with contact : " << ct->getId() << endl;
int count;
do {
checker.insert(tmp);
count = 0;
Segment* sm = nullptr;
for ( Component* cp : tmp->getSlaveComponents() ) {
sm = dynamic_cast<Segment*>(cp);
if ( not sm )
continue;
Contact* tar = dynamic_cast<Contact*>(sm->getOppositeAnchor(tmp));
if ( tar && checker.count(tar) != 0 ) {
Set_RC(R, C, tmp, sm);
cdebug_log(199,0) << "RC from build_branch :" << endl;
cdebug_log(199,0) << "tmp = " << tmp->getId() << "; sm = " << sm->getId() << "; R = " << *R << "; C = " << *C << endl;
}
count += 1;
}
if ( count == 0 ) {
cerr << "Something is not right here : Contact " << tmp << " is isolated ?" << endl;
break;
}
else if ( count != 2 ) {
break;
}
else { else {
if ( ccont != (s->Np)->_contact ) { Contact* cct = nullptr;
Node* node = new Node( s, ccont ); for ( Component* cp : tmp->getSlaveComponents() ) {
build_from_node(node); sm = dynamic_cast<Segment*>(cp);
if ( not sm )
continue;
cdebug_log(199,1) << "Sm : " << sm->getId() << endl;
cdebug_tabw(199,-1);
Contact* tar = dynamic_cast<Contact*>(sm->getOppositeAnchor(tmp));
cdebug_log(199,0) << "tar : " << tar->getId() << endl << endl;
if ( tar && checker.count(tar) == 0 )
cct = tar;
} }
cdebug_tabw(199,-1);
cdebug_log(199,0) << "cct : " << cct->getId() << endl;
if ( not cct || checker.count(cct) != 0 ) {
cerr << "This branch leads to no where ?" << endl;
tmp = nullptr;
break;
} }
else
tmp = cct;
} }
} while ( count == 2 );
cdebug_tabw(199,-1);
cdebug_log(199,0) << "Branch done !" << endl;
return tmp;
} }
void Elmore::Set_RC ( double* R, double* C, Contact* ct, Segment* sm ) {
double Rct = getConfig()->getRct();
//double h_ct = DbU::toPhysical(ct->getHeight(), DbU::UnitPower::Nano);
double w_ct = DbU::toPhysical(ct->getWidth(), DbU::UnitPower::Nano);
double S_ct = w_ct*w_ct;
(*R) += Rct*S_ct;
if ( sm == nullptr ) {
*C = 0;
}
else {
double Rsm = getConfig()->getRsm();
double Csm = getConfig()->getCsm();
double l_sm = DbU::toPhysical(sm->getLength(), DbU::UnitPower::Nano);
double w_sm = DbU::toPhysical(sm->getWidth(), DbU::UnitPower::Nano);
double S_sm = l_sm*w_sm;
//---------------------------------------------------------------------------------------
cdebug_log(199,0) << "sm = " << sm->getId() << "; l_sm = " << l_sm << "; w_sm = " << w_sm << "; S_sm = " << S_sm << endl;
//---------------------------------------------------------------------------------------
(*R) += Rsm*S_sm;
if ( S_sm == 0 )
(*C) += 0;
else
(*C) += 1/(Csm*S_sm);
} }
} }

View File

@ -0,0 +1,59 @@
#pragma once
#include <string>
#include <vector>
#include <hurricane/DbU.h>
namespace Hurricane {
class Layer;
class Cell;
class Net;
class RoutingPad;
class Contact;
class Segment;
}
namespace CRL {
class CellGauge;
class RoutingGauge;
class RoutingLayerGauge;
}
namespace Seabreeze {
using std::string;
using Hurricane::Record;
using Hurricane::Name;
using Hurricane::Layer;
using Hurricane::DbU;
using Hurricane::RoutingPad;
using Hurricane::Cell;
using Hurricane::Net;
using Hurricane::Contact;
using Hurricane::Segment;
//------------------------------------------------------------------------
// Class : "Seabreeze::Configuration"
class Configuration {
public :
// Constructor & Destructor
virtual Configuration* clone () const;
Configuration ();
Configuration ( const Configuration& );
~Configuration ();
// Methods
double getRct ();
double getRsm ();
double getCsm ();
//virtual Record* _getRecord () const;
//virtual string _getString () const;
virtual string _getTypeName () const;
protected :
// Attributes
double _Rct;
double _Rsm;
double _Csm;
private :
Configuration& operator = ( const Configuration& ) = delete;
};
}

View File

@ -8,9 +8,9 @@ using Hurricane::Contact;
class Node { class Node {
public : public :
int R; double R;
int Rt; double Rt;
int C; double C;
Node* Np; Node* Np;
std::vector<Node*> Ne; std::vector<Node*> Ne;
Contact* _contact; Contact* _contact;

View File

@ -5,7 +5,8 @@
#include "hurricane/Property.h" #include "hurricane/Property.h"
#include "hurricane/RoutingPad.h" #include "hurricane/RoutingPad.h"
#include "hurricane/Contact.h" #include "hurricane/Contact.h"
#include "hurricane/Segment.h"
#include "Configuration.h"
#include "Tree.h" #include "Tree.h"
namespace Hurricane { namespace Hurricane {
@ -23,6 +24,7 @@ namespace Seabreeze {
using Hurricane::RoutingPad; using Hurricane::RoutingPad;
using Hurricane::Contact; using Hurricane::Contact;
using Hurricane::Instance; using Hurricane::Instance;
using Hurricane::Segment;
using Hurricane::PrivateProperty; using Hurricane::PrivateProperty;
//---------------------------------------------------------- //----------------------------------------------------------
@ -34,17 +36,32 @@ namespace Seabreeze {
~Elmore (); ~Elmore ();
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, Segment* seg );
Contact* build_branch ( double* R, double* C, Contact* contact );
void Set_RC ( double* R, double* C, Contact* ct, Segment* sm );
void clearTree (); void clearTree ();
Tree* getTree (); Tree* getTree ();
inline const set<Contact*>& get_conts () const;
inline Configuration* getConfig ();
int delayElmore ( RoutingPad* rp ); int delayElmore ( RoutingPad* rp );
void toTREE ( ostream& ) const; void toTREE ( ostream& ) const;
private: private:
Configuration* _config;
set<Contact*> _conts; set<Contact*> _conts;
set<Contact*> checker; set<Contact*> checker;
Tree* _tree; Tree* _tree;
}; };
inline const set<Contact*>& Elmore::get_conts () const
{
return _conts;
}
inline Configuration* Elmore::getConfig ()
{
return _config;
}
//--------------------------------------------------------- //---------------------------------------------------------
// Class : Seabreeze::ElmoreProperty // Class : Seabreeze::ElmoreProperty

View File

@ -8,11 +8,14 @@
#include "hurricane/Contact.h" #include "hurricane/Contact.h"
#include "hurricane/RoutingPad.h" #include "hurricane/RoutingPad.h"
#include "hurricane/Component.h"
using namespace std; using namespace std;
using Hurricane::Contact;
using Hurricane::RoutingPad; using Hurricane::RoutingPad;
using Hurricane::Component;
class Tree{ class Tree {
public: public:
Tree (); Tree ();
~Tree (); ~Tree ();

View File

@ -95,6 +95,9 @@ namespace Seabreeze {
{ {
cerr << "SeabreezeEngine::runTool() has been called." << endl; cerr << "SeabreezeEngine::runTool() has been called." << endl;
DebugSession::addToTrace(net);
DebugSession::open(net, 190, 200);
RoutingPad* driver= nullptr; RoutingPad* driver= nullptr;
for ( RoutingPad* rp : net->getRoutingPads() ) { for ( RoutingPad* rp : net->getRoutingPads() ) {
@ -106,7 +109,17 @@ namespace Seabreeze {
} }
Elmore* elm = ElmoreProperty::create(net)->getElmore(); Elmore* elm = ElmoreProperty::create(net)->getElmore();
elm->contFromNet(net);
cdebug_log(199, 0) << endl << "There are : " << (elm->get_conts()).size() << " routing pads presented by :" << endl;
for ( Contact* ct : elm->get_conts() ) {
cdebug_log(199, 1) << ct << endl;
cdebug_tabw(199, -1);
}
cdebug_log(199,0) << endl;
elm->buildTree(driver); elm->buildTree(driver);
DebugSession::close();
} }
SeabreezeEngine::SeabreezeEngine ( Cell* cell ) SeabreezeEngine::SeabreezeEngine ( Cell* cell )

View File

@ -46,6 +46,7 @@ void Tree::new_node ()
void Tree::add_node ( Node* node ) void Tree::add_node ( Node* node )
{ {
node->label = nodes.size(); node->label = nodes.size();
if ( find(nodes.begin(), nodes.end(), node) == nodes.end() )
nodes.push_back(node); nodes.push_back(node);
} }
@ -55,9 +56,8 @@ void Tree::After_i ( Node *ni )
return; return;
ni->ap = 1; ni->ap = 1;
int size = ni->Ne.size(); for ( Node* ne : ni->Ne ) {
for(int i = 0; i < size; i++){ After_i(ne);
After_i(ni->Ne[i]);
} }
} }
@ -65,7 +65,7 @@ set<Node*> Tree::Branch_i ( Contact* ct )
{ {
set<Node*> ln; set<Node*> ln;
Node *ni = get_node(ct); Node *ni = get_node(ct);
while(ni != nullptr){ while ( ni != nullptr ) {
ln.insert(ni->Np); ln.insert(ni->Np);
ni = ni->Np; ni = ni->Np;
} }
@ -79,8 +79,18 @@ int Tree::Delay_Elmore ( RoutingPad* rp )
cerr << "Input RoutingPad is NULL. Please select a RoutingPad !" << endl; cerr << "Input RoutingPad is NULL. Please select a RoutingPad !" << endl;
return -1; return -1;
} }
Contact* ct = dynamic_cast<Contact*>(rp);
if ( not ct ) { Contact* ct = nullptr;
for ( Component* c : rp->getSlaveComponents() ) {
Contact* cont = dynamic_cast<Contact*>(c);
if ( ct ) {
ct = cont;
break;
}
}
if ( ct == nullptr ) {
cerr << "No contact found" << endl; cerr << "No contact found" << endl;
return -1; return -1;
} }
@ -121,23 +131,26 @@ int Tree::Delay_Elmore ( RoutingPad* rp )
void Tree::print ( ostream& out ) void Tree::print ( ostream& out )
{ {
out << "Start printing tree..." << endl;
out << "Tree has " << nodes.size() << " nodes :" << endl; out << "Tree has " << nodes.size() << " nodes :" << endl;
out << nodes[0]->_contact->getId()
out << nodes[0]->label << " -> "; << " : R = " << nodes[0]->R
<< ", C = " << nodes[0]->C
<< " -> ";
for(Node* n : nodes[0]->Ne){ for(Node* n : nodes[0]->Ne){
out << n->label << ", "; out << n->_contact->getId() << ", ";
} }
out << std::endl; out << std::endl;
for ( int i = 1; i < nodes.size(); i++ ) { for ( size_t i = 1; i < nodes.size(); i++ ) {
out << nodes[i]->Np->label out << nodes[i]->Np->_contact->getId()
<< " -> " << nodes[i]->label << " -> " << nodes[i]->_contact->getId()
<< " : R = " << nodes[i]->R << " : R = " << nodes[i]->R
<< ", C = " << nodes[i]->C; << ", C = " << nodes[i]->C;
if ( !(nodes[i]->Ne).empty() ) { if ( !(nodes[i]->Ne).empty() ) {
out << " -> "; out << " -> ";
for ( Node* n : nodes[i]->Ne ) { for ( Node* n : nodes[i]->Ne ) {
out << n->label << ", "; out << n->_contact->getId() << ", ";
} }
} }
else else