coriolis/katana/src/TrackSegmentCost.cpp

204 lines
6.8 KiB
C++
Raw Normal View History

Anabatic transient commit 18. Port of Kite (Katana), Yeah, Baby! Yeah! * Bug: In Hurricane, in StaticObservable::getObserver(), if the slot pointer is NULL, do not try to access the owner. Returns NULL, so the caller can be aware of the situation... * Change: In Hurricane, in BreakpointWidget & ExceptionWidget some cosmetic changes (fonts and window sizes). * Bug: In Anabatic, In AutoHorizontal::getConstraints(), take into account the constraints from the source AutoContact, as it holds the constraints transmitted by the RoutingPads and sets up by propageConstraintsFromRp(). It is likely to be a bug affecting the original Katabatic as well. * Change: In Anabatic, in RawGCellsUnder(), check that the segment is not completly oustside the cell abutment box and truncate the coordinates to the part that is inside. Use the "shrink" if we reach the east/north border. * Change: In Anabatic, in Configuration, no more decorator because we will use a true derived relationship. Katana *derives* from *Anabatic* and do not *decorate* it, so the Configuration can do the same. It also implies that we directly create a Katana engine, not an Anabatic one. * Change: In Anabatic, in Session, do not allow the opening of the Session in a standalone fashion (with a static method). Instead it must be opened using the relevant method of the Anabatic/Katana engine. This ensure we are opening the right Session type. * Change: In Anabatic, in AutoSegment_Aligneds() collection the seed segment is not part of the collection by default, but will be included if the Flags::WithSelf is set. * Change: In Configuration, all the flags value are now defined in two steps. Declared in the header and initialized in the module. This is to prevent the fact that on some cases, in relation with the Python "extern C" part modules, we need a true allocated variable. It was causing weird linking problems. A side effect is that they can no longer be used as entry is switches, have to replace them by if/else. * New: In Anabatic, new GCell::getNeighborAt() utility function. * Bug: In Anabatic, in GCell::doGrid(), tag all the GCells of the grid with the grid type... Back annote all the edges capacity (north & east) with the reserved local capacity. * New: Complete portage of Kite over Anabatic. The new engine is christened "Katana" for Kite-Analogic. When it's capabilities and performances will be on a part with Kite, it is to completly replace it (and take back the "Kite" name). Preliminary tests seems to show that, contrary to intuition (because built on a more complex/slower grid), it is even slightly faster than Kite 8-).
2016-08-15 09:30:13 -05:00
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2016, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | K i t e - D e t a i l e d R o u t e r |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./TrackSegmentCost.cpp" |
// +-----------------------------------------------------------------+
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <map>
#include "hurricane/Bug.h"
#include "hurricane/DebugSession.h"
#include "anabatic/AutoSegment.h"
#include "katana/TrackElement.h"
#include "katana/TrackSegmentCost.h"
namespace Katana {
using std::cerr;
using std::endl;
using std::map;
using std::multimap;
using std::make_pair;
using std::ostringstream;
using Hurricane::Bug;
using Hurricane::DebugSession;
using Hurricane::tab;
// -------------------------------------------------------------------
// Class : "TrackSegmentCost".
TrackSegmentCost::TrackSegmentCost ( TrackElement* trackSegment )
: _terminals (0)
, _ripupCount (0)
, _leftMinExtend (DbU::Max)
, _rightMinExtend(DbU::Min)
, _net (trackSegment->getNet())
, _attractors ()
{
//update ( trackSegment );
}
TrackSegmentCost::~TrackSegmentCost ()
{ }
DbU::Unit TrackSegmentCost::getWiringDelta ( DbU::Unit axis ) const
{
DbU::Unit attraction = 0;
for ( size_t i=0 ; i < _attractors.size() ; i++ ) {
if ( _attractors[i] > axis ) attraction += _attractors[i] - axis;
else attraction += axis - _attractors[i];
}
return attraction;
}
void TrackSegmentCost::update ( TrackElement* trackSegment )
{
Support for symmetric routing in Anabatic/Katabatic. * New: In Katana::SegmentFsm, the object is now able to handle two events at the same time. The master and it's symmetric. When there is no symmetric, the corresponing data is just left blank. This makes a bigger object, but as there is only one when running, it is not an issue. Candidates tracks are now an vector of array<2> (pairs), the TrackCost::Compare() functor has to be wrapped through CompareCostArray. The compined TrackCost of the two tracks is accumulated into the first element. Everything related to events gets duplicated: _event is now _event1 and _event2, and so on. As there can be now two Manipulator actions done with SegmentFsm, this class now completly hide the Manipulator level from the RoutingEvent processing. New function ::bindToTrack() to perform the track insertion. * New: In Katana::TrackCost, add a new ::merge() function. * New: In Katana::TrackElement and Katana::TrackSegment, add symmetric management. Allows to know if a TrackElement has a symmetric and to access it. * New: In Katana::DataSymmetric, add new overload for ::getSymmetrical() to handle DbU::Unit and intervals. * Change: In Katana::RoutingEvent, remove all direct uses of Manipulator objects. Now any change to the event associated segment must go through call to Segment Fsm. * Change: In Katana, adjust the debug level so internal informations are put below level 156. * New: In Hurricane::DbU, in ::getValueString(), special display when the value is Min or Max (more helpful than a gigantic number).
2017-04-30 16:46:33 -05:00
DebugSession::open ( trackSegment->getNet(), 156, 160 );
Anabatic transient commit 18. Port of Kite (Katana), Yeah, Baby! Yeah! * Bug: In Hurricane, in StaticObservable::getObserver(), if the slot pointer is NULL, do not try to access the owner. Returns NULL, so the caller can be aware of the situation... * Change: In Hurricane, in BreakpointWidget & ExceptionWidget some cosmetic changes (fonts and window sizes). * Bug: In Anabatic, In AutoHorizontal::getConstraints(), take into account the constraints from the source AutoContact, as it holds the constraints transmitted by the RoutingPads and sets up by propageConstraintsFromRp(). It is likely to be a bug affecting the original Katabatic as well. * Change: In Anabatic, in RawGCellsUnder(), check that the segment is not completly oustside the cell abutment box and truncate the coordinates to the part that is inside. Use the "shrink" if we reach the east/north border. * Change: In Anabatic, in Configuration, no more decorator because we will use a true derived relationship. Katana *derives* from *Anabatic* and do not *decorate* it, so the Configuration can do the same. It also implies that we directly create a Katana engine, not an Anabatic one. * Change: In Anabatic, in Session, do not allow the opening of the Session in a standalone fashion (with a static method). Instead it must be opened using the relevant method of the Anabatic/Katana engine. This ensure we are opening the right Session type. * Change: In Anabatic, in AutoSegment_Aligneds() collection the seed segment is not part of the collection by default, but will be included if the Flags::WithSelf is set. * Change: In Configuration, all the flags value are now defined in two steps. Declared in the header and initialized in the module. This is to prevent the fact that on some cases, in relation with the Python "extern C" part modules, we need a true allocated variable. It was causing weird linking problems. A side effect is that they can no longer be used as entry is switches, have to replace them by if/else. * New: In Anabatic, new GCell::getNeighborAt() utility function. * Bug: In Anabatic, in GCell::doGrid(), tag all the GCells of the grid with the grid type... Back annote all the edges capacity (north & east) with the reserved local capacity. * New: Complete portage of Kite over Anabatic. The new engine is christened "Katana" for Kite-Analogic. When it's capabilities and performances will be on a part with Kite, it is to completly replace it (and take back the "Kite" name). Preliminary tests seems to show that, contrary to intuition (because built on a more complex/slower grid), it is even slightly faster than Kite 8-).
2016-08-15 09:30:13 -05:00
cdebug_log(159,1) << "TrackSegmentCost::update() - " << trackSegment << endl;
vector<AutoSegment*> collapseds;
vector<AutoSegment*> perpandiculars;
map<DbU::Unit,int> attractorSpins;
AutoSegment::getTopologicalInfos ( trackSegment->base()
, collapseds
, perpandiculars
, _leftMinExtend
, _rightMinExtend
);
_terminals = AutoSegment::getTerminalCount ( trackSegment->base(), collapseds );
_attractors.clear ();
for ( size_t i=0 ; i < perpandiculars.size() ; i++ ) {
Interval interval;
TrackElement* perpandicular;
if ( perpandiculars[i]->isCanonical() ) {
perpandicular = Session::lookup ( perpandiculars[i]->base() );
if ( perpandicular )
perpandicular->getCanonical ( interval );
} else {
perpandicular = Session::lookup ( perpandiculars[i]->getCanonical(interval)->base() );
}
if ( not perpandicular ) {
cerr << Bug("Not a TrackSegment: %s:%s\n (perpandicular: %s:%s)"
,getString((void*)perpandiculars[i]->getCanonical(interval)->base()).c_str()
,getString(perpandiculars[i]->getCanonical(interval)).c_str()
,getString((void*)perpandiculars[i]->base()).c_str()
,getString(perpandiculars[i]).c_str()
) << endl;
continue;
}
interval.inflate ( DbU::lambda(-1.5) );
cdebug_log(159,0) << "| perpandicular: " << perpandiculars[i] << endl;
cdebug_log(159,1) << "| canonical: " << perpandicular << endl;
cdebug_log(159,0) << "interval: " << interval << endl;
if ( interval.isPonctual() ) {
cdebug_log(159,0) << "Punctual attractor @" << DbU::getValueString(interval.getVMin()) << endl;
_attractors.push_back ( interval.getVMin() );
cdebug_tabw(159,-1);
continue;
}
if ( ( interval.getVMin() != trackSegment->getAxis() )
or AutoSegment::isTopologicalBound(perpandiculars[i]
,false
,perpandicular->isHorizontal()
) ) {
map<DbU::Unit,int>::iterator iattractor = attractorSpins.find ( interval.getVMin() );
if ( iattractor == attractorSpins.end() ) {
attractorSpins.insert ( make_pair(interval.getVMin(),-1) );
} else {
iattractor->second -= 1;
}
cdebug_log(159,0) << "Left attractor @" << DbU::getValueString(interval.getVMin()) << endl;
}
if ( ( interval.getVMax() != trackSegment->getAxis() )
or AutoSegment::isTopologicalBound(perpandiculars[i]
,true
,perpandicular->isHorizontal()
) ) {
map<DbU::Unit,int>::iterator iattractor = attractorSpins.find ( interval.getVMax() );
if ( iattractor == attractorSpins.end() ) {
attractorSpins.insert ( make_pair(interval.getVMax(),1) );
} else {
iattractor->second += 1;
}
cdebug_log(159,0) << "Right attractor @" << DbU::getValueString(interval.getVMax()) << endl;
}
cdebug_tabw(159,-1);
}
map<DbU::Unit,int>::iterator iattractor = attractorSpins.begin();
for ( ; iattractor != attractorSpins.end() ; iattractor++ ) {
if ( iattractor->second != 0 )
_attractors.push_back ( iattractor->first );
}
ostringstream s;
s << "Attractors [";
for ( size_t i=0 ; i<_attractors.size() ; i++ ) {
if ( i ) s << ", ";
s << DbU::getValueString(_attractors[i]);
}
s << "]";
cdebug_log(159,0) << s.str() << endl;
cdebug_tabw(159,-1);
DebugSession::close ();
}
string TrackSegmentCost::_getString () const
{
return "<" + _getTypeName() + " "
+ getString(_terminals)
+ " [" + DbU::getValueString(_leftMinExtend)
+ ":" + DbU::getValueString(_rightMinExtend)
+ "]>";
}
Record* TrackSegmentCost::_getRecord () const
{
Record* record = new Record ( getString(this) );
record->add ( getSlot ( "_terminals" , _terminals ) );
record->add ( getSlot ( "_ripupCount" , _ripupCount ) );
record->add ( getSlot ( "_leftMinExtend" , &_leftMinExtend ) );
record->add ( getSlot ( "_rightMinExtend", &_rightMinExtend ) );
record->add ( getSlot ( "_net" , _net ) );
return record;
}
} // End of Katana namespace.