17 #ifndef KATABATIC_GCELL_H 18 #define KATABATIC_GCELL_H 25 #include "hurricane/DbU.h" 26 #include "hurricane/Point.h" 27 #include "hurricane/Box.h" 28 #include "hurricane/Interval.h" 29 #include "hurricane/ExtensionGo.h" 35 #include "crlcore/RoutingLayerGauge.h" 36 #include "katabatic/Constants.h" 37 #include "katabatic/AutoSegments.h" 46 using std::binary_function;
47 using Hurricane::_TName;
48 using Hurricane::Record;
54 using Hurricane::ExtensionGo;
62 enum GCellFunctionFlags { NoUpdate = 0x00000001 };
68 enum GCellFlag { GCellInvalidated = 0x00000001
69 , GCellSaturated = 0x00000002
70 , GCellUnderIoPad = 0x00000004
74 class GCell :
public ExtensionGo {
77 class CompareByIndex :
public binary_function<const GCell*,const GCell*,bool> {
79 bool operator() (
const GCell* lhs,
const GCell* rhs );
88 class CompareByKey :
public binary_function<const GCell*,const GCell*,bool> {
90 bool operator() (
const GCell* lhs,
const GCell* rhs );
98 inline Key (
GCell*,
unsigned int depth );
99 inline float getDensity ()
const;
100 inline GCell* getGCell ()
const;
101 inline void update (
unsigned int depth );
102 friend bool operator< (
const Key&,
const Key& );
109 static bool areDensityConnex (
GCell* a,
GCell* b );
111 static size_t getAllocateds ();
113 static const Name& getStaticName ();
114 virtual const Name& getName ()
const;
116 inline bool isSaturated ()
const;
117 bool isSaturated (
unsigned int depth )
const;
118 inline bool isValid ()
const;
119 inline bool isUnderIoPad ()
const;
120 bool isAboveDensity (
float threshold )
const;
121 bool hasFreeTrack (
size_t depth,
float reserve )
const;
123 inline unsigned int getDepth ()
const;
124 inline unsigned int getIndex ()
const;
125 unsigned int getRow ()
const;
126 unsigned int getColumn ()
const;
127 GCell* getLeft ()
const;
128 GCell* getRight ()
const;
129 GCell* getUp ()
const;
130 GCell* getDown ()
const;
131 void getDensities (
float* )
const;
133 virtual Box getBoundingBox ()
const;
134 inline Point getCenter ()
const;
139 Interval getSide (
unsigned int )
const;
140 float getHCapacity ()
const;
141 float getVCapacity ()
const;
142 float getDensity (
unsigned int flags=0 )
const;
143 float getAverageHVDensity ()
const;
144 float getMaxHVDensity ()
const;
145 inline float getCDensity (
unsigned int flags=0 )
const;
146 inline float getWDensity (
unsigned int depth,
unsigned int flags=0 )
const;
147 inline DbU::Unit getBlockage (
unsigned int depth )
const;
148 inline float getFragmentation (
unsigned int depth )
const;
149 inline float getFeedthroughs (
unsigned int depth )
const;
150 inline float getGlobalsCount (
unsigned int depth )
const;
151 inline const vector<AutoSegment*>& getHSegments ()
const;
152 inline const vector<AutoSegment*>& getVSegments ()
const;
153 inline const vector<AutoContact*>& getContacts ()
const;
158 inline AutoSegments getStartSegments (
unsigned int direction );
159 inline AutoSegments getStopSegments (
unsigned int direction );
160 size_t getRoutingPads ( set<RoutingPad*>& );
161 inline const Key& getKey ()
const;
162 size_t checkDensity ()
const;
163 bool checkEdgeSaturation (
size_t hreserved,
size_t vreserved)
const;
165 void addBlockage (
unsigned int depth,
DbU::Unit );
172 void updateContacts ();
173 size_t updateDensity ();
174 inline void updateKey (
unsigned int depth );
175 bool stepBalance (
unsigned int depth, SetIndex& invalidateds );
176 void rpDesaturate ( set<Net*>& );
177 bool stepDesaturate (
unsigned int depth
179 ,
unsigned int flags=0 );
180 bool stepNetDesaturate (
unsigned int depth
181 , set<Net*>& globalNets
182 , SetIndex& invalidateds );
183 inline void invalidateCt ();
184 inline void setUnderIoPad ();
185 void truncDensities ();
187 Record* _getRecord ()
const;
188 string _getString ()
const;
189 inline string _getTypeName ()
const;
190 void _xmlWrite ( ostream& o )
const;
194 static const Name _goName;
195 static size_t _allocateds;
200 vector<AutoSegment*> _vsegments;
201 vector<AutoSegment*> _hsegments;
202 vector<AutoContact*> _contacts;
209 float* _feedthroughs;
210 float* _fragmentations;
211 float* _globalsCount;
222 inline void _postCreate ();
223 inline void _preDestroy ();
237 inline bool GCell::isSaturated ()
const {
return _flags&GCellSaturated; }
238 inline bool GCell::isValid ()
const {
return not (_flags&GCellInvalidated); }
239 inline bool GCell::isUnderIoPad ()
const {
return _flags&GCellUnderIoPad; }
240 inline GCellGrid* GCell::getGCellGrid ()
const {
return _gcellGrid; }
241 inline unsigned int GCell::getDepth ()
const {
return _depth; }
242 inline unsigned int GCell::getIndex ()
const {
return _index; }
243 inline Point GCell::getCenter ()
const {
return _box.getCenter(); }
244 inline DbU::Unit GCell::getX ()
const {
return _box.getXMin(); }
245 inline DbU::Unit GCell::getY ()
const {
return _box.getYMin(); }
246 inline DbU::Unit GCell::getXMax ()
const {
return _box.getXMax(); }
247 inline DbU::Unit GCell::getYMax ()
const {
return _box.getYMax(); }
248 inline const vector<AutoSegment*>& GCell::getVSegments ()
const {
return _vsegments; }
249 inline const vector<AutoSegment*>& GCell::getHSegments ()
const {
return _hsegments; }
250 inline const vector<AutoContact*>& GCell::getContacts ()
const {
return _contacts; }
251 inline string GCell::_getTypeName ()
const {
return _TName(
"GCell"); }
252 inline void GCell::invalidateCt () { _flags |= GCellInvalidated; }
253 inline void GCell::setUnderIoPad() { _flags |= GCellUnderIoPad; }
254 inline const GCell::Key& GCell::getKey ()
const {
return _key; }
255 inline void GCell::updateKey (
unsigned int depth ) { _key.
update(depth); }
258 {
return (direction&
KbHorizontal) ? getHStartSegments() : getVStartSegments(); }
261 {
return (direction&
KbHorizontal) ? getHStopSegments() : getVStopSegments(); }
263 inline float GCell::getCDensity (
unsigned int flags )
const 264 {
if (not isValid() and not(flags & NoUpdate))
const_cast<GCell*
>(
this)->updateDensity();
return _cDensity; }
266 inline float GCell::getWDensity (
unsigned int depth,
unsigned int flags )
const 267 {
if (not isValid() and not(flags & NoUpdate))
const_cast<GCell*
>(
this)->updateDensity();
return _densities[depth]; }
269 inline float GCell::getFragmentation (
unsigned int depth )
const 270 {
if (not isValid())
const_cast<GCell*
>(
this)->updateDensity();
return _fragmentations[depth]; }
272 inline float GCell::getFeedthroughs (
unsigned int depth )
const 273 {
if (not isValid())
const_cast<GCell*
>(
this)->updateDensity();
return _feedthroughs[depth]; }
275 inline float GCell::getGlobalsCount (
unsigned int depth )
const 276 {
if (not isValid())
const_cast<GCell*
>(
this)->updateDensity();
return _globalsCount[depth]; }
278 inline DbU::Unit GCell::getBlockage (
unsigned int depth )
const 279 {
return (depth<_depth) ? _blockages[depth] : 0; }
282 { invalidateCt(); _vsegments.push_back(segment); }
285 { invalidateCt(); _hsegments.push_back(segment); }
288 { invalidateCt(); _contacts.push_back(contact); }
292 inline bool GCell::CompareByIndex::operator() (
const GCell* lhs,
const GCell* rhs )
297 inline GCell::Key::Key (
GCell* owner,
unsigned int depth ) : _gcell(owner), _density(owner->getWDensity(depth,NoUpdate)) {}
305 float difference = lhs._density - rhs._density;
306 if (difference != 0.0)
return (difference > 0.0);
320 inline bool empty ()
const;
321 inline size_t size ()
const;
322 inline const std::set<GCell*,GCell::CompareByKey>&
324 inline void insert (
GCell* );
325 inline void erase (
GCell* );
326 inline void unqueue (
GCell* );
330 std::set<GCell*,GCell::CompareByKey> _set;
347 string getVectorString (
float*,
size_t );
350 typedef std::vector<GCell*> GCellVector;
359 #endif // KATABATIC_GCELL_H GCell Density Comparison Functor.
Definition: GCell.h:81
void insert(GCell *)
Definition: GCell.h:337
bool empty() const
Definition: GCell.h:335
GCell * getGCell() const
Definition: GCell.h:299
const std::set< GCell *, GCell::CompareByKey > & getGCells() const
Definition: GCell.h:340
void erase(GCell *)
Definition: GCell.h:338
GCell Grid.
Definition: GCellGrid.h:42
GCell Index Comparison Functor.
Definition: GCell.h:77
Routing Global Cell.
Definition: GCell.h:74
Abstract base class for AutoSegment.
Definition: AutoSegment.h:104
set< GCell *, CompareByIndex > SetIndex
Definition: GCell.h:105
The namespace dedicated to Katabatic.
Definition: Katabatic.dox:13
unsigned int getIndex() const
Definition: GCell.h:242
void update(unsigned int depth)
Definition: GCell.h:300
size_t size() const
Definition: GCell.h:336
Definition: Constants.h:27
float getDensity() const
Definition: GCell.h:298
GCell Set, sorted by density.
Definition: GCell.h:315
GCell Key - Density Cache.
Definition: GCell.h:93
float getWDensity(unsigned int depth, unsigned int flags=0) const
Definition: GCell.h:266
void unqueue(GCell *)
Definition: GCell.h:339