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
Node.cpp
Tree.cpp
Configuration.cpp
#GraphicSeabreezeEngine.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)
, label(-1)
, ap(0)
{ (p->Ne).push_back(this); }
{
if( p != nullptr)
(p->Ne).push_back(this);
}
Node::~Node ()
{}

View File

@ -1,23 +1,29 @@
#include "Seabreeze/Seabreeze.h"
#include "hurricane/Net.h"
#include "hurricane/Segment.h"
#include "hurricane/DebugSession.h"
namespace Seabreeze {
using namespace std;
using Hurricane::DBo;
using Hurricane::DbU;
using Hurricane::Net;
using Hurricane::Cell;
using Hurricane::Instance;
using Hurricane::PrivateProperty;
using Hurricane::Component;
using Hurricane::Segment;
using Hurricane::DebugSession;
//---------------------------------------------------------
// Class : "Elmore"
Elmore::Elmore ( Net* net )
: _conts()
, checker()
, _tree()
: _config (new Configuration())
, _conts ()
, checker ()
, _tree (new Tree())
{}
Elmore::~Elmore ()
@ -27,12 +33,9 @@ namespace Seabreeze {
void Elmore::contFromNet ( Net* net ) {
for ( RoutingPad* rp : net->getRoutingPads() ) {
for ( Component* c : rp->getSlaveComponents() ) {
Contact* ct = dynamic_cast<Contact*>(c);
for ( Component* comp : rp->getSlaveComponents() ) {
Contact* ct = dynamic_cast<Contact*>(comp);
if ( not ct ) continue;
_conts.insert(ct);
}
}
@ -42,53 +45,230 @@ namespace Seabreeze {
{
if ( rp == nullptr ) {
cerr << "Input RoutingPad is NULL. Please select a RoutingPad !" << endl;
cerr << "Cannot build tree" << endl;
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 << "Cannot build tree" << endl;
return;
}
cerr << "Root contact : " << ct->getId() << endl;
cerr << "Start building tree..." << endl;
checker.insert(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 ) {
cerr << "Not begin with a RoutingPad ? Something doesn't seem right : " << c << " linked segments" << endl;
cerr << "Tree build failed" << endl;
return;
}
build_from_Node(s, seg);
cerr << endl << "Finished building tree !" << endl << endl;
_tree->print(cerr);
}
void Elmore::build_from_node ( Node* s )
void Elmore::build_from_Node ( Node* s, Segment* seg )
{
if ( s->_contact == nullptr || find(_conts.begin(), _conts.end(), s->_contact) == _conts.end() ) {
if ( s->_contact == nullptr ) {
cerr << "No contact found" << s->_contact << endl;
return;
}
_tree->add_node(s);
cdebug_log(199,0) << endl
<< endl
<< "Build from contact : " << s->_contact->getId() << endl
<< "With segment : " << seg->getId() << endl;
Contact* ccont = dynamic_cast<Contact*>(seg->getOppositeAnchor(s->_contact));
if ( not ccont || (s->Np && ccont == (s->Np)->_contact) )
return;
cdebug_log(199,0) << "Target contact : " << ccont->getId() << endl;
//-----------------------------------------------------------------------
double Rb = 0;
double Cb = 0;
//-----------------------------------------------------------------------
ccont = build_branch(&Rb, &Cb, ccont);
cdebug_log(199, 0) << "Found a node : " << ccont->getId() << endl;
if ( not ccont ) {
cerr << "This branch leads to a NULL contact ?" << endl;
return;
}
_tree->add_node(s);
// To check for circle
checker.insert(s->_contact);
Node* node = new Node(s, ccont);
//-----------------------------------------------------------------------
node->R = Rb;
if ( Cb == 0 )
node->C = 0;
else
node->C = 1/Cb;
for ( Component* c : (s->_contact)->getSlaveComponents() ) {
cdebug_log(199,0) << "R = " << Rb << "; C = " << Cb << endl;
//-----------------------------------------------------------------------
int count = 0;
for ( Component* comp : ccont->getSlaveComponents() ) {
count += (dynamic_cast<Segment*>(comp)) ? 1 : 0;
}
Contact* ccont = dynamic_cast<Contact*>(c);
cdebug_log(199,0) << "This node's contact has : " << count << " segments" << endl;
if ( not ccont )
continue;
else{
if ( find( _conts.begin(), _conts.end(), ccont) != _conts.end() ) {
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;
if ( find( checker.begin(), checker.end(), ccont) != checker.end() ) {
cerr << "Net contains a circle. Cannot apply Elmore's delay here !" << endl;
return;
}
else {
if ( ccont != (s->Np)->_contact ) {
Node* node = new Node( s, ccont );
build_from_node(node);
}
}
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 {
Contact* cct = nullptr;
for ( Component* cp : tmp->getSlaveComponents() ) {
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);
}
}
void Elmore::clearTree ()
{
_tree->clear();
@ -144,7 +324,7 @@ namespace Seabreeze {
void ElmoreExtension::destroyAll ()
{
}
void ElmoreExtension::destroy ( Net* net )

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 {
public :
int R;
int Rt;
int C;
double R;
double Rt;
double C;
Node* Np;
std::vector<Node*> Ne;
Contact* _contact;

View File

@ -5,7 +5,8 @@
#include "hurricane/Property.h"
#include "hurricane/RoutingPad.h"
#include "hurricane/Contact.h"
#include "hurricane/Segment.h"
#include "Configuration.h"
#include "Tree.h"
namespace Hurricane {
@ -23,6 +24,7 @@ namespace Seabreeze {
using Hurricane::RoutingPad;
using Hurricane::Contact;
using Hurricane::Instance;
using Hurricane::Segment;
using Hurricane::PrivateProperty;
//----------------------------------------------------------
@ -30,20 +32,35 @@ namespace Seabreeze {
class Elmore {
public:
Elmore ( Net* net = NULL );
~Elmore ();
void contFromNet ( Net* net );
void buildTree ( RoutingPad* rp );
void build_from_node ( Node* source );
void clearTree ();
Tree* getTree ();
int delayElmore ( RoutingPad* rp );
void toTREE ( ostream& ) const;
Elmore ( Net* net = NULL );
~Elmore ();
void contFromNet ( Net* net );
void buildTree ( RoutingPad* rp );
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 ();
Tree* getTree ();
inline const set<Contact*>& get_conts () const;
inline Configuration* getConfig ();
int delayElmore ( RoutingPad* rp );
void toTREE ( ostream& ) const;
private:
set<Contact*> _conts;
set<Contact*> checker;
Configuration* _config;
set<Contact*> _conts;
set<Contact*> checker;
Tree* _tree;
};
inline const set<Contact*>& Elmore::get_conts () const
{
return _conts;
}
inline Configuration* Elmore::getConfig ()
{
return _config;
}
//---------------------------------------------------------
// Class : Seabreeze::ElmoreProperty

View File

@ -55,15 +55,15 @@ namespace Seabreeze {
SeabreezeEngine& operator= ( const SeabreezeEngine& );
private :
// Attributes.
static Name _toolName;
static Name _toolName;
protected :
CellViewer* _viewer;
};
// Inline Functions.
inline CellViewer* SeabreezeEngine::getViewer () const { return _viewer; }
inline ToolEngine* SeabreezeEngine::base () { return static_cast<ToolEngine*>(this); }
inline void SeabreezeEngine::setViewer ( CellViewer* viewer ) { _viewer = viewer; }
inline CellViewer* SeabreezeEngine::getViewer () const { return _viewer; }
inline ToolEngine* SeabreezeEngine::base () { return static_cast<ToolEngine*>(this); }
inline void SeabreezeEngine::setViewer ( CellViewer* viewer ) { _viewer = viewer; }
} // Seabreeze namespace.
INSPECTOR_P_SUPPORT(Seabreeze::SeabreezeEngine);

View File

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

View File

@ -94,7 +94,10 @@ namespace Seabreeze {
void SeabreezeEngine::runTool ( Net* net )
{
cerr << "SeabreezeEngine::runTool() has been called." << endl;
DebugSession::addToTrace(net);
DebugSession::open(net, 190, 200);
RoutingPad* driver= nullptr;
for ( RoutingPad* rp : net->getRoutingPads() ) {
@ -106,7 +109,17 @@ namespace Seabreeze {
}
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);
DebugSession::close();
}
SeabreezeEngine::SeabreezeEngine ( Cell* cell )

View File

@ -6,7 +6,7 @@
using namespace std;
Tree::Tree ()
:nodes()
:nodes()
{}
Tree::~Tree ()
@ -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 )
@ -55,9 +56,8 @@ void Tree::After_i ( Node *ni )
return;
ni->ap = 1;
int size = ni->Ne.size();
for(int i = 0; i < size; i++){
After_i(ni->Ne[i]);
for ( Node* ne : ni->Ne ) {
After_i(ne);
}
}
@ -65,7 +65,7 @@ set<Node*> Tree::Branch_i ( Contact* ct )
{
set<Node*> ln;
Node *ni = get_node(ct);
while(ni != nullptr){
while ( ni != nullptr ) {
ln.insert(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;
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;
return -1;
}
@ -121,23 +131,26 @@ int Tree::Delay_Elmore ( RoutingPad* rp )
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->getId()
<< " : R = " << nodes[0]->R
<< ", C = " << nodes[0]->C
<< " -> ";
for(Node* n : nodes[0]->Ne){
out << n->label << ", ";
out << n->_contact->getId() << ", ";
}
out << std::endl;
for ( int i = 1; i < nodes.size(); i++ ) {
out << nodes[i]->Np->label
<< " -> " << nodes[i]->label
for ( size_t i = 1; i < nodes.size(); i++ ) {
out << nodes[i]->Np->_contact->getId()
<< " -> " << nodes[i]->_contact->getId()
<< " : 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->getId() << ", ";
}
}
else