# Kite - Detailed Router

RoutingEvent.h
1 // -*- C++ -*-
2 //
3 // This file is part of the Coriolis Software.
4 // Copyright (c) UPMC 2008-2018, All Rights Reserved
5 //
6 // +-----------------------------------------------------------------+
7 // | C O R I O L I S |
8 // | K i t e - D e t a i l e d R o u t e r |
9 // | |
10 // | Author : Jean-Paul CHAPUT |
11 // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
12 // | =============================================================== |
13 // | C++ Header : "./kite/RoutingEvent.h" |
14 // +-----------------------------------------------------------------+
15
16
17 #ifndef KITE_ROUTING_EVENT_H
18 #define KITE_ROUTING_EVENT_H
19
20 #include <set>
21 #include <vector>
22 #include <cstdlib>
23 #include <functional>
24
25 #include "hurricane/Interval.h"
26 namespace Hurricane {
27 class Net;
28 }
29
30 #include "kite/TrackCost.h"
31 #include "kite/TrackElement.h"
32 #include "kite/DataNegociate.h"
33 #include "kite/Session.h"
34
35
36 namespace Kite {
37
38 using std::set;
39 using std::vector;
40 using std::binary_function;
41 using std::labs;
42 using Hurricane::DbU;
43 using Hurricane::Interval;
44 using Hurricane::Net;
45 class TrackElement;
46 class Track;
47 class RoutingEventHistory;
48 class RoutingEventQueue;
49 class RoutingEventLoop;
50
51
52 // -------------------------------------------------------------------
53 // Class : "RoutingEvent".
54
55 class RoutingEvent {
56
57 private:
58 class Key {
59 public:
60 class Compare : public binary_function<const Key&,const Key&,bool> {
61 public:
62 bool operator() ( const Key& lhs, const Key& rhs ) const;
63 };
64
65 public:
66 Key ( const RoutingEvent* );
67 void update ( const RoutingEvent* );
68 private:
69 unsigned int _tracksNb:6;
70 float _priority;
71 unsigned int _eventLevel;
72 unsigned int _segFlags;
73 unsigned int _layerDepth;
74 DbU::Unit _length;
75 DbU::Unit _axis;
76 DbU::Unit _sourceU;
77 Net* _net;
78 unsigned long _id;
79 friend class Compare;
80 };
81
82 public:
83 // Sub-Class: "Compare".
84 class Compare : public binary_function<const RoutingEvent*,const RoutingEvent*,bool> {
85 public:
86 bool operator() ( const RoutingEvent* lhs, const RoutingEvent* rhs ) const;
87 };
88 // Sub-Class: "CompareById".
89 class CompareById : public binary_function<const RoutingEvent*,const RoutingEvent*,bool> {
90 public:
91 inline bool operator() ( const RoutingEvent* lhs, const RoutingEvent* rhs ) const;
92 };
93 friend class Compare;
94
95 public:
96 enum Mode { Negociate=1, Pack=2, Repair=3 };
97
98 public:
99 static unsigned int getStage ();
100 static size_t getAllocateds ();
101 static size_t getProcesseds ();
102 static size_t getCloneds ();
103 static void resetProcesseds ();
104 static void setStage ( unsigned int );
105 public:
106 static RoutingEvent* create ( TrackElement*, unsigned int mode=Negociate );
107 RoutingEvent* clone () const;
108 void destroy ();
109 inline bool isCloned () const;
110 inline bool isValid () const;
111 bool isUnimplemented () const;
112 inline bool isProcessed () const;
113 inline bool isDisabled () const;
114 inline bool isForcedToHint () const;
115 inline bool isSheared () const;
116 inline bool isRipedByLocal () const;
117 inline bool isOverConstrained () const;
118 inline unsigned int getId () const;
119 inline unsigned int getTimeStamp () const;
120 inline bool getMode () const;
121 inline bool canMinimize () const;
122 unsigned int getState () const;
123 inline const Key& getKey () const;
124 inline TrackElement* getSegment () const;
125 inline const vector<TrackElement*>& getPerpandiculars () const;
126 inline DbU::Unit getAxisHint () const;
127 inline DbU::Unit getAxisHistory () const;
128 inline long getAxisWeight ( DbU::Unit ) const;
129 inline const Interval& getConstraints () const;
130 inline const Interval& getOptimal () const;
131 inline const Interval& getPerpandicularFree () const;
132 inline float getPriority () const;
133 inline unsigned int getTracksNb () const;
134 inline unsigned int getTracksFree () const;
135 inline unsigned int getInsertState () const;
136 inline unsigned int getEventLevel () const;
137 void revalidate ();
138 inline void updateKey ();
139 void process ( RoutingEventQueue&
140 , RoutingEventHistory&
141 , RoutingEventLoop&
142 );
143 void setSegment ( TrackElement* );
144 RoutingEvent* reschedule ( RoutingEventQueue&, unsigned int eventLevel );
145 void setMode ( unsigned int );
146 void setState ( unsigned int );
147 inline void setTimeStamp ( unsigned int );
148 inline void setProcessed ( bool state=true );
149 inline void setDisabled ( bool state=true );
150 inline void setMinimized ( bool state=true );
151 inline void setRipedByLocal ( bool state=true );
152 inline void setTracksFree ( unsigned int );
153 inline void setForcedToHint ( bool state = true );
154 void setAxisHint ( DbU::Unit );
155 void setAxisHintFromParent ();
156 inline void incInsertState ();
157 inline void resetInsertState ();
158 inline void setEventLevel ( unsigned int );
159 void _processNegociate ( RoutingEventQueue&, RoutingEventHistory& );
160 void _processPack ( RoutingEventQueue&, RoutingEventHistory& );
161 void _processRepair ( RoutingEventQueue&, RoutingEventHistory& );
162 Record* _getRecord () const;
163 string _getString () const;
164 string _getTypeName () const;
165 private:
166 RoutingEvent ( TrackElement*, unsigned int mode );
167 ~RoutingEvent ();
168
169 protected:
170 // Attributes.
171 static unsigned int _idCounter;
172 static unsigned int _stage;
173 static size_t _allocateds;
174 static size_t _processeds;
175 static size_t _cloneds;
176 mutable bool _cloned;
177 bool _processed;
178 bool _disabled;
179 bool _overConstrained;
180 bool _minimized;
181 bool _forceToHint;
182 bool _ripedByLocal;
183 unsigned int _id;
184 unsigned int _timeStamp;
185 TrackElement* _segment;
186 DataNegociate* _dataNegociate;
187 DbU::Unit _axisHistory;
188 DbU::Unit _axisHint;
189 Interval _constraints;
190 Interval _optimal;
191 //Interval _perpandicular;
192 unsigned int _tracksNb : 6;
193 unsigned int _tracksFree : 4;
194 unsigned int _insertState : 6;
195 unsigned int _mode : 4;
196 unsigned int _rippleState : 4;
197 unsigned int _eventLevel;
198 float _priority;
199 //vector<TrackElement*> _perpandiculars;
200 Key _key;
201 };
202
203
204 // Inline Functions.
205 inline bool RoutingEvent::isCloned () const { return _cloned; }
206 inline bool RoutingEvent::isProcessed () const { return _processed; }
207 inline bool RoutingEvent::isDisabled () const { return _disabled; }
208 inline bool RoutingEvent::isForcedToHint () const { return _forceToHint; }
209 inline bool RoutingEvent::isRipedByLocal () const { return _ripedByLocal; }
210 inline bool RoutingEvent::isOverConstrained () const { return _overConstrained; }
211 inline unsigned int RoutingEvent::getId () const { return _id; }
212 inline unsigned int RoutingEvent::getTimeStamp () const { return _timeStamp; }
213 inline bool RoutingEvent::getMode () const { return _mode; }
214 inline bool RoutingEvent::canMinimize () const { return not _minimized; }
215 inline const RoutingEvent::Key& RoutingEvent::getKey () const { return _key; }
216 inline TrackElement* RoutingEvent::getSegment () const { return _segment; }
217 inline const vector<TrackElement*>& RoutingEvent::getPerpandiculars () const { return _dataNegociate->getPerpandiculars(); }
218 //inline const vector<TrackElement*>& RoutingEvent::getPerpandiculars () const { return _perpandiculars; }
219 inline DbU::Unit RoutingEvent::getAxisHistory () const { return _axisHistory; }
220 inline DbU::Unit RoutingEvent::getAxisHint () const { return _axisHint; }
221 inline long RoutingEvent::getAxisWeight ( DbU::Unit axis ) const { return labs(axis - getAxisHint()); }
222 inline const Interval& RoutingEvent::getConstraints () const { return _constraints; }
223 inline const Interval& RoutingEvent::getOptimal () const { return _optimal; }
224 inline const Interval& RoutingEvent::getPerpandicularFree () const { return _dataNegociate->getPerpandicularFree(); }
225 //inline const Interval& RoutingEvent::getPerpandicular () const { return _perpandicular; }
226 inline float RoutingEvent::getPriority () const { return _priority; }
227 inline unsigned int RoutingEvent::getEventLevel () const { return _eventLevel; }
228 inline unsigned int RoutingEvent::getTracksNb () const { return _tracksNb; }
229 inline unsigned int RoutingEvent::getTracksFree () const { return _tracksFree; }
230 inline unsigned int RoutingEvent::getInsertState () const { return _insertState; }
231 inline void RoutingEvent::setTimeStamp ( unsigned int stamp ) { _timeStamp = stamp; }
232 inline void RoutingEvent::setProcessed ( bool state ) { _processed = state; }
233 inline void RoutingEvent::setDisabled ( bool state ) { _disabled = state; }
234 inline void RoutingEvent::setMinimized ( bool state ) { _minimized = state; }
235 inline void RoutingEvent::setRipedByLocal ( bool state ) { _ripedByLocal = state; }
236 inline void RoutingEvent::setTracksFree ( unsigned int nb ) { _tracksFree = nb; }
237 inline void RoutingEvent::setForcedToHint ( bool state ) { _forceToHint = state; }
238 inline void RoutingEvent::incInsertState () { _insertState++; }
239 inline void RoutingEvent::resetInsertState () { _insertState = 0; }
240 inline void RoutingEvent::setEventLevel ( unsigned int level ) { _eventLevel = level; }
241 inline void RoutingEvent::updateKey () { revalidate(); _key.update(this); }
242
243 inline bool RoutingEvent::CompareById::operator() ( const RoutingEvent* lhs, const RoutingEvent* rhs ) const
244 { return lhs->getId() < rhs->getId(); }
245
246
247 typedef set<RoutingEvent*,RoutingEvent::CompareById> RoutingEventSet;
248
249
250 // -------------------------------------------------------------------
251 // Macros.
252
253
254 # if !defined(NDEBUG)
255 # define _preCheck(segment) \
256 DbU::Unit beforeMin = segment->base()->getSourcePosition(); \
257 DbU::Unit beforeMax = segment->base()->getTargetPosition(); \
258 segment->base()->checkPositions (); \
259 if ( Session::getSegmentStackSize() ) \
260 cerr << "[ERROR] Session Segment Stack is not empty (" \
261 << Session::getSegmentStackSize() << ")." << endl;
262
263 # define _postCheck(segment) \
264 cdebug_log(159,0) << "Bounds := [" \
265 << DbU::getValueString(segment->base()->getSourcePosition()) << ":" \
266 << DbU::getValueString(segment->base()->getTargetPosition()) << "] " \
267 << DbU::getValueString(segment->getAxis()) << " " \
268 << segment->getTrack() << endl; \
269 if ( beforeMin != segment->base()->getSourcePosition() ) \
270 cerr << "[ERROR] " << segment \
271 << " origin was " << DbU::getValueString(beforeMin) << endl; \
272 if ( beforeMax != segment->base()->getTargetPosition() ) \
273 cerr << "[ERROR] " << segment \
274 << " extremity was " << DbU::getValueString(beforeMax) << endl;
275 # else
276 # define _preCheck(segment) ;
277 # define _postCheck(segment) ;
278 # endif
279
280
281 } // Kite namespace.
282
283
284 INSPECTOR_P_SUPPORT(Kite::RoutingEvent);
285
286
287 #endif // KITE_ROUTING_EVENT_H
Kite::RoutingEvent
Atomic Placement Request for a TrackSegment.
Definition: RoutingEvent.h:55
Kite::RoutingEvent::Repair
Definition: RoutingEvent.h:96
Kite::RoutingEvent::isCloned
bool isCloned() const
Definition: RoutingEvent.h:205
Kite::RoutingEvent::getEventLevel
unsigned int getEventLevel() const
Definition: RoutingEvent.h:227
Kite::RoutingEvent::setSegment
void setSegment(TrackElement *)
Definition: RoutingEvent.cpp:351
Kite::RoutingEvent::create
static RoutingEvent * create(TrackElement *, unsigned int mode=Negociate)
Definition: RoutingEvent.cpp:200
Kite::RoutingEvent::getAllocateds
static size_t getAllocateds()
Definition: RoutingEvent.cpp:150
Kite::RoutingEvent::getConstraints
const Interval & getConstraints() const
Definition: RoutingEvent.h:222
Kite::RoutingEvent::getProcesseds
static size_t getProcesseds()
Definition: RoutingEvent.cpp:151
Hurricane::Net
Kite::RoutingEvent::getInsertState
unsigned int getInsertState() const
Definition: RoutingEvent.h:230
Kite::RoutingEvent::canMinimize
bool canMinimize() const
Definition: RoutingEvent.h:214
Hurricane::DbU::Unit
std::int64_t Unit
Kite::RoutingEvent::getState
unsigned int getState() const
Definition: RoutingEvent.cpp:261
Kite::RoutingEvent::resetProcesseds
static void resetProcesseds()
Definition: RoutingEvent.cpp:154
Kite::RoutingEvent::isForcedToHint
bool isForcedToHint() const
Definition: RoutingEvent.h:208
Hurricane::Interval
Kite::RoutingEvent::getPriority
float getPriority() const
Definition: RoutingEvent.h:226
Kite::RoutingEventLoop
Simple loop dectector for RoutingEvent.
Definition: RoutingEventLoop.h:32
Kite::RoutingEvent::setStage
static void setStage(unsigned int)
Definition: RoutingEvent.cpp:153
Kite::RoutingEvent::getSegment
TrackElement * getSegment() const
Definition: RoutingEvent.h:216
Kite::RoutingEvent::process
void process(RoutingEventQueue &, RoutingEventHistory &, RoutingEventLoop &)
Definition: RoutingEvent.cpp:359
Kite::RoutingEvent::setAxisHintFromParent
void setAxisHintFromParent()
Definition: RoutingEvent.cpp:282
Kite::RoutingEvent::setMode
void setMode(unsigned int)
Definition: RoutingEvent.cpp:257
Kite::RoutingEvent::destroy
void destroy()
Definition: RoutingEvent.cpp:244
Kite::RoutingEvent::incInsertState
void incInsertState()
Definition: RoutingEvent.h:238
Kite::RoutingEvent::getOptimal
const Interval & getOptimal() const
Definition: RoutingEvent.h:223
Kite::RoutingEvent::getTracksNb
unsigned int getTracksNb() const
Definition: RoutingEvent.h:228
Kite::RoutingEvent::isProcessed
bool isProcessed() const
Definition: RoutingEvent.h:206
Kite::RoutingEventHistory
History of RoutingEvent.
Definition: RoutingEventHistory.h:35
Hurricane::DbU
Kite::RoutingEvent::updateKey
void updateKey()
Definition: RoutingEvent.h:241
Kite::RoutingEvent::revalidate
void revalidate()
Definition: RoutingEvent.cpp:600
Kite::RoutingEvent::getAxisWeight
long getAxisWeight(DbU::Unit) const
Definition: RoutingEvent.h:221
Kite::RoutingEvent::getMode
bool getMode() const
Definition: RoutingEvent.h:213
Kite::DataNegociate::getPerpandicularFree
const Interval & getPerpandicularFree() const
Definition: DataNegociate.h:131
Kite::TrackElement
Abstract Class for all Elements inserted inside a Track.
Definition: TrackElement.h:100
Kite::RoutingEvent::Key::update
void update(const RoutingEvent *)
Definition: RoutingEvent.cpp:122
Kite::RoutingEvent::getPerpandiculars
const vector< TrackElement * > & getPerpandiculars() const
Definition: RoutingEvent.h:217
Kite::RoutingEvent::isRipedByLocal
bool isRipedByLocal() const
Definition: RoutingEvent.h:209
Kite::RoutingEvent::Mode
Mode
Definition: RoutingEvent.h:96
Kite::RoutingEvent::isUnimplemented
bool isUnimplemented() const
Definition: RoutingEvent.cpp:253
Kite::RoutingEvent::reschedule
RoutingEvent * reschedule(RoutingEventQueue &, unsigned int eventLevel)
Definition: RoutingEvent.cpp:307
Kite::RoutingEvent::isValid
bool isValid() const
Kite::RoutingEvent::isDisabled
bool isDisabled() const
Definition: RoutingEvent.h:207
Kite::RoutingEvent::resetInsertState
void resetInsertState()
Definition: RoutingEvent.h:239
Kite::RoutingEvent::Key
RoutingEvent cached key for maps.
Definition: RoutingEvent.h:58
Kite::RoutingEventQueue
The priority Queue of RoutingEvent.
Definition: RoutingEventQueue.h:35
Hurricane
Kite::RoutingEvent::getKey
const Key & getKey() const
Definition: RoutingEvent.h:215
Kite::RoutingEvent::setEventLevel
void setEventLevel(unsigned int)
Definition: RoutingEvent.h:240
Kite
The namespace dedicated to Kite.
Definition: Constants.h:22
Kite::RoutingEvent::getAxisHistory
DbU::Unit getAxisHistory() const
Definition: RoutingEvent.h:219
Kite::RoutingEvent::setState
void setState(unsigned int)
Definition: RoutingEvent.cpp:268
Kite::RoutingEvent::getAxisHint
DbU::Unit getAxisHint() const
Definition: RoutingEvent.h:220
Kite::DataNegociate
Algorimthmic datas associated the TrackSegment.
Definition: DataNegociate.h:50
Kite::RoutingEvent::Pack
Definition: RoutingEvent.h:96
Kite::RoutingEvent::Negociate
Definition: RoutingEvent.h:96
Hurricane::Net
Kite::RoutingEvent::getStage
static unsigned int getStage()
Definition: RoutingEvent.cpp:149
Kite::RoutingEvent::clone
RoutingEvent * clone() const
Definition: RoutingEvent.cpp:215

Generated by doxygen 1.8.14 on Mon Feb 3 2020 | Return to top of page

Kite - Detailed Router | Copyright © 2008-2016 UPMC. All rights reserved