2016-05-23 09:15:25 -05:00
|
|
|
// -*- C++ -*-
|
|
|
|
//
|
|
|
|
// This file is part of the Coriolis Software.
|
|
|
|
// Copyright (c) UPMC 2016-2016, All Rights Reserved
|
|
|
|
//
|
|
|
|
// +-----------------------------------------------------------------+
|
|
|
|
// | C O R I O L I S |
|
|
|
|
// | A n a b a t i c - Global Routing Toolbox |
|
|
|
|
// | |
|
|
|
|
// | Author : Jean-Paul CHAPUT |
|
|
|
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
|
|
|
// | =============================================================== |
|
|
|
|
// | C++ Module : "./AnabaticEngine.cpp" |
|
|
|
|
// +-----------------------------------------------------------------+
|
|
|
|
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include "hurricane/Error.h"
|
2016-05-26 06:56:16 -05:00
|
|
|
#include "hurricane/RegularLayer.h"
|
2016-05-23 09:15:25 -05:00
|
|
|
#include "hurricane/Cell.h"
|
|
|
|
#include "hurricane/UpdateSession.h"
|
2016-05-26 06:56:16 -05:00
|
|
|
#include "crlcore/RoutingGauge.h"
|
2016-05-23 09:15:25 -05:00
|
|
|
#include "anabatic/GCell.h"
|
|
|
|
#include "anabatic/AnabaticEngine.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Anabatic {
|
|
|
|
|
|
|
|
using std::cerr;
|
|
|
|
using std::cout;
|
|
|
|
using std::endl;
|
|
|
|
using std::ostringstream;
|
|
|
|
using Hurricane::Error;
|
2016-05-26 06:56:16 -05:00
|
|
|
using Hurricane::RegularLayer;
|
2016-05-23 09:15:25 -05:00
|
|
|
using Hurricane::Cell;
|
|
|
|
using Hurricane::UpdateSession;
|
2016-05-26 06:56:16 -05:00
|
|
|
using CRL::RoutingGauge;
|
|
|
|
using CRL::RoutingLayerGauge;
|
2016-05-23 09:15:25 -05:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Class : "Anabatic::AnabaticEngine".
|
|
|
|
|
|
|
|
Name AnabaticEngine::_toolName = "Anabatic";
|
|
|
|
|
|
|
|
|
|
|
|
AnabaticEngine* AnabaticEngine::get ( const Cell* cell )
|
|
|
|
{ return static_cast<AnabaticEngine*>(ToolEngine::get(cell,staticGetName())); }
|
|
|
|
|
|
|
|
|
|
|
|
const Name& AnabaticEngine::staticGetName ()
|
|
|
|
{ return _toolName; }
|
|
|
|
|
|
|
|
|
|
|
|
const Name& AnabaticEngine::getName () const
|
|
|
|
{ return _toolName; }
|
|
|
|
|
|
|
|
|
|
|
|
AnabaticEngine::AnabaticEngine ( Cell* cell )
|
|
|
|
: Super(cell)
|
2016-06-17 06:09:34 -05:00
|
|
|
, _timer ()
|
2016-05-23 09:15:25 -05:00
|
|
|
, _configuration (new ConfigurationConcrete())
|
|
|
|
, _matrix ()
|
2016-05-26 11:30:03 -05:00
|
|
|
, _gcells ()
|
|
|
|
, _viewer (NULL)
|
|
|
|
, _flags (Flags::NoFlags)
|
2016-05-30 04:30:29 -05:00
|
|
|
, _stamp (-1)
|
2016-05-23 09:15:25 -05:00
|
|
|
{
|
2016-05-30 04:30:29 -05:00
|
|
|
_matrix.setCell( cell, _configuration->getSliceHeight() );
|
|
|
|
Edge::unity = _configuration->getSliceHeight();
|
2016-05-23 09:15:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AnabaticEngine::_postCreate ()
|
|
|
|
{
|
|
|
|
Super::_postCreate();
|
|
|
|
|
|
|
|
UpdateSession::open();
|
2016-05-26 06:56:16 -05:00
|
|
|
GCell::create( this );
|
2016-05-23 09:15:25 -05:00
|
|
|
UpdateSession::close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AnabaticEngine* AnabaticEngine::create ( Cell* cell )
|
|
|
|
{
|
|
|
|
if (not cell) throw Error( "AnabaticEngine::create(): NULL cell argument." );
|
|
|
|
if (cell->getAbutmentBox().isEmpty())
|
|
|
|
throw Error( "AnabaticEngine::create(): %s has no abutment box." , getString(cell).c_str() );
|
|
|
|
|
|
|
|
AnabaticEngine* engine = new AnabaticEngine ( cell );
|
|
|
|
engine->_postCreate();
|
|
|
|
return engine;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AnabaticEngine::~AnabaticEngine ()
|
|
|
|
{
|
|
|
|
delete _configuration;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AnabaticEngine::_preDestroy ()
|
|
|
|
{
|
2016-05-26 11:30:03 -05:00
|
|
|
_clear();
|
2016-05-23 09:15:25 -05:00
|
|
|
Super::_preDestroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-26 11:30:03 -05:00
|
|
|
void AnabaticEngine::_clear ()
|
|
|
|
{
|
|
|
|
_flags |= Flags::Destroy;
|
|
|
|
|
|
|
|
for ( GCell* gcell : _gcells ) gcell->_destroyEdges();
|
|
|
|
for ( GCell* gcell : _gcells ) gcell->destroy();
|
|
|
|
_gcells.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-23 09:15:25 -05:00
|
|
|
Configuration* AnabaticEngine::getConfiguration ()
|
|
|
|
{ return _configuration; }
|
|
|
|
|
|
|
|
|
2016-05-26 06:56:16 -05:00
|
|
|
int AnabaticEngine::getCapacity ( Interval span, Flags flags ) const
|
|
|
|
{
|
|
|
|
int capacity = 0;
|
|
|
|
Box ab = getCell()->getAbutmentBox();
|
|
|
|
RoutingGauge* rg = _configuration->getRoutingGauge();
|
|
|
|
|
2016-05-26 11:54:57 -05:00
|
|
|
span.inflate( 0, -1 );
|
|
|
|
if (span.isEmpty()) return 0;
|
|
|
|
|
2016-05-26 06:56:16 -05:00
|
|
|
const vector<RoutingLayerGauge*>& layerGauges = rg->getLayerGauges();
|
|
|
|
for ( size_t depth=0 ; depth <= _configuration->getAllowedDepth() ; ++depth ) {
|
|
|
|
if (layerGauges[depth]->getType() != Constant::Default) continue;
|
|
|
|
|
|
|
|
if (flags & Flags::Horizontal) {
|
|
|
|
if (layerGauges[depth]->getDirection() != Constant::Horizontal) continue;
|
|
|
|
capacity += layerGauges[depth]->getTrackNumber( span.getVMin() - ab.getYMin()
|
|
|
|
, span.getVMax() - ab.getYMin() );
|
2016-06-17 06:09:34 -05:00
|
|
|
//cdebug_log(110,0) << "Horizontal edge capacity:" << capacity << endl;
|
2016-05-26 06:56:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & Flags::Vertical) {
|
|
|
|
if (layerGauges[depth]->getDirection() != Constant::Vertical) continue;
|
|
|
|
capacity += layerGauges[depth]->getTrackNumber( span.getVMin() - ab.getXMin()
|
|
|
|
, span.getVMax() - ab.getXMin() );
|
2016-06-17 06:09:34 -05:00
|
|
|
//cdebug_log(110,0) << "Vertical edge capacity:" << capacity << endl;
|
2016-05-26 06:56:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return capacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-26 11:30:03 -05:00
|
|
|
void AnabaticEngine::reset ()
|
2016-05-23 09:15:25 -05:00
|
|
|
{
|
2016-05-26 11:30:03 -05:00
|
|
|
_clear();
|
|
|
|
_flags.reset( Flags::Destroy );
|
|
|
|
|
|
|
|
UpdateSession::open();
|
|
|
|
GCell::create( this );
|
|
|
|
UpdateSession::close();
|
2016-05-23 09:15:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-17 06:09:34 -05:00
|
|
|
void AnabaticEngine::startMeasures ()
|
|
|
|
{
|
|
|
|
_timer.resetIncrease();
|
|
|
|
_timer.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AnabaticEngine::stopMeasures ()
|
|
|
|
{ _timer.stop(); }
|
|
|
|
|
|
|
|
|
|
|
|
void AnabaticEngine::printMeasures ( const string& tag ) const
|
|
|
|
{
|
|
|
|
ostringstream result;
|
|
|
|
|
|
|
|
result << Timer::getStringTime(_timer.getCombTime())
|
|
|
|
<< ", " << Timer::getStringMemory(_timer.getIncrease());
|
|
|
|
cmess1 << Dots::asString( " - Done in", result.str() ) << endl;
|
|
|
|
|
|
|
|
result.str("");
|
|
|
|
result << _timer.getCombTime()
|
|
|
|
<< "s, +" << (_timer.getIncrease()>>10) << "Kb/"
|
|
|
|
<< (_timer.getMemorySize()>>10) << "Kb";
|
|
|
|
cmess2 << Dots::asString( " - Raw measurements", result.str() ) << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-23 09:15:25 -05:00
|
|
|
string AnabaticEngine::_getTypeName () const
|
|
|
|
{ return getString(_toolName); }
|
|
|
|
|
|
|
|
|
|
|
|
string AnabaticEngine::_getString () const
|
|
|
|
{
|
|
|
|
ostringstream os;
|
|
|
|
os << "<" << _toolName << " " << _cell->getName() << ">";
|
|
|
|
return os.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Record* AnabaticEngine::_getRecord () const
|
|
|
|
{
|
|
|
|
Record* record = Super::_getRecord();
|
2016-05-26 06:56:16 -05:00
|
|
|
record->add( getSlot("_configuration", _configuration) );
|
|
|
|
record->add( getSlot("_gcells" , &_gcells ) );
|
|
|
|
record->add( getSlot("_matrix" , &_matrix ) );
|
2016-05-26 11:30:03 -05:00
|
|
|
record->add( getSlot("_flags" , &_flags ) );
|
2016-05-23 09:15:25 -05:00
|
|
|
return record;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // Anabatic namespace.
|