17 #ifndef KATABATIC_AUTOSEGMENT_H
18 #define KATABATIC_AUTOSEGMENT_H
23 #include "hurricane/Interval.h"
24 #include "hurricane/Segment.h"
25 #include "hurricane/Components.h"
26 #include "hurricane/Contact.h"
33 #include "crlcore/RoutingGauge.h"
34 #include "katabatic/Constants.h"
35 #include "katabatic/Observer.h"
36 #include "katabatic/GCell.h"
37 #include "katabatic/AutoSegments.h"
38 #include "katabatic/Session.h"
47 using std::binary_function;
78 , SegSourceTerminal = (1<<14)
79 , SegTargetTerminal = (1<<15)
85 , SegUnbound = (1<<20)
86 , SegHalfSlackened = (1<<21)
90 , SegInvalidatedSource = (1<<25)
91 , SegInvalidatedTarget = (1<<26)
94 , SegUserDefined = (1<<29)
100 , SegDepthSpin = SegSpinTop |SegSpinBottom
109 enum ObserverFlag { Create = 0x000000001
110 , Destroy = 0x000000002
111 , Invalidate = 0x000000004
112 , Revalidate = 0x000000008
113 , RevalidatePPitch = 0x000000010
116 typedef std::function< void(AutoSegment*) > RevalidateCb_t;
118 static void setDestroyMode (
bool );
126 ,
size_t depth=RoutingGauge::nlayerdepth
160 inline bool isWeakGlobal ()
const;
165 inline bool isWeakTerminal1 ()
const;
166 inline bool isWeakTerminal2 ()
const;
167 inline bool isTerminal ()
const;
168 inline bool isNotSourceAligned ()
const;
169 inline bool isNotTargetAligned ()
const;
170 inline bool isNotAligned ()
const;
172 inline bool isSourceTerminal ()
const;
173 inline bool isTargetTerminal ()
const;
181 inline bool isUnbound ()
const;
188 inline bool isUserDefined ()
const;
189 bool isReduceCandidate ()
const;
190 bool isUTurn ()
const;
195 virtual bool canMoveULeft (
float reserve=0.0 )
const = 0;
197 bool canMoveUp (
float reserve=0.0,
unsigned int flags=0 )
const;
198 bool canPivotUp (
float reserve=0.0,
unsigned int flags=0 )
const;
199 bool canPivotDown (
float reserve=0.0,
unsigned int flags=0 )
const;
200 bool canSlacken (
unsigned int flags=0 )
const;
203 bool checkDepthSpin ()
const;
205 template<
typename T >
206 inline T* getObserver ();
207 inline unsigned long getId ()
const;
208 inline unsigned int getFlags ()
const;
211 virtual size_t getGCells ( vector<GCell*>& )
const = 0;
217 inline unsigned int getDepth ()
const;
241 float getMaxUnderDensity (
unsigned int flags );
246 inline void setFlags (
unsigned int );
247 void setFlagsOnAligneds (
unsigned int );
248 inline void incReduceds ();
249 inline void decReduceds ();
255 void updateSourceSpin ();
256 void updateTargetSpin ();
257 void sourceDetach ();
258 void targetDetach ();
266 bool checkNotInvalidated ()
const;
275 bool slacken (
unsigned int flags );
276 virtual bool _slacken (
unsigned int flags ) = 0;
277 void _changeDepth (
unsigned int depth,
unsigned int flags );
278 void changeDepth (
unsigned int depth,
unsigned int flags );
279 bool moveUp (
unsigned int flags=KbNoFlags );
280 bool moveDown (
unsigned int flags=KbNoFlags );
295 AutoSegments getCachedOnSourceContact (
unsigned int direction );
296 AutoSegments getCachedOnTargetContact (
unsigned int direction );
299 size_t getAlignedContacts ( map<AutoContact*,int>& )
const ;
301 virtual Record* _getRecord ()
const = 0;
302 virtual string _getString ()
const = 0;
303 virtual string _getTypeName ()
const = 0;
305 bool _check ()
const;
308 bool shearUp (
GCell*
311 ,
unsigned int flags );
316 static size_t _allocateds;
317 static size_t _globalsCount;
318 static bool _destroyBase;
319 static bool _destroyTool;
320 static unsigned long _maxId;
323 const unsigned long _id;
325 unsigned int _depth : 8;
326 unsigned int _optimalMin : 8;
327 unsigned int _optimalMax : 8;
328 unsigned int _reduceds : 2;
348 std::string _getStringFlags ()
const;
352 struct CompareId :
public binary_function<AutoSegment*,AutoSegment*,bool> {
356 struct CompareByDepthLength :
public binary_function<AutoSegment*,AutoSegment*,bool> {
360 struct CompareByDepthAxis :
public binary_function<AutoSegment*,AutoSegment*,bool> {
364 typedef std::set<AutoSegment*,CompareByDepthLength> DepthLengthSet;
369 static bool isTopologicalBound (
AutoSegment* seed,
unsigned int flags );
371 static inline bool arePerpandiculars (
bool isHorizontalA,
AutoSegment* b );
373 static unsigned int getPerpandicularState ( AutoContact* contact
376 ,
bool isHorizontalMaster
377 ,
const Layer* masterLayer=NULL
379 static inline unsigned int getPerpandicularState ( AutoContact* contact
384 static void getTopologicalInfos (
AutoSegment* seed
385 , vector<AutoSegment*>& collapseds
386 , vector<AutoSegment*>& perpandiculars
391 , vector<AutoSegment*>& collapseds
393 static inline int getTerminalCount (
AutoSegment* seed );
394 static inline size_t getGlobalsCount ();
395 static inline size_t getAllocateds ();
396 static inline unsigned long getMaxId ();
401 inline void AutoSegment::addObserver ( BaseObserver* observer ) { _observers.
addObserver(observer); }
402 inline void AutoSegment::removeObserver ( BaseObserver* observer ) { _observers.
removeObserver(observer); }
428 inline unsigned int AutoSegment::getDepth ()
const {
return _depth; }
441 inline bool AutoSegment::isWeakGlobal ()
const {
return _flags &
SegWeakGlobal; }
445 inline bool AutoSegment::isWeakTerminal1 ()
const {
return _flags &
SegWeakTerminal1; }
446 inline bool AutoSegment::isWeakTerminal2 ()
const {
return _flags &
SegWeakTerminal2; }
447 inline bool AutoSegment::isSourceTerminal ()
const {
return _flags & SegSourceTerminal; }
448 inline bool AutoSegment::isTargetTerminal ()
const {
return _flags & SegTargetTerminal; }
449 inline bool AutoSegment::isTerminal ()
const {
return _flags &
SegStrongTerminal; }
450 inline bool AutoSegment::isNotSourceAligned ()
const {
return _flags &
SegNotSourceAligned; }
451 inline bool AutoSegment::isNotTargetAligned ()
const {
return _flags &
SegNotTargetAligned; }
454 inline bool AutoSegment::isUnbound ()
const {
return _flags & SegUnbound ; }
467 inline bool AutoSegment::isUserDefined ()
const {
return _flags & SegUserDefined; }
471 inline unsigned int AutoSegment::getFlags ()
const {
return _flags; }
473 inline void AutoSegment::incReduceds () {
if (_reduceds<3) ++_reduceds; }
474 inline void AutoSegment::decReduceds () {
if (_reduceds>0) --_reduceds; }
481 inline void AutoSegment::setParent (
AutoSegment* parent )
483 if ( parent ==
this ) {
484 cerr <<
"Parentage Looping: " << parent->_getString() << endl;
489 template<
typename T >
490 inline T* AutoSegment::getObserver () {
return _observers.
getObserver<T>(); }
493 inline bool AutoSegment::CompareId::operator() (
const AutoSegment* lhs,
const AutoSegment* rhs )
const
494 {
return lhs->getId() < rhs->getId(); }
496 inline unsigned long AutoSegment::getMaxId ()
499 inline bool AutoSegment::areAlignedsAndDiffLayer ( AutoSegment* s1, AutoSegment* s2 )
501 and (s1->isHorizontal() == s2->isHorizontal())
502 and (s1->getLayer() != s2->getLayer()); }
504 inline bool AutoSegment::arePerpandiculars ( AutoSegment* a, AutoSegment* b )
505 {
return a and b and (a->isHorizontal() != b->isHorizontal()); }
507 inline bool AutoSegment::arePerpandiculars (
bool isHorizontalA, AutoSegment* b )
508 {
return b and (isHorizontalA != b->isHorizontal()); }
510 inline bool AutoSegment::areAligneds ( AutoSegment* a, AutoSegment* b )
511 {
return a and b and (a->isHorizontal() == b->isHorizontal()); }
513 inline unsigned int AutoSegment::getPerpandicularState ( AutoContact* contact
514 , AutoSegment* source
515 , AutoSegment* current
516 , AutoSegment* master )
518 return getPerpandicularState ( contact, source, current, master->isHorizontal(), master->getLayer() );
522 inline int AutoSegment::getTerminalCount ( AutoSegment* seed )
524 cdebug_log(145,0) <<
"getTerminalCount() - " << seed << endl;
526 vector<AutoSegment*> collapseds;
527 vector<AutoSegment*> perpandiculars;
531 getTopologicalInfos ( seed
538 return getTerminalCount ( seed, collapseds );
542 inline size_t AutoSegment::getGlobalsCount () {
return _globalsCount; }
543 inline size_t AutoSegment::getAllocateds () {
return _allocateds; }
552 # endif // KATABATIC_AUTOSEGMENT_H
void removeObserver(BaseObserver *)
Definition: Observer.h:103
bool slacken(unsigned int flags)
Definition: AutoSegment.cpp:1346
const DbU::Unit & getVMin() const
bool mustRaise() const
Definition: AutoSegment.cpp:1233
Definition: AutoSegment.h:66
virtual DbU::Unit getCost(DbU::Unit axis) const
Definition: AutoSegment.cpp:547
bool isSpinBottom() const
Definition: AutoSegment.h:458
virtual Vertical * getVertical()
Definition: AutoSegment.h:133
bool isReduced() const
Definition: AutoSegment.h:460
Definition: Constants.h:24
bool reduceDoglegLayer()
Definition: AutoSegment.cpp:1596
virtual Segment * base() const =0
Definition: AutoSegment.h:75
virtual DbU::Unit getSourceX() const =0
static Unit lambda(double value)
virtual DbU::Unit getTargetY() const =0
Hook * getSourceHook()
Definition: AutoSegment.h:408
virtual bool moveULeft()=0
virtual bool moveURight()=0
Component * getOppositeAnchor(Component *) const
Definition: AutoSegment.h:412
void setLayer(const Layer *)
Definition: AutoSegment.h:475
Box getBoundingBox() const
Definition: AutoSegment.h:407
virtual unsigned int _makeDogleg(GCell *, unsigned int flags)=0
virtual DbU::Unit getX() const =0
Definition: AutoSegment.h:87
void setLayer(const Layer *layer)
Concrete Horizontal AutoSegment.
Definition: AutoHorizontal.h:31
bool isSpinTop() const
Definition: AutoSegment.h:457
bool toOptimalAxis(unsigned int flags=KbRealignate)
Definition: AutoSegment.cpp:804
virtual DbU::Unit getX() const
Definition: AutoSegment.cpp:387
bool isSlackened() const
Definition: AutoSegment.h:461
Cell * getCell() const
Definition: AutoSegment.h:404
virtual const Layer * getLayer() const =0
void resetUserConstraints()
Definition: AutoSegment.h:479
const DbU::Unit & getWidth() const
static AutoSegment * create(AutoContact *source, AutoContact *target, Segment *hurricaneSegment)
Definition: AutoSegment.cpp:1988
virtual Interval getSpanU() const =0
Definition: AutoSegment.h:84
AutoSegmentFlag
Definition: AutoSegment.h:63
unsigned int _getFlags() const
Definition: AutoSegment.h:472
Definition: AutoSegment.h:76
GCell * getGCell() const
Definition: AutoSegment.h:423
void revalidate()
Definition: AutoSegment.cpp:457
const Layer * getLayer() const
Definition: AutoSegment.h:406
Net * getNet() const
Definition: AutoSegment.h:405
DbU::Unit getSourceY() const
Definition: AutoSegment.h:417
virtual void invalidate(unsigned int flags=KbPropagate)
Definition: AutoSegment.cpp:416
virtual bool canMoveULeft(float reserve=0.0) const =0
const DbU::Unit & getVMax() const
virtual Interval getTargetConstraints(unsigned int flags=0) const =0
Observer Design Pattern, Subject part.
Definition: Observer.h:69
AutoSegment(Segment *segment)
Definition: AutoSegment.cpp:311
Contact * getSource() const
Definition: AutoSegment.h:410
Interval getMinSpanU() const
Definition: AutoSegment.cpp:1104
Definition: AutoSegment.h:83
virtual bool checkPositions() const =0
Definition: AutoSegment.h:89
bool isDogleg() const
Definition: AutoSegment.h:453
bool canReduce() const
Definition: AutoSegment.cpp:1193
AutoSegments getOnSourceContact(unsigned int direction)
Definition: AutoSegment.cpp:610
DbU::Unit getOrigin() const
Definition: AutoSegment.h:431
virtual ~AutoSegment()
Definition: AutoSegment.cpp:380
DbU::Unit getSourceX() const
Definition: AutoSegment.h:416
Definition: AutoSegment.h:97
AutoContact * getAutoTarget() const
Definition: AutoSegment.h:425
virtual Interval getSourceConstraints(unsigned int flags=0) const =0
virtual size_t getGCells(vector< GCell * > &) const =0
Definition: AutoSegment.h:67
static AutoContact * lookup(Contact *)
Definition: Session.cpp:384
Definition: AutoSegment.h:68
Routing Global Cell.
Definition: GCell.h:74
DbU::Unit getY() const
Definition: GCell.h:245
Abstract base class for AutoSegment.
Definition: AutoSegment.h:104
Definition: AutoSegment.h:92
virtual void setDuSource(DbU::Unit du)=0
bool canPivotDown(float reserve=0.0, unsigned int flags=0) const
Definition: AutoSegment.cpp:1446
static void _preCreate(AutoContact *source, AutoContact *target)
Definition: AutoSegment.cpp:343
bool isVertical() const
Definition: AutoSegment.h:438
void setFlags(unsigned int)
Definition: AutoSegment.h:468
Definition: LoadGrByNet.cpp:405
virtual DbU::Unit getSourceY() const =0
bool isCanonical() const
Definition: AutoSegment.h:462
bool isWeakTerminal() const
Definition: AutoSegment.h:444
Definition: AutoSegment.h:73
bool canPivotUp(float reserve=0.0, unsigned int flags=0) const
Definition: AutoSegment.cpp:1398
Definition: Constants.h:38
unsigned long getId() const
Definition: AutoSegment.h:403
Definition: AutoSegment.h:70
virtual DbU::Unit getY() const =0
virtual void _preDestroy()
Definition: AutoSegment.cpp:368
bool isHorizontal() const
Definition: AutoSegment.h:437
bool canSlacken(unsigned int flags=0) const
Definition: AutoSegment.cpp:1329
DbU::Unit getTargetY() const
Definition: AutoSegment.h:419
AutoContact * getAutoSource() const
Definition: AutoSegment.h:424
bool toConstraintAxis(unsigned int flags=KbRealignate)
Definition: AutoSegment.cpp:766
Hook * getTargetHook()
Definition: AutoSegment.h:409
bool isCreated() const
Definition: AutoSegment.h:466
AutoSegment * getParent() const
Definition: AutoSegment.h:413
virtual DbU::Unit getDuTarget() const =0
bool reduce()
Definition: AutoSegment.cpp:1218
void mergeUserConstraints(const Interval &)
Definition: AutoSegment.cpp:758
virtual AutoSegment * getCanonical(DbU::Unit &min, DbU::Unit &max)
Definition: AutoSegment.cpp:559
const Interval & getUserConstraints() const
Definition: AutoSegment.h:435
DbU::Unit getTargetPosition() const
Definition: AutoSegment.h:415
Definition: AutoSegment.h:96
bool canMoveUp(float reserve=0.0, unsigned int flags=0) const
Definition: AutoSegment.cpp:1493
DbU::Unit getXMax() const
Definition: GCell.h:246
bool isLocal() const
Definition: AutoSegment.h:442
bool isBipoint() const
Definition: AutoSegment.h:443
DbU::Unit getYMax() const
Definition: GCell.h:247
Definition: AutoSegment.h:74
bool isUnsetAxis() const
Definition: AutoSegment.h:463
Component * getTarget() const
bool isGlobal() const
Definition: AutoSegment.h:440
DbU::Unit getWidth() const
Definition: AutoSegment.h:420
void computeTerminal()
Definition: AutoSegment.cpp:862
virtual Horizontal * getHorizontal()
Definition: AutoSegment.h:132
bool isInvalidatedLayer() const
Definition: AutoSegment.h:465
void invert()
Definition: AutoSegment.h:422
AutoSegment * canonize(unsigned int flags=KbNoFlags)
Definition: AutoSegment.cpp:1018
Interval & getOptimal(Interval &i) const
Definition: AutoSegment.cpp:399
size_t getPerpandicularsBound(set< AutoSegment * > &)
Definition: AutoSegment.cpp:1130
Definition: AutoSegment.h:88
DbU::Unit getTargetX() const
Definition: AutoSegment.h:418
Components getAnchors() const
Component * getSource() const
Contact * getTarget() const
Definition: AutoSegment.h:411
virtual Box getBoundingBox(const BasicLayer *) const =0
Definition: AutoSegment.h:71
virtual bool getConstraints(DbU::Unit &min, DbU::Unit &max) const =0
DbU::Unit getOptimalMin() const
Definition: AutoSegment.h:433
virtual DbU::Unit getSourceU() const =0
virtual bool _canSlacken() const =0
DbU::Unit getSourcePosition() const
Definition: AutoSegment.h:414
bool isInvalidated() const
Definition: AutoSegment.h:464
Definition: AutoSegment.h:82
void setOptimalMin(DbU::Unit min)
Definition: AutoSegment.h:476
bool isSpinTopOrBottom() const
Definition: AutoSegment.h:459
DbU::Unit getLength() const
Definition: AutoSegment.h:421
bool isLayerChange() const
Definition: AutoSegment.h:456
Definition: AutoSegment.h:72
DbU::Unit getExtremity() const
Definition: AutoSegment.h:432
Definition: AutoSegment.h:65
bool isStrongTerminal(unsigned int flags=0) const
Definition: AutoSegment.cpp:513
AutoSegments getOnTargetContact(unsigned int direction)
Definition: AutoSegment.cpp:617
Definition: AutoSegment.h:77
virtual bool checkConstraints() const =0
Definition: AutoSegment.h:69
virtual void updatePositions()=0
void addObserver(BaseObserver *)
Definition: Observer.h:96
Observer Design Pattern, Observer part.
Definition: Observer.h:29
void setOptimalMax(DbU::Unit max)
Definition: AutoSegment.h:477
virtual DbU::Unit getY() const
Definition: AutoSegment.cpp:391
Concrete Vertical AutoSegment.
Definition: AutoVertical.h:32
Definition: AutoSegment.h:80
virtual void setDuTarget(DbU::Unit du)=0
virtual Cell * getCell() const =0
bool isStrap() const
Definition: AutoSegment.h:455
AutoSegments getPerpandiculars()
Definition: AutoSegment.cpp:639
virtual void updateOrient()=0
Definition: AutoSegment.h:64
Definition: AutoSegment.h:81
Definition: AutoSegment.h:93
virtual DbU::Unit getTargetU() const =0
AutoSegments getAligneds(unsigned int flags=KbNoFlags)
Definition: AutoSegment.cpp:632
void _invalidate()
Definition: AutoSegment.cpp:437
virtual DbU::Unit getSlack() const
Definition: AutoSegment.cpp:536
DbU::Unit getX() const
Definition: GCell.h:244
DbU::Unit getAxis() const
Definition: AutoSegment.h:430
static double getLambda(Unit u)
Component * getOppositeAnchor(Component *anchor) const
void computeOptimal(set< AutoSegment * > &processeds)
Definition: AutoSegment.cpp:903
GenericCollection< Component * > Components
T * getObserver()
Definition: Observer.h:90
virtual bool canMoveURight(float reserve=0.0) const =0
void unsetFlags(unsigned int)
Definition: AutoSegment.h:469
virtual unsigned int getDirection() const =0
bool isFixed() const
Definition: AutoSegment.h:439
void setAxis(DbU::Unit, unsigned int flags=KbNoFlags)
Definition: AutoSegment.cpp:837
virtual DbU::Unit getLength() const =0
AutoSegment * makeDogleg(AutoContact *)
Definition: AutoSegment.cpp:1727
virtual DbU::Unit getTargetX() const =0
virtual DbU::Unit getDuSource() const =0
DbU::Unit getOptimalMax() const
Definition: AutoSegment.h:434
virtual void _postCreate()
Definition: AutoSegment.cpp:356
unsigned int canDogleg(Interval)
Definition: AutoSegment.cpp:1696