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#pragma once
33#include <vector>
34#include <iomanip>
35#include "hurricane/Commons.h"
36#include "hurricane/Box.h"
37#include "hurricane/Transformation.h"
38#include "hurricane/Cell.h"
39#include "hurricane/Instance.h"
40
41
42namespace Hurricane {
43
44 class BasicLayer;
45 class Go;
46 class QueryStack;
47
48
49// -------------------------------------------------------------------
50// Slave Class : "QueryState".
51
52 class QueryState {
53 private:
54 inline QueryState ( Locator<Instance*>* locator );
55 inline QueryState ( Locator<Instance*>* locator
56 , const Box& area
57 , const Transformation& transformation
58 , const Path& path
59 );
60 QueryState ( const QueryState& );
61 QueryState& operator= ( const QueryState& );
62 inline ~QueryState ();
63 private:
64 Locator<Instance*>* _locator;
65 Box _area;
66 Transformation _transformation;
67 Path _path;
68
69 friend class QueryStack;
70 };
71
72
73// QueryState Inline Functions.
74
75
76 inline QueryState::QueryState ( Locator<Instance*>* locator )
77 : _locator (locator)
78 , _area ()
79 , _transformation()
80 , _path ()
81 { }
82
83
84 inline QueryState::QueryState ( Locator<Instance*>* locator
85 , const Box& area
86 , const Transformation& transformation
87 , const Path& path
88 )
89 : _locator (locator)
90 , _area (area)
91 , _transformation(transformation)
92 , _path (path)
93 { }
94
95
96 inline QueryState::~QueryState ()
97 {
98 if ( _locator ) delete _locator;
99 }
100
101
102// -------------------------------------------------------------------
103// Class : "QueryStack".
104
105
106 class QueryStack : public vector<QueryState*> {
107 public:
108 // Constructor & destructor.
109 QueryStack ();
110 ~QueryStack ();
111 // Accessors.
112 inline Cell* getTopCell ();
113 inline const Box& getTopArea () const;
114 inline const Transformation& getTopTransformation () const;
115 inline unsigned int getStartLevel () const;
116 inline unsigned int getStopLevel () const;
117 inline Cell::Flags getStopCellFlags () const;
118 inline Cell* getMasterCell ();
119 inline Instance* getInstance ();
120 inline const Box& getArea () const;
121 inline DbU::Unit getThreshold () const;
122 inline const Transformation& getTransformation () const;
123 inline const Path& getPath () const;
124 //inline const Tabulation& getTab () const;
125 // Modifiers.
126 inline void setTopCell ( Cell* cell );
127 inline void setTopArea ( const Box& area );
128 inline void setTopTransformation ( const Transformation& transformation );
129 inline void setThreshold ( DbU::Unit threshold );
130 inline void setStartLevel ( unsigned int level );
131 inline void setStopLevel ( unsigned int level );
132 inline void setStopCellFlags ( Cell::Flags );
133 inline void unsetStopCellFlags ( Cell::Flags );
134 inline void init ();
135 inline void updateTransformation ();
136 inline bool levelDown ();
137 inline void levelUp ();
138 inline void levelProgress ();
139 inline bool levelCompleted ();
140 inline void progress ( bool init=false );
141 inline size_t getInstanceCount () const;
142
143 protected:
144 // Internal: Attributes.
145 // Tabulation _tab;
146 Cell* _topCell;
147 Box _topArea;
148 DbU::Unit _threshold;
149 Transformation _topTransformation;
150 unsigned int _startLevel;
151 unsigned int _stopLevel;
152 Cell::Flags _stopCellFlags;
153 size_t _instanceCount;
154
155 private:
156 // Internal: Constructors.
157 QueryStack ( const QueryStack& );
158 QueryStack& operator= ( const QueryStack& );
159 };
160
161
162// QueryStack Inline Functions.
163
164
165 inline Cell* QueryStack::getTopCell () { return _topCell; }
166 inline const Box& QueryStack::getTopArea () const { return _topArea; }
167 inline const Transformation& QueryStack::getTopTransformation () const { return _topTransformation; }
168 inline DbU::Unit QueryStack::getThreshold () const { return _threshold; }
169 inline unsigned int QueryStack::getStartLevel () const { return _startLevel; }
170 inline unsigned int QueryStack::getStopLevel () const { return _stopLevel; }
171 inline Cell::Flags QueryStack::getStopCellFlags () const { return _stopCellFlags; }
172 inline const Box& QueryStack::getArea () const { return back()->_area; }
173 inline const Transformation& QueryStack::getTransformation () const { return back()->_transformation; }
174 inline const Path& QueryStack::getPath () const { return back()->_path; }
175//inline const Tabulation& QueryStack::getTab () const { return _tab; }
176 inline size_t QueryStack::getInstanceCount () const { return _instanceCount; }
177
178
179 inline Instance* QueryStack::getInstance ()
180 {
181 if ( levelCompleted() ) return NULL;
182 return back()->_locator->getElement();
183 }
184
185
186 inline Cell* QueryStack::getMasterCell ()
187 {
188 if ( size() == 1 ) return _topCell;
189 if ( !getInstance() ) return NULL;
190 return getInstance()->getMasterCell();
191 }
192
193
194 inline void QueryStack::setTopCell ( Cell* cell ) { _topCell = cell; }
195 inline void QueryStack::setTopArea ( const Box& area ) { _topArea = area; }
196 inline void QueryStack::setTopTransformation ( const Transformation& transformation ) { _topTransformation = transformation; }
197 inline void QueryStack::setThreshold ( DbU::Unit threshold ) { _threshold = threshold; }
198 inline void QueryStack::setStartLevel ( unsigned int level ) { _startLevel = level; }
199 inline void QueryStack::setStopLevel ( unsigned int level ) { _stopLevel = level; }
200 inline void QueryStack::setStopCellFlags ( Cell::Flags flags ) { _stopCellFlags = flags; }
201 inline void QueryStack::unsetStopCellFlags ( Cell::Flags flags ) { _stopCellFlags.reset(flags); }
202
203
204 inline void QueryStack::init ()
205 {
206 _instanceCount = 0;
207 while (not empty()) levelUp();
208
209 push_back( new QueryState(NULL,_topArea,_topTransformation,Path()) );
210 //_tab++;
211
212 progress( true );
213 }
214
215
216 inline void QueryStack::updateTransformation ()
217 {
218 QueryState* child = *(rbegin() );
219 QueryState* parent = *(rbegin()+1);
220 Instance* instance = child->_locator->getElement();
221
222 //cerr << "Processing " << instance << endl;
223
224 child->_area = parent->_area;
225 child->_transformation = instance->getTransformation ();
226
227 instance->getTransformation().getInvert().applyOn ( child->_area );
228 parent->_transformation.applyOn ( child->_transformation );
229
230 //child->_path = Path ( Path(parent->_path,instance->getCell()->getShuntedPath()) , instance );
231 child->_path = Path ( parent->_path, instance );
232 //cerr << "QueryStack::updateTransformation() " << child->_path << endl;
233 }
234
235
236 inline bool QueryStack::levelDown ()
237 {
238 if (size() > _stopLevel) return false;
239 if (getMasterCell()->getFlags().isset(_stopCellFlags)) return false;
240
241 //cerr << "QueryStack::levelDown(): t:" << DbU::getValueString(getThreshold()) << endl;
242 Locator<Instance*>* locator =
243 getMasterCell()->getInstancesUnder(getArea(),getThreshold()).getLocator();
244
245 if ( locator->isValid() ) {
246 push_back ( new QueryState ( locator ) );
247
248 updateTransformation ();
249 //_tab++;
250
251 return true;
252 } else
253 delete locator;
254
255 //cerr << " Aborting level down" << endl;
256 return false;
257 }
258
259
260 inline void QueryStack::levelUp ()
261 {
262 delete back ();
263 pop_back ();
264 //_tab--;
265 }
266
267
268 inline bool QueryStack::levelCompleted ()
269 {
270 if ( !back()->_locator || !back()->_locator->isValid () ) return true;
271 return false;
272 }
273
274
275 inline void QueryStack::levelProgress ()
276 {
277 if (levelCompleted()) return;
278
279 back()->_locator->progress();
280 if (not back()->_locator->isValid()) return;
281
282 //cerr << " stack:" << std::setw(3) << _instanceCount << ":" << getPath() << endl;
283 ++_instanceCount;
284 updateTransformation();
285 }
286
287
288 inline void QueryStack::progress ( bool init )
289 {
290 if (not init) levelProgress ();
291 else {
292 if (not levelDown() and (size() > _startLevel))
293 return;
294 }
295
296 while (not empty()) {
297 if (levelCompleted()) {
298 levelUp ();
299 } else {
300 if (levelDown()) continue;
301 }
302
303 if (size() > _startLevel) return;
304 if (empty()) break;
305 levelProgress();
306 }
307 }
308
309
310// -------------------------------------------------------------------
311// Class : "Query".
312
313 class Query {
314 public:
315 typedef Hurricane::Mask<uint64_t> Mask;
316 public:
317 // Types.
327 | DoMarkers
328 | DoRubbers
330 };
331 public:
332 // Constructors & Destructors.
334 virtual ~Query ();
335 // Accessors.
336 inline unsigned int getStartLevel () const;
337 inline unsigned int getStopLevel () const;
338 inline Cell::Flags getStopCellFlags () const;
339 inline size_t getDepth () const;
340 inline const Transformation& getTransformation () const;
341 inline const Box& getTopArea () const;
342 inline const Box& getArea () const;
343 inline DbU::Unit getThreshold () const;
344 inline const BasicLayer* getBasicLayer () const;
345 inline Cell* getMasterCell ();
346 inline Instance* getInstance ();
347 inline Path getPath () const;
348 //inline const Tabulation& getTab () const;
349 virtual bool hasGoCallback () const;
350 virtual bool hasMarkerCallback () const;
351 virtual bool hasRubberCallback () const;
352 virtual bool hasExtensionGoCallback () const;
353 virtual bool hasMasterCellCallback () const;
354 virtual void goCallback ( Go* ) = 0;
355 virtual void markerCallback ( Marker* );
356 virtual void rubberCallback ( Rubber* );
357 virtual void extensionGoCallback ( Go* ) = 0;
358 virtual void masterCellCallback () = 0;
359 // Modifiers.
360 void setQuery ( Cell* cell
361 , const Box& area
362 , const Transformation& transformation
363 , const BasicLayer* basicLayer
364 , ExtensionSlice::Mask extensionMask
365 , Mask filter
366 , DbU::Unit threshold=0
367 );
368 inline void setCell ( Cell* cell );
369 inline void setArea ( const Box& area );
370 inline void setThreshold ( DbU::Unit threshold );
371 inline void setTransformation ( const Transformation& transformation );
372 virtual void setBasicLayer ( const BasicLayer* basicLayer );
373 inline void setExtensionMask ( ExtensionSlice::Mask mode );
374 inline void setFilter ( Mask mode );
375 inline void setStartLevel ( unsigned int level );
376 inline void setStopLevel ( unsigned int level );
377 inline void setStopCellFlags ( Cell::Flags );
378 inline void unsetStopCellFlags ( Cell::Flags );
379 virtual void doQuery ();
380
381 protected:
382 // Internal: Attributes.
383 QueryStack _stack;
384 const BasicLayer* _basicLayer;
385 ExtensionSlice::Mask _extensionMask;
386 Mask _filter;
387 };
388
389
390// Query Inline Functions.
391
392 inline void Query::setCell ( Cell* cell ) { _stack.setTopCell(cell); }
393 inline void Query::setArea ( const Box& area ) { _stack.setTopArea(area); }
394 inline void Query::setThreshold ( DbU::Unit threshold ) { _stack.setThreshold(threshold); }
395 inline void Query::setTransformation ( const Transformation& transformation ) { _stack.setTopTransformation(transformation); }
396 inline void Query::setFilter ( Mask filter ) { _filter = filter; }
397 inline void Query::setExtensionMask ( ExtensionSlice::Mask mask ) { _extensionMask = mask; }
398 inline void Query::setStartLevel ( unsigned int level ) { _stack.setStartLevel(level); }
399 inline void Query::setStopLevel ( unsigned int level ) { _stack.setStopLevel(level); }
400 inline void Query::setStopCellFlags ( Cell::Flags flags ) { _stack.setStopCellFlags(flags); }
401 inline void Query::unsetStopCellFlags ( Cell::Flags flags ) { _stack.unsetStopCellFlags(flags); }
402
403 inline unsigned int Query::getStartLevel () const { return _stack.getStartLevel(); }
404 inline unsigned int Query::getStopLevel () const { return _stack.getStopLevel(); }
405 inline Cell::Flags Query::getStopCellFlags () const { return _stack.getStopCellFlags(); }
406 inline size_t Query::getDepth () const { return _stack.size(); }
407 inline const Box& Query::getTopArea () const { return _stack.getTopArea(); }
408 inline const Box& Query::getArea () const { return _stack.getArea(); }
409 inline const Transformation& Query::getTransformation () const { return _stack.getTransformation(); }
410 inline Path Query::getPath () const { return _stack.getPath(); }
411 inline const BasicLayer* Query::getBasicLayer () const { return _basicLayer; }
412 inline Cell* Query::getMasterCell () { return _stack.getMasterCell(); }
413 inline Instance* Query::getInstance () { return _stack.getInstance(); }
414//inline const Tabulation& Query::getTab () const { return _stack.getTab(); }
415
416
417} // Hurricane namespace.
418
419
420INSPECTOR_PR_SUPPORT(Hurricane::Query::Mask);
BasicLayer description (API)
Definition BasicLayer.h:42
Box description (API)
Definition Box.h:30
The model (API).
Definition Cell.h:64
std::int64_t Unit
Definition DbU.h:67
Go description (API)
Definition Go.h:34
Instance description (API)
Definition Instance.h:35
Locator description (API)
Definition Locator.h:33
Path description (API)
Definition Path.h:35
QueryFilter
Definition Query.h:318
@ DoComponents
Definition Query.h:320
@ DoExtensionGos
Definition Query.h:323
@ DoAll
Definition Query.h:324
@ DoTerminalCells
Definition Query.h:319
@ DoMasterCells
Definition Query.h:318
@ DoMarkers
Definition Query.h:321
@ DoRubbers
Definition Query.h:322
virtual bool hasRubberCallback() const
virtual void masterCellCallback()=0
virtual void rubberCallback(Rubber *)
virtual bool hasMarkerCallback() const
unsigned int getStopLevel() const
Definition Query.h:404
void setCell(Cell *cell)
Definition Query.h:392
virtual bool hasMasterCellCallback() const
void setFilter(Mask mode)
Definition Query.h:396
Instance * getInstance()
Definition Query.h:413
virtual ~Query()
virtual void doQuery()
virtual void extensionGoCallback(Go *)=0
virtual void markerCallback(Marker *)
const Box & getArea() const
Definition Query.h:408
void setStopLevel(unsigned int level)
Definition Query.h:399
void setQuery(Cell *cell, const Box &area, const Transformation &transformation, const BasicLayer *basicLayer, ExtensionSlice::Mask extensionMask, Mask filter, DbU::Unit threshold=0)
unsigned int getStartLevel() const
Definition Query.h:403
virtual void goCallback(Go *)=0
void setTransformation(const Transformation &transformation)
Definition Query.h:395
void setStartLevel(unsigned int level)
Definition Query.h:398
virtual bool hasGoCallback() const
const Transformation & getTransformation() const
Definition Query.h:409
virtual bool hasExtensionGoCallback() const
void setArea(const Box &area)
Definition Query.h:393
const BasicLayer * getBasicLayer() const
Definition Query.h:411
virtual void setBasicLayer(const BasicLayer *basicLayer)
Cell * getMasterCell()
Definition Query.h:412
Path getPath() const
Definition Query.h:410
void setExtensionMask(ExtensionSlice::Mask mode)
Definition Query.h:397
size_t getDepth() const
Definition Query.h:406
Rubber description (API)
Definition Rubber.h:36
Transformation description (API)
Definition Transformation.h:32
Contains Almost Everything.
Definition BasicLayer.h:39


Generated by doxygen 1.13.2 on Fri Sep 27 2024 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved