# Hurricane VLSI Database

Query.h
1 // -*- C++ -*-
2 //
3 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
4 //
5 // This file is part of Hurricane.
6 //
7 // Hurricane is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
11 //
12 // Hurricane is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
14 // TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the Lesser GNU General Public
18 // License along with Hurricane. If not, see
19 // <http://www.gnu.org/licenses/>.
20 //
21 // +-----------------------------------------------------------------+
22 // | H U R R I C A N E |
23 // | V L S I B a c k e n d D a t a - B a s e |
24 // | |
25 // | Author : Jean-Paul CHAPUT |
26 // | E-mail : Jean-Paul.Chaput@lip6.fr |
27 // | =============================================================== |
28 // | C++ Header : "./hurricane/Query.h" |
29 // +-----------------------------------------------------------------+
30
31
32 #ifndef HURRICANE_QUERY_H
33 #define HURRICANE_QUERY_H
34
35 #include <vector>
36 #include "hurricane/Commons.h"
37 #include "hurricane/Box.h"
38 #include "hurricane/Transformation.h"
39 #include "hurricane/Cell.h"
40 #include "hurricane/Instance.h"
41
42
43 namespace Hurricane {
44
45 class BasicLayer;
46 class Go;
47 class QueryStack;
48
49
50 // -------------------------------------------------------------------
51 // Slave Class : "QueryState".
52
53 class QueryState {
54 private:
55 inline QueryState ( Locator<Instance*>* locator );
56 inline QueryState ( Locator<Instance*>* locator
57 , const Box& area
58 , const Transformation& transformation
59 , const Path& path
60 );
61 QueryState ( const QueryState& );
62 QueryState& operator= ( const QueryState& );
63 inline ~QueryState ();
64 private:
65 Locator<Instance*>* _locator;
66 Box _area;
67 Transformation _transformation;
68 Path _path;
69
70 friend class QueryStack;
71 };
72
73
74 // QueryState Inline Functions.
75
76
77 inline QueryState::QueryState ( Locator<Instance*>* locator )
78 : _locator (locator)
79 , _area ()
80 , _transformation()
81 , _path ()
82 { }
83
84
85 inline QueryState::QueryState ( Locator<Instance*>* locator
86 , const Box& area
87 , const Transformation& transformation
88 , const Path& path
89 )
90 : _locator (locator)
91 , _area (area)
92 , _transformation(transformation)
93 , _path (path)
94 { }
95
96
97 inline QueryState::~QueryState ()
98 {
99 if ( _locator ) delete _locator;
100 }
101
102
103 // -------------------------------------------------------------------
104 // Class : "QueryStack".
105
106
107 class QueryStack : public vector<QueryState*> {
108 public:
109 // Constructor & destructor.
110 QueryStack ();
111 ~QueryStack ();
112 // Accessors.
113 inline Cell* getTopCell ();
114 inline const Box& getTopArea () const;
115 inline const Transformation& getTopTransformation () const;
116 inline unsigned int getStartLevel () const;
117 inline unsigned int getStopLevel () const;
118 inline Cell* getMasterCell ();
119 inline Instance* getInstance ();
120 inline const Box& getArea () const;
121 inline const Transformation& getTransformation () const;
122 inline const Path& getPath () const;
123 //inline const Tabulation& getTab () const;
124 // Modifiers.
125 inline void setTopCell ( Cell* cell );
126 inline void setTopArea ( const Box& area );
127 inline void setTopTransformation ( const Transformation& transformation );
128 inline void setStartLevel ( unsigned int level );
129 inline void setStopLevel ( unsigned int level );
130 inline void init ();
131 inline void updateTransformation ();
132 inline bool levelDown ();
133 inline void levelUp ();
134 inline void levelProgress ();
135 inline bool levelCompleted ();
136 inline void progress ( bool init=false );
137
138 protected:
139 // Internal: Attributes.
140 // Tabulation _tab;
141 Cell* _topCell;
142 Box _topArea;
143 Transformation _topTransformation;
144 unsigned int _startLevel;
145 unsigned int _stopLevel;
146
147 private:
148 // Internal: Constructors.
149 QueryStack ( const QueryStack& );
150 QueryStack& operator= ( const QueryStack& );
151 };
152
153
154 // QueryStack Inline Functions.
155
156
157 inline Cell* QueryStack::getTopCell () { return _topCell; }
158 inline const Box& QueryStack::getTopArea () const { return _topArea; }
159 inline const Transformation& QueryStack::getTopTransformation () const { return _topTransformation; }
160 inline unsigned int QueryStack::getStartLevel () const { return _startLevel; }
161 inline unsigned int QueryStack::getStopLevel () const { return _stopLevel; }
162 inline const Box& QueryStack::getArea () const { return back()->_area; }
163 inline const Transformation& QueryStack::getTransformation () const { return back()->_transformation; }
164 inline const Path& QueryStack::getPath () const { return back()->_path; }
165 //inline const Tabulation& QueryStack::getTab () const { return _tab; }
166
167
168 inline Instance* QueryStack::getInstance ()
169 {
170 if ( levelCompleted() ) return NULL;
171 return back()->_locator->getElement();
172 }
173
174
175 inline Cell* QueryStack::getMasterCell ()
176 {
177 if ( size() == 1 ) return _topCell;
178 if ( !getInstance() ) return NULL;
179 return getInstance()->getMasterCell();
180 }
181
182
183 inline void QueryStack::setTopCell ( Cell* cell ) { _topCell = cell; }
184 inline void QueryStack::setTopArea ( const Box& area ) { _topArea = area; }
185 inline void QueryStack::setTopTransformation ( const Transformation& transformation ) { _topTransformation = transformation; }
186 inline void QueryStack::setStartLevel ( unsigned int level ) { _startLevel = level; }
187 inline void QueryStack::setStopLevel ( unsigned int level ) { _stopLevel = level; }
188
189
190 inline void QueryStack::init ()
191 {
192 while ( !empty() ) levelUp();
193
194 push_back ( new QueryState(NULL,_topArea,_topTransformation,Path()) );
195 //_tab++;
196
197 progress ( true );
198 }
199
200
201 inline void QueryStack::updateTransformation ()
202 {
203 QueryState* child = *(rbegin() );
204 QueryState* parent = *(rbegin()+1);
205 Instance* instance = child->_locator->getElement();
206
207 child->_area = parent->_area;
208 child->_transformation = instance->getTransformation ();
209
210 instance->getTransformation().getInvert().applyOn ( child->_area );
211 parent->_transformation.applyOn ( child->_transformation );
212
213 //child->_path = Path ( Path(parent->_path,instance->getCell()->getShuntedPath()) , instance );
214 child->_path = Path ( parent->_path, instance );
215 }
216
217
218 inline bool QueryStack::levelDown ()
219 {
220 if ( size() > _stopLevel ) return false;
221
222 Locator<Instance*>* locator = getMasterCell()->getInstancesUnder(getArea()).getLocator();
223
224 if ( locator->isValid() ) {
225 push_back ( new QueryState ( locator ) );
226
227 updateTransformation ();
228 //_tab++;
229
230 return true;
231 } else
232 delete locator;
233
234 return false;
235 }
236
237
238 inline void QueryStack::levelUp ()
239 {
240 delete back ();
241 pop_back ();
242 //_tab--;
243 }
244
245
246 inline bool QueryStack::levelCompleted ()
247 {
248 if ( !back()->_locator || !back()->_locator->isValid () ) return true;
249 return false;
250 }
251
252
253 inline void QueryStack::levelProgress ()
254 {
255 if ( levelCompleted() ) return;
256
257 back()->_locator->progress ();
258 if ( !back()->_locator->isValid() ) return;
259
260 updateTransformation ();
261 }
262
263
264 inline void QueryStack::progress ( bool init )
265 {
266 if ( !init ) levelProgress ();
267 else {
268 if ( !levelDown() && ( size() > _startLevel ) )
269 return;
270 }
271
272 while ( !empty() ) {
273 if ( levelCompleted() ) {
274 levelUp ();
275 } else {
276 if ( levelDown() ) continue;
277 }
278
279 if ( size() > _startLevel ) return;
280 if ( empty() ) break;
281 levelProgress ();
282 }
283 }
284
285
286 // -------------------------------------------------------------------
287 // Class : "Query".
288
289 class Query {
290 public:
291 typedef Hurricane::Mask<int> Mask;
292 public:
293 // Types.
294 enum QueryFilter { DoMasterCells = 1
295 , DoTerminalCells = 2
296 , DoComponents = 4
297 , DoMarkers = 8
298 , DoRubbers = 16
299 , DoExtensionGos = 32
300 , DoAll = DoMasterCells
301 | DoTerminalCells
302 | DoComponents
303 | DoMarkers
304 | DoRubbers
305 | DoExtensionGos
306 };
307 public:
308 // Constructors & Destructors.
309 Query ();
310 virtual ~Query ();
311 // Accessors.
312 inline unsigned int getStartLevel () const;
313 inline unsigned int getStopLevel () const;
314 inline size_t getDepth () const;
315 inline const Transformation& getTransformation () const;
316 inline const Box& getArea () const;
317 inline const BasicLayer* getBasicLayer () const;
318 inline Cell* getMasterCell ();
319 inline Instance* getInstance ();
320 inline Path getPath () const;
321 //inline const Tabulation& getTab () const;
322 virtual bool hasGoCallback () const;
323 virtual bool hasMarkerCallback () const;
324 virtual bool hasRubberCallback () const;
325 virtual bool hasExtensionGoCallback () const;
326 virtual bool hasMasterCellCallback () const;
327 virtual void goCallback ( Go* ) = 0;
328 virtual void markerCallback ( Marker* );
329 virtual void rubberCallback ( Rubber* );
330 virtual void extensionGoCallback ( Go* ) = 0;
331 virtual void masterCellCallback () = 0;
332 // Modifiers.
333 void setQuery ( Cell* cell
334 , const Box& area
335 , const Transformation& transformation
336 , const BasicLayer* basicLayer
337 , ExtensionSlice::Mask extensionMask
338 , Mask filter
339 );
340 inline void setCell ( Cell* cell );
341 inline void setArea ( const Box& area );
342 inline void setTransformation ( const Transformation& transformation );
343 virtual void setBasicLayer ( const BasicLayer* basicLayer );
344 inline void setExtensionMask ( ExtensionSlice::Mask mode );
345 inline void setFilter ( Mask mode );
346 inline void setStartLevel ( unsigned int level );
347 inline void setStopLevel ( unsigned int level );
348 virtual void doQuery ();
349
350 protected:
351 // Internal: Attributes.
352 QueryStack _stack;
353 const BasicLayer* _basicLayer;
354 ExtensionSlice::Mask _extensionMask;
355 Mask _filter;
356 };
357
358
359 // Query Inline Functions.
360
361 inline void Query::setCell ( Cell* cell ) { _stack.setTopCell(cell); }
362 inline void Query::setArea ( const Box& area ) { _stack.setTopArea(area); }
363 inline void Query::setTransformation ( const Transformation& transformation ) { _stack.setTopTransformation(transformation); }
364 inline void Query::setFilter ( Mask filter ) { _filter = filter; }
365 inline void Query::setExtensionMask ( ExtensionSlice::Mask mask ) { _extensionMask = mask; }
366 inline void Query::setStartLevel ( unsigned int level ) { _stack.setStartLevel(level); }
367 inline void Query::setStopLevel ( unsigned int level ) { _stack.setStopLevel(level); }
368
369 inline unsigned int Query::getStartLevel () const { return _stack.getStartLevel(); }
370 inline unsigned int Query::getStopLevel () const { return _stack.getStopLevel(); }
371 inline size_t Query::getDepth () const { return _stack.size(); }
372 inline const Box& Query::getArea () const { return _stack.getArea(); }
373 inline const Transformation& Query::getTransformation () const { return _stack.getTransformation(); }
374 inline Path Query::getPath () const { return _stack.getPath(); }
375 inline const BasicLayer* Query::getBasicLayer () const { return _basicLayer; }
376 inline Cell* Query::getMasterCell () { return _stack.getMasterCell(); }
377 inline Instance* Query::getInstance () { return _stack.getInstance(); }
378 //inline const Tabulation& Query::getTab () const { return _stack.getTab(); }
379
380
381 } // Hurricane namespace.
382
383 #endif // HURRICANE_QUERY_H
Hurricane::Path
Path description (API)
Definition: Path.h:37
Hurricane::Query::DoComponents
Definition: Query.h:296
Hurricane::Go
Go description (API)
Definition: Go.h:36
Hurricane::Query::getStopLevel
unsigned int getStopLevel() const
Definition: Query.h:370
Hurricane::BasicLayer
BasicLayer description (API)
Definition: BasicLayer.h:44
Hurricane::Query::setStartLevel
void setStartLevel(unsigned int level)
Definition: Query.h:366
Hurricane::Query::getArea
const Box & getArea() const
Definition: Query.h:372
Hurricane::Query::DoExtensionGos
Definition: Query.h:299
Hurricane::Query::getInstance
Instance * getInstance()
Definition: Query.h:377
Hurricane::Query
Query description (API)
Definition: Query.h:289
Hurricane::Query::setBasicLayer
virtual void setBasicLayer(const BasicLayer *basicLayer)
Hurricane::Query::~Query
virtual ~Query()
Hurricane::Query::Query
Query()
Hurricane::Cell
The model (API).
Definition: Cell.h:66
Hurricane::Query::DoTerminalCells
Definition: Query.h:295
Hurricane::Query::markerCallback
virtual void markerCallback(Marker *)
Hurricane::Query::setArea
void setArea(const Box &area)
Definition: Query.h:362
Hurricane::Query::hasGoCallback
virtual bool hasGoCallback() const
Hurricane::Query::DoMarkers
Definition: Query.h:297
Hurricane::Query::getStartLevel
unsigned int getStartLevel() const
Definition: Query.h:369
Hurricane::Query::setStopLevel
void setStopLevel(unsigned int level)
Definition: Query.h:367
Hurricane::Transformation
Transformation description (API)
Definition: Transformation.h:32
Hurricane::Query::getDepth
size_t getDepth() const
Definition: Query.h:371
Hurricane::Query::rubberCallback
virtual void rubberCallback(Rubber *)
Hurricane::Query::setFilter
void setFilter(Mask mode)
Definition: Query.h:364
Hurricane::Query::DoRubbers
Definition: Query.h:298
Hurricane::Query::setQuery
void setQuery(Cell *cell, const Box &area, const Transformation &transformation, const BasicLayer *basicLayer, ExtensionSlice::Mask extensionMask, Mask filter)
Hurricane::Query::getPath
Path getPath() const
Definition: Query.h:374
Hurricane::Box
Box description (API)
Definition: Box.h:31
Hurricane::Instance
Instance description (API)
Definition: Instance.h:37
Hurricane::Query::setCell
void setCell(Cell *cell)
Definition: Query.h:361
Hurricane::Query::hasMarkerCallback
virtual bool hasMarkerCallback() const
Hurricane::Query::getBasicLayer
const BasicLayer * getBasicLayer() const
Definition: Query.h:375
Hurricane::Query::hasExtensionGoCallback
virtual bool hasExtensionGoCallback() const
Hurricane::Query::masterCellCallback
virtual void masterCellCallback()=0
Hurricane::Query::extensionGoCallback
virtual void extensionGoCallback(Go *)=0
Hurricane::Query::getMasterCell
Cell * getMasterCell()
Definition: Query.h:376
Hurricane
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5
Hurricane::Query::setTransformation
void setTransformation(const Transformation &transformation)
Definition: Query.h:363
Hurricane::Query::doQuery
virtual void doQuery()
Hurricane::Query::goCallback
virtual void goCallback(Go *)=0
Hurricane::Query::DoMasterCells
Definition: Query.h:294
Hurricane::Query::QueryFilter
QueryFilter
Definition: Query.h:294
Hurricane::Query::hasRubberCallback
virtual bool hasRubberCallback() const
Hurricane::Query::setExtensionMask
void setExtensionMask(ExtensionSlice::Mask mode)
Definition: Query.h:365
Hurricane::Query::hasMasterCellCallback
virtual bool hasMasterCellCallback() const
Hurricane::Rubber
Rubber description (API)
Definition: Rubber.h:36
Hurricane::Query::DoAll
Definition: Query.h:300
Hurricane::Query::getTransformation
const Transformation & getTransformation() const
Definition: Query.h:373

Generated by doxygen 1.8.14 on Sun Mar 8 2020 | Return to top of page

Hurricane VLSI Database | Copyright © 2000-2016 Bull S.A. All rights reserved