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;
67 , SegWeakGlobal = (1<< 3)
69 , SegBipoint = (1<< 5)
73 , SegSourceBottom = (1<< 9)
75 , SegTargetBottom = (1<<11)
77 , SegLayerChange = (1<<13)
78 , SegSourceTerminal = (1<<14)
79 , SegTargetTerminal = (1<<15)
82 , SegWeakTerminal2 = (1<<17)
84 , SegNotTargetAligned = (1<<19)
85 , SegUnbound = (1<<20)
86 , SegHalfSlackened = (1<<21)
88 , SegAxisSet = (1<<23)
90 , SegInvalidatedSource = (1<<25)
91 , SegInvalidatedTarget = (1<<26)
92 , SegInvalidatedLayer = (1<<27)
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
130 virtual Segment* base ()
const = 0;
134 inline Cell* getCell ()
const;
135 inline Net* getNet ()
const;
136 inline const Layer* getLayer ()
const;
137 inline Box getBoundingBox ()
const;
138 inline Hook* getSourceHook ();
139 inline Hook* getTargetHook ();
140 inline Contact* getSource ()
const;
141 inline Contact* getTarget ()
const;
148 inline DbU::Unit getSourcePosition ()
const;
149 inline DbU::Unit getTargetPosition ()
const;
154 inline void invert ();
155 inline void setLayer (
const Layer* );
157 inline bool isHorizontal ()
const;
158 inline bool isVertical ()
const;
159 inline bool isGlobal ()
const;
160 inline bool isWeakGlobal ()
const;
161 inline bool isLocal ()
const;
162 inline bool isFixed ()
const;
163 inline bool isBipoint ()
const;
164 inline bool isWeakTerminal ()
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;
171 bool isStrongTerminal (
unsigned int flags=0 )
const;
172 inline bool isSourceTerminal ()
const;
173 inline bool isTargetTerminal ()
const;
174 inline bool isLayerChange ()
const;
175 inline bool isSpinTop ()
const;
176 inline bool isSpinBottom ()
const;
177 inline bool isSpinTopOrBottom ()
const;
178 inline bool isReduced ()
const;
179 inline bool isStrap ()
const;
180 inline bool isDogleg ()
const;
181 inline bool isUnbound ()
const;
182 inline bool isInvalidated ()
const;
183 inline bool isInvalidatedLayer ()
const;
184 inline bool isCreated ()
const;
185 inline bool isCanonical ()
const;
186 inline bool isUnsetAxis ()
const;
187 inline bool isSlackened ()
const;
188 inline bool isUserDefined ()
const;
189 bool isReduceCandidate ()
const;
190 bool isUTurn ()
const;
191 virtual bool _canSlacken ()
const = 0;
192 bool canReduce ()
const;
193 bool mustRaise ()
const;
194 unsigned int canDogleg (
Interval );
195 virtual bool canMoveULeft (
float reserve=0.0 )
const = 0;
196 virtual bool canMoveURight (
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;
201 virtual bool checkPositions ()
const = 0;
202 virtual bool checkConstraints ()
const = 0;
203 bool checkDepthSpin ()
const;
205 template<
typename T >
206 inline T* getObserver ();
207 inline unsigned long getId ()
const;
208 inline unsigned int getFlags ()
const;
209 virtual unsigned int getDirection ()
const = 0;
210 inline GCell* getGCell ()
const;
211 virtual size_t getGCells ( vector<GCell*>& )
const = 0;
215 size_t getPerpandicularsBound ( set<AutoSegment*>& );
217 inline unsigned int getDepth ()
const;
221 virtual DbU::Unit getSourceU ()
const = 0;
222 virtual DbU::Unit getTargetU ()
const = 0;
223 virtual DbU::Unit getDuSource ()
const = 0;
224 virtual DbU::Unit getDuTarget ()
const = 0;
227 virtual Interval getSpanU ()
const = 0;
229 virtual Interval getSourceConstraints (
unsigned int flags=0 )
const = 0;
230 virtual Interval getTargetConstraints (
unsigned int flags=0 )
const = 0;
232 inline bool getConstraints (
Interval& i )
const;
233 inline const Interval& getUserConstraints ()
const;
241 float getMaxUnderDensity (
unsigned int flags );
245 inline void unsetFlags (
unsigned int );
246 inline void setFlags (
unsigned int );
247 void setFlagsOnAligneds (
unsigned int );
248 inline void incReduceds ();
249 inline void decReduceds ();
250 virtual void setDuSource (
DbU::Unit du ) = 0;
251 virtual void setDuTarget (
DbU::Unit du ) = 0;
252 void computeTerminal ();
253 virtual void updateOrient () = 0;
254 virtual void updatePositions () = 0;
255 void updateSourceSpin ();
256 void updateTargetSpin ();
257 void sourceDetach ();
258 void targetDetach ();
262 void mergeUserConstraints (
const Interval& );
263 inline void resetUserConstraints ();
264 inline void setOptimalMin (
DbU::Unit min );
265 inline void setOptimalMax (
DbU::Unit max );
266 bool checkNotInvalidated ()
const;
270 unsigned int makeDogleg (
Interval,
unsigned int flags=KbNoFlags );
271 unsigned int makeDogleg (
GCell*,
unsigned int flags=KbNoFlags );
272 virtual unsigned int _makeDogleg (
GCell*,
unsigned int flags ) = 0;
273 virtual bool moveULeft () = 0;
274 virtual bool moveURight () = 0;
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 );
281 bool reduceDoglegLayer ();
285 AutoSegment* canonize (
unsigned int flags=KbNoFlags );
286 virtual void invalidate (
unsigned int flags=
KbPropagate );
288 void computeOptimal ( set<AutoSegment*>& processeds );
289 void setAxis (
DbU::Unit,
unsigned int flags=KbNoFlags );
290 bool toConstraintAxis (
unsigned int flags=
KbRealignate );
293 AutoSegments getOnSourceContact (
unsigned int direction );
294 AutoSegments getOnTargetContact (
unsigned int direction );
295 AutoSegments getCachedOnSourceContact (
unsigned int direction );
296 AutoSegments getCachedOnTargetContact (
unsigned int direction );
297 AutoSegments getAligneds (
unsigned int flags=KbNoFlags );
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;
340 virtual void _postCreate ();
341 virtual void _preDestroy ();
347 inline unsigned int _getFlags ()
const;
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); }
403 inline unsigned long AutoSegment::getId ()
const {
return _id; }
404 inline Cell* AutoSegment::getCell ()
const {
return base()->
getCell(); }
405 inline Net* AutoSegment::getNet ()
const {
return base()->getNet(); }
406 inline const Layer* AutoSegment::getLayer ()
const {
return base()->getLayer(); }
407 inline Box AutoSegment::getBoundingBox ()
const {
return base()->getBoundingBox(); }
408 inline Hook* AutoSegment::getSourceHook () {
return base()->getSourceHook(); }
409 inline Hook* AutoSegment::getTargetHook () {
return base()->getTargetHook(); }
410 inline Contact* AutoSegment::getSource ()
const {
return static_cast<Contact*
>(base()->getSource()); }
411 inline Contact* AutoSegment::getTarget ()
const {
return static_cast<Contact*
>(base()->getTarget()); }
412 inline Component* AutoSegment::getOppositeAnchor (
Component* anchor )
const {
return base()->getOppositeAnchor(anchor); };
413 inline AutoSegment* AutoSegment::getParent ()
const {
return _parent; }
414 inline DbU::Unit AutoSegment::getSourcePosition ()
const {
return _sourcePosition; }
415 inline DbU::Unit AutoSegment::getTargetPosition ()
const {
return _targetPosition; }
417 inline DbU::Unit AutoSegment::getSourceY ()
const {
return base()->getSourceY(); }
418 inline DbU::Unit AutoSegment::getTargetX ()
const {
return base()->getTargetX(); }
419 inline DbU::Unit AutoSegment::getTargetY ()
const {
return base()->getTargetY(); }
420 inline DbU::Unit AutoSegment::getWidth ()
const {
return base()->getWidth(); }
421 inline DbU::Unit AutoSegment::getLength ()
const {
return base()->getLength(); }
422 inline void AutoSegment::invert () { base()->invert(); }
423 inline GCell* AutoSegment::getGCell ()
const {
return _gcell; }
424 inline AutoContact* AutoSegment::getAutoSource ()
const {
return Session::lookup(getSource()); }
425 inline AutoContact* AutoSegment::getAutoTarget ()
const {
return Session::lookup(getTarget()); }
428 inline unsigned int AutoSegment::getDepth ()
const {
return _depth; }
430 inline DbU::Unit AutoSegment::getAxis ()
const {
return isHorizontal()?base()->getY():base()->getX(); }
431 inline DbU::Unit AutoSegment::getOrigin ()
const {
return isHorizontal()?_gcell->getY():_gcell->getX(); }
432 inline DbU::Unit AutoSegment::getExtremity ()
const {
return isHorizontal()?_gcell->getYMax():_gcell->getXMax(); }
435 inline const Interval& AutoSegment::getUserConstraints ()
const {
return _userConstraints; }
437 inline bool AutoSegment::isHorizontal ()
const {
return _flags &
SegHorizontal; }
438 inline bool AutoSegment::isVertical ()
const {
return not (_flags &
SegHorizontal); }
439 inline bool AutoSegment::isFixed ()
const {
return _flags &
SegFixed; }
440 inline bool AutoSegment::isGlobal ()
const {
return _flags &
SegGlobal; }
441 inline bool AutoSegment::isWeakGlobal ()
const {
return _flags &
SegWeakGlobal; }
442 inline bool AutoSegment::isLocal ()
const {
return not (_flags &
SegGlobal); }
443 inline bool AutoSegment::isBipoint ()
const {
return _flags &
SegBipoint; }
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; }
452 inline bool AutoSegment::isNotAligned ()
const {
return (_flags &
SegNotAligned) == SegNotAligned; }
453 inline bool AutoSegment::isDogleg ()
const {
return _flags &
SegDogleg ; }
454 inline bool AutoSegment::isUnbound ()
const {
return _flags & SegUnbound ; }
455 inline bool AutoSegment::isStrap ()
const {
return _flags &
SegStrap; }
456 inline bool AutoSegment::isLayerChange ()
const {
return _flags &
SegLayerChange; }
457 inline bool AutoSegment::isSpinTop ()
const {
return ((_flags & SegSpinTop ) == SegSpinTop); }
458 inline bool AutoSegment::isSpinBottom ()
const {
return ((_flags & SegSpinBottom) == SegSpinBottom); }
459 inline bool AutoSegment::isSpinTopOrBottom ()
const {
return isSpinTop() or isSpinBottom(); }
460 inline bool AutoSegment::isReduced ()
const {
return _flags &
SegIsReduced; }
461 inline bool AutoSegment::isSlackened ()
const {
return _flags &
SegSlackened; }
462 inline bool AutoSegment::isCanonical ()
const {
return _flags &
SegCanonical; }
463 inline bool AutoSegment::isUnsetAxis ()
const {
return not (_flags &
SegAxisSet); }
464 inline bool AutoSegment::isInvalidated ()
const {
return _flags &
SegInvalidated; }
466 inline bool AutoSegment::isCreated ()
const {
return _flags &
SegCreated; }
467 inline bool AutoSegment::isUserDefined ()
const {
return _flags & SegUserDefined; }
468 inline void AutoSegment::setFlags (
unsigned int flags ) { _flags |= flags; }
469 inline void AutoSegment::unsetFlags (
unsigned int flags ) { _flags &= ~flags; }
471 inline unsigned int AutoSegment::getFlags ()
const {
return _flags; }
472 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; }
475 inline void AutoSegment::setLayer (
const Layer* layer ) { base()->setLayer(layer); _depth=Session::getLayerDepth(layer); }
479 inline void AutoSegment::resetUserConstraints () { _userConstraints =
Interval(
false); }
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>(); }
496 inline unsigned long AutoSegment::getMaxId ()
507 inline bool AutoSegment::arePerpandiculars (
bool isHorizontalA,
AutoSegment* b )
513 inline unsigned int AutoSegment::getPerpandicularState (
AutoContact* contact
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 const DbU::Unit & getVMax() const
Definition: AutoSegment.h:66
virtual Vertical * getVertical()
Definition: AutoSegment.h:133
const DbU::Unit & getVMin() const
Definition: Constants.h:24
Definition: AutoSegment.h:75
DbU::Unit getSourceX() const
Definition: AutoSegment.h:416
static Unit lambda(double value)
Definition: AutoSegment.h:87
Concrete Horizontal AutoSegment.
Definition: AutoHorizontal.h:31
Definition: AutoSegment.h:84
AutoSegmentFlag
Definition: AutoSegment.h:63
Definition: AutoSegment.h:76
Observer Design Pattern, Subject part.
Definition: Observer.h:69
Definition: AutoSegment.h:83
Definition: AutoSegment.h:89
unsigned long getId() const
Definition: AutoSegment.h:403
Definition: AutoSegment.h:97
Definition: AutoSegment.h:67
Definition: AutoSegment.h:68
Routing Global Cell.
Definition: GCell.h:74
Abstract base class for AutoSegment.
Definition: AutoSegment.h:104
Definition: AutoSegment.h:92
Definition: LoadGrByNet.cpp:405
Definition: AutoSegment.h:73
Definition: Constants.h:38
Definition: AutoSegment.h:70
The namespace dedicated to Katabatic.
Definition: Katabatic.dox:13
Definition: AutoSegment.h:96
Definition: AutoSegment.h:74
virtual Horizontal * getHorizontal()
Definition: AutoSegment.h:132
Definition: AutoSegment.h:88
Definition: AutoSegment.h:71
Definition: AutoSegment.h:82
Definition: AutoSegment.h:72
Definition: AutoSegment.h:65
Definition: AutoSegment.h:77
Definition: AutoSegment.h:69
Observer Design Pattern, Observer part.
Definition: Observer.h:29
Concrete Vertical AutoSegment.
Definition: AutoVertical.h:32
Definition: AutoSegment.h:80
virtual Cell * getCell() const=0
const Layer * getLayer() const
Definition: AutoSegment.h:406
Definition: AutoSegment.h:64
Definition: AutoSegment.h:81
Definition: AutoSegment.h:93
static double getLambda(Unit u)
bool isHorizontal() const
Definition: AutoSegment.h:437