# Coriolis Core (CRL) Documentation

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

Catalog.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 // | Alliance / Hurricane Interface |
9 // | |
10 // | Author : Jean-Paul CHAPUT |
11 // | E-mail : Jean-Paul.Chaput@lip6.fr |
12 // | =============================================================== |
13 // | C++ Header : "./crlcore/Catalog.h" |
14 // +-----------------------------------------------------------------+
15
16
17 #ifndef CRL_CATALOG_H
18 #define CRL_CATALOG_H
19
20 #include <string>
21 #include <map>
22 #include "hurricane/Name.h"
23 #include "hurricane/Property.h"
24 #include "hurricane/Slot.h"
25
26 namespace Hurricane {
27 class Cell;
28 class Library;
29 }
30
31
32 namespace CRL {
33
34
35 using std::string;
36 using std::map;
37 using Hurricane::JsonObject;
38 using Hurricane::JsonStack;
39 using Hurricane::_TName;
40 using Hurricane::Name;
41 using Hurricane::Record;
42 using Hurricane::PrivateProperty;
43 using Hurricane::DBo;
44 using Hurricane::Cell;
45 using Hurricane::Library;
46 using Hurricane::Property;
47
48
49 extern const char* MissingStateProperty;
50
51
52 // -------------------------------------------------------------------
53 // Class : "CRL::Catalog".
54
55
56 class Catalog {
57
58 public:
59 class State;
60 public:
61 inline Catalog ();
62 ~Catalog ();
63 State* getState ( const Name& name, bool add=false );
64 void mergeState ( const Name& name, const State& other );
65 bool deleteState ( const Name& name );
66 void clear ();
67 bool loadFromFile ( const string& path, Library* library );
68 void saveToFile ( const string& path, Library* library );
69 inline map<Name,State*>* getStates ();
70 string _getPrint () const;
71 inline string _getTypeName () const;
72 string _getString () const;
73 Record* _getRecord () const;
74
75 public:
76 // Sub-Class: State.
77 class State {
78 public:
79 // Flags Constants.
80 enum Flags { TerminalNetlist = 1 << 0
81 , Feed = 1 << 1
82 , Pad = 1 << 2
83 , GDS = 1 << 3
84 , Delete = 1 << 4
85 , Logical = 1 << 5
86 , Physical = 1 << 6
87 , InMemory = 1 << 7
88 , Foreign = 1 << 8
89 , VstUseConcat = 1 << 9
90 , Views = Physical|Logical
91 };
92 // Constructors.
93 inline State ();
94 ~State ();
95 // Predicates.
96 inline bool isTerminalNetlist () const;
97 inline bool isFeed () const;
98 inline bool isPad () const;
99 inline bool isGds () const;
100 inline bool isDelete () const;
101 inline bool isPhysical () const;
102 inline bool isLogical () const;
103 inline bool isInMemory () const;
104 // Flags management.
105 inline unsigned int getFlags ( unsigned int mask=(unsigned int)-1 ) const;
106 inline bool setFlags ( unsigned int mask, bool value );
107 inline bool setTerminalNetlist ( bool value );
108 inline bool setFeed ( bool value );
109 inline bool setPad ( bool value );
110 inline bool setGds ( bool value );
111 inline bool setDelete ( bool value );
112 inline bool setPhysical ( bool value );
113 inline bool setLogical ( bool value );
114 inline bool setInMemory ( bool value );
115 // Accessors.
116 inline Cell* getCell () const;
117 inline Library* getLibrary () const;
118 inline unsigned int getDepth () const;
119 // Modifiers.
120 inline void merge ( const State& other );
121 Cell* setCell ( Cell* cell );
122 inline Library* setLibrary ( Library* library );
123 inline void setDepth ( unsigned int depth );
124 // Hurricane Management.
125 void toJson ( JsonWriter* w ) const;
126 inline string _getTypeName () const;
127 string _getString () const;
128 Record* _getRecord () const;
129
130 private:
131 // Internal - Attributes.
132 unsigned int _flags;
133 unsigned int _depth;
134 Cell* _cell;
135 Library* _library;
136
137 // Json Property.
138 public:
139 class JsonState : public JsonObject {
140 public:
141 static void initialize ();
142 JsonState ( unsigned long flags );
143 virtual string getTypeName () const;
144 virtual JsonState* clone ( unsigned long ) const;
145 virtual void toData ( JsonStack& );
146 };
147 };
148
149 private:
150 // Attributes.
151 map<Name,State*> _states;
152
153 private:
154 Catalog ( const Catalog& );
155 static bool readLine ( const string& s, string& name, State* state );
156
157 };
158
159
160 // -------------------------------------------------------------------
161 // Class : "CRL::CatalogProperty".
162
163 class CatalogProperty : public PrivateProperty {
164
165 public:
166 static Name _name;
167 public:
168 static CatalogProperty* create ( Catalog::State* state );
169 static Name getPropertyName ();
170 virtual Name getName () const;
171 inline Catalog::State* getState () const;
172 inline void setState ( Catalog::State* state );
173 virtual void onReleasedBy ( DBo* owner );
174 virtual bool hasJson () const;
175 virtual void toJson ( JsonWriter* w, const DBo* ) const;
176 virtual string _getTypeName () const;
177 virtual string _getString () const;
178 virtual Record* _getRecord () const;
179
180 protected:
181 // Attributes.
182 Catalog::State* _state;
183
184 protected:
185 // Constructor.
186 inline CatalogProperty ( Catalog::State* state );
187 };
188
189
190 // -------------------------------------------------------------------
191 // Class : "CRL::JsonCatalogProperty".
192
193 class JsonCatalogProperty : public JsonObject {
194 public:
195 static void initialize ();
196 JsonCatalogProperty ( unsigned long );
197 virtual string getTypeName () const;
198 virtual JsonCatalogProperty* clone ( unsigned long ) const;
199 virtual void toData ( JsonStack& );
200 };
201
202
203 // -------------------------------------------------------------------
204 // Inline Functions.
205
206 inline Catalog::State::State () : _flags(0), _depth(1), _cell(NULL), _library(NULL) { }
207 inline bool Catalog::State::isTerminalNetlist () const { return (_flags&TerminalNetlist)?1:0; }
208 inline bool Catalog::State::isFeed () const { return (_flags&Feed )?1:0; }
209 inline bool Catalog::State::isPad () const { return (_flags&Pad )?1:0; }
210 inline bool Catalog::State::isGds () const { return (_flags&GDS )?1:0; }
211 inline bool Catalog::State::isDelete () const { return (_flags&Delete )?1:0; }
212 inline bool Catalog::State::isPhysical () const { return (_flags&Physical )?1:0; }
213 inline bool Catalog::State::isLogical () const { return (_flags&Logical )?1:0; }
214 inline bool Catalog::State::isInMemory () const { return (_flags&InMemory )?1:0; }
215 inline unsigned int Catalog::State::getFlags ( unsigned int mask ) const { return ( _flags & mask ); }
216 inline bool Catalog::State::setFlags ( unsigned int mask, bool value ) {
217 if (value) { _flags |= mask; }
218 else { _flags &= ~mask; }
219 return ((_flags&mask) ? true : false);
220 }
221 inline bool Catalog::State::setTerminalNetlist ( bool value ) { return setFlags(TerminalNetlist,value); }
222 inline bool Catalog::State::setFeed ( bool value ) { return setFlags(Feed ,value); }
223 inline bool Catalog::State::setPad ( bool value ) { return setFlags(Pad ,value); }
224 inline bool Catalog::State::setGds ( bool value ) { return setFlags(GDS ,value); }
225 inline bool Catalog::State::setDelete ( bool value ) { return setFlags(Delete ,value); }
226 inline bool Catalog::State::setPhysical ( bool value ) { return setFlags(Physical ,value); }
227 inline bool Catalog::State::setLogical ( bool value ) { return setFlags(Logical ,value); }
228 inline bool Catalog::State::setInMemory ( bool value ) { return setFlags(InMemory ,value); }
229 inline Library* Catalog::State::setLibrary ( Library* library ) { return _library = library; }
230 inline void Catalog::State::setDepth ( unsigned int depth ) { _depth = depth; }
231 inline Cell* Catalog::State::getCell () const { return _cell; }
232 inline Library* Catalog::State::getLibrary () const { return _library; }
233 inline unsigned int Catalog::State::getDepth () const { return _depth; }
234 inline string Catalog::State::_getTypeName () const { return _TName("Catalog::State"); }
235
236 inline Catalog::Catalog () : _states() { }
237 inline map<Name,Catalog::State*>*
238 Catalog::getStates () { return &_states; }
239 inline string Catalog::_getTypeName () const { return _TName("Catalog"); }
240
241 inline CatalogProperty::CatalogProperty ( Catalog::State* state ) : PrivateProperty(), _state(state) {}
242 inline Catalog::State* CatalogProperty::getState () const { return _state; }
243 inline void CatalogProperty::setState ( Catalog::State* state ) { _state = state; }
244
245
246 // -------------------------------------------------------------------
247 // Class : "CRL::CatalogExtension".
248
249
250 class CatalogExtension {
251 public:
252 static Catalog::State* get ( const Cell* );
253 public:
254 static inline bool isTerminalNetlist ( const Cell* );
255 static inline bool isFeed ( const Cell* );
256 static inline bool isPad ( const Cell* );
257 static inline bool isGds ( const Cell* );
258 static inline bool isDelete ( const Cell* );
259 static inline bool isPhysical ( const Cell* );
260 static inline bool isLogical ( const Cell* );
261 // Flags management.
262 static inline unsigned int getFlags ( const Cell*, unsigned int mask=(unsigned int)-1 );
263 static inline bool setFlags ( const Cell*, unsigned int mask, bool value );
264 static inline bool setTerminalNetlist ( const Cell*, bool value );
265 static inline bool setFeed ( const Cell*, bool value );
266 static inline bool setPad ( const Cell*, bool value );
267 static inline bool setGds ( const Cell*, bool value );
268 static inline bool setDelete ( const Cell*, bool value );
269 static inline bool setPhysical ( const Cell*, bool value );
270 static inline bool setLogical ( const Cell*, bool value );
271 // Accessors.
272 static inline Library* getLibrary ( const Cell* );
273 static inline unsigned int getDepth ( const Cell* );
274 // Modifiers.
275 static inline Library* setLibrary ( const Cell*, Library* library );
276 static inline void setDepth ( const Cell*, unsigned int depth );
277 private:
278 static const Cell* _owner;
279 static Catalog::State* _cache;
280 };
281
282
283 inline bool CatalogExtension::isTerminalNetlist ( const Cell* cell )
284 {
285 Catalog::State* state = get(cell);
286 return (state == NULL) ? false : state->isTerminalNetlist();
287 }
288
289
290 inline bool CatalogExtension::isFeed ( const Cell* cell )
291 {
292 Catalog::State* state = get(cell);
293 return (state == NULL) ? false : state->isFeed();
294 }
295
296
297 inline bool CatalogExtension::isGds ( const Cell* cell )
298 {
299 Catalog::State* state = get(cell);
300 return (state == NULL) ? false : state->isGds();
301 }
302
303
304 inline bool CatalogExtension::isPad ( const Cell* cell )
305 {
306 Catalog::State* state = get(cell);
307 return (state == NULL) ? false : state->isPad();
308 }
309
310
311 inline bool CatalogExtension::isDelete ( const Cell* cell )
312 {
313 Catalog::State* state = get(cell);
314 return (state == NULL) ? false : state->isDelete();
315 }
316
317
318 inline bool CatalogExtension::isPhysical ( const Cell* cell )
319 {
320 Catalog::State* state = get(cell);
321 return (state == NULL) ? false : state->isPhysical();
322 }
323
324
325 inline bool CatalogExtension::isLogical ( const Cell* cell )
326 {
327 Catalog::State* state = get(cell);
328 return (state == NULL) ? false : state->isLogical();
329 }
330
331
332 inline unsigned int CatalogExtension::getFlags ( const Cell* cell, unsigned int mask )
333 {
334 Catalog::State* state = get(cell);
335 return (state == NULL) ? 0 : state->getFlags();
336 }
337
338
339 inline bool CatalogExtension::setFlags ( const Cell* cell, unsigned int mask, bool value )
340 {
341 Catalog::State* state = get(cell);
342 return (state == NULL) ? false : state->setFlags(mask,value);
343 }
344
345
346 inline bool CatalogExtension::setTerminalNetlist ( const Cell* cell, bool value )
347 {
348 Catalog::State* state = get(cell);
349 return (state == NULL) ? false : state->setTerminalNetlist(value);
350 }
351
352
353 inline bool CatalogExtension::setFeed ( const Cell* cell, bool value )
354 {
355 Catalog::State* state = get(cell);
356 return (state == NULL) ? false : state->setFeed(value);
357 }
358
359
360 inline bool CatalogExtension::setPad ( const Cell* cell, bool value )
361 {
362 Catalog::State* state = get(cell);
363 return (state == NULL) ? false : state->setPad(value);
364 }
365
366
367 inline bool CatalogExtension::setGds ( const Cell* cell, bool value )
368 {
369 Catalog::State* state = get(cell);
370 return (state == NULL) ? false : state->setGds(value);
371 }
372
373
374 inline bool CatalogExtension::setDelete ( const Cell* cell, bool value )
375 {
376 Catalog::State* state = get(cell);
377 return (state == NULL) ? false : state->setDelete(value);
378 }
379
380
381 inline bool CatalogExtension::setPhysical ( const Cell* cell, bool value )
382 {
383 Catalog::State* state = get(cell);
384 return (state == NULL) ? false : state->setPhysical(value);
385 }
386
387
388 inline bool CatalogExtension::setLogical ( const Cell* cell, bool value )
389 {
390 Catalog::State* state = get(cell);
391 return (state == NULL) ? false : state->setLogical(value);
392 }
393
394
395 inline Library* CatalogExtension::getLibrary ( const Cell* cell )
396 {
397 Catalog::State* state = get(cell);
398 return (state == NULL) ? NULL : state->getLibrary();
399 }
400
401
402 inline unsigned int CatalogExtension::getDepth ( const Cell* cell )
403 {
404 Catalog::State* state = get(cell);
405 return (state == NULL) ? 0 : state->getDepth();
406 }
407
408
409 inline Library* CatalogExtension::setLibrary ( const Cell* cell, Library* library )
410 {
411 Catalog::State* state = get(cell);
412 return (state == NULL) ? NULL : state->setLibrary(library);
413 }
414
415
416 inline void CatalogExtension::setDepth ( const Cell* cell, unsigned int depth )
417 {
418 Catalog::State* state = get(cell);
419 if ( state == NULL ) state->setDepth(depth);
420 }
421
422
423 } // End of CRL namespace.
424
425
426
427
428 // x-----------------------------------------------------------------x
429 // | Functions Overload for Hurricane Management |
430 // x-----------------------------------------------------------------x
431
432
433 inline std::string getPrint ( const CRL::Catalog &CATAL ) { return CATAL._getPrint(); }
434
435 INSPECTOR_P_SUPPORT(CRL::Catalog);
436 INSPECTOR_P_SUPPORT(CRL::Catalog::State);
437
438
439 #endif // CRL_CATALOG_H
CRL::Catalog::clear
void clear()
CRL::CatalogExtension::setPad
static bool setPad(const Cell *, bool value)
Definition: Catalog.h:360
Hurricane::PrivateProperty
CRL::Catalog::State
An entry to store the Cell State in the Catalog.
Definition: Catalog.h:77
CRL::Catalog::State::InMemory
Definition: Catalog.h:87
CRL::CatalogExtension::setLogical
static bool setLogical(const Cell *, bool value)
Definition: Catalog.h:388
Hurricane::Library
CRL::Catalog::State::~State
~State()
CRL::Catalog::State::setPad
bool setPad(bool value)
Definition: Catalog.h:223
CRL::Catalog::State::getCell
Cell * getCell() const
Definition: Catalog.h:231
CRL::CatalogExtension::isGds
static bool isGds(const Cell *)
Definition: Catalog.h:297
CRL::Catalog::State::setGds
bool setGds(bool value)
Definition: Catalog.h:224
CRL::Catalog::State::setCell
Cell * setCell(Cell *cell)
CRL::Catalog::Catalog
Catalog()
Definition: Catalog.h:236
CRL::CatalogExtension::isDelete
static bool isDelete(const Cell *)
Definition: Catalog.h:311
CRL::Catalog::State::isFeed
bool isFeed() const
Definition: Catalog.h:208
CRL::CatalogExtension::isLogical
static bool isLogical(const Cell *)
Definition: Catalog.h:325
CRL::CatalogExtension::setFeed
static bool setFeed(const Cell *, bool value)
Definition: Catalog.h:353
Hurricane::JsonObject
CRL::Catalog::State::merge
void merge(const State &other)
Hurricane::Name
CRL::Catalog::State::isPad
bool isPad() const
Definition: Catalog.h:209
CRL::Catalog::State::getDepth
unsigned int getDepth() const
Definition: Catalog.h:233
CRL::Catalog::State::isDelete
bool isDelete() const
Definition: Catalog.h:211
CRL::Catalog::State::isLogical
bool isLogical() const
Definition: Catalog.h:213
Hurricane::Cell
Hurricane::DBo
CRL::Catalog::State::setLibrary
Library * setLibrary(Library *library)
Definition: Catalog.h:229
CRL::Catalog::State::Physical
Definition: Catalog.h:86
CRL::Catalog::State::Views
Definition: Catalog.h:90
CRL::Catalog::State::setLogical
bool setLogical(bool value)
Definition: Catalog.h:227
CRL::CatalogExtension::setGds
static bool setGds(const Cell *, bool value)
Definition: Catalog.h:367
CRL::Catalog::State::Delete
Definition: Catalog.h:84
CRL::Catalog::deleteState
bool deleteState(const Name &name)
Hurricane::JsonStack
CRL::Catalog::mergeState
void mergeState(const Name &name, const State &other)
CRL::Catalog::State::setFeed
bool setFeed(bool value)
Definition: Catalog.h:222
CRL::Catalog::~Catalog
~Catalog()
CRL::Catalog::State::Feed
Definition: Catalog.h:81
CRL::Catalog::State::setFlags
bool setFlags(unsigned int mask, bool value)
Definition: Catalog.h:216
Hurricane::Property
CRL::Catalog::getStates
map< Name, State * > * getStates()
Definition: Catalog.h:238
CRL::CatalogExtension::isFeed
static bool isFeed(const Cell *)
Definition: Catalog.h:290
CRL::Catalog::State::Pad
Definition: Catalog.h:82
CRL::Catalog::State::isGds
bool isGds() const
Definition: Catalog.h:210
CRL::CatalogExtension::getLibrary
static Library * getLibrary(const Cell *)
Definition: Catalog.h:395
CRL::CatalogExtension::getFlags
static unsigned int getFlags(const Cell *, unsigned int mask=(unsigned int)-1)
Definition: Catalog.h:332
CRL::Catalog::getState
State * getState(const Name &name, bool add=false)
CRL::Catalog::State::State
State()
Definition: Catalog.h:206
CRL::Catalog::State::getLibrary
Library * getLibrary() const
Definition: Catalog.h:232
CRL::CatalogExtension::isPad
static bool isPad(const Cell *)
Definition: Catalog.h:304
CRL::Catalog::loadFromFile
bool loadFromFile(const string &path, Library *library)
CRL::Catalog::State::setDelete
bool setDelete(bool value)
Definition: Catalog.h:225
CRL::CatalogExtension::setLibrary
static Library * setLibrary(const Cell *, Library *library)
Definition: Catalog.h:409
CRL::CatalogExtension::setPhysical
static bool setPhysical(const Cell *, bool value)
Definition: Catalog.h:381
CRL::Catalog::State::Logical
Definition: Catalog.h:85
CRL::Catalog::State::getFlags
unsigned int getFlags(unsigned int mask=(unsigned int)-1) const
Definition: Catalog.h:215
CRL::Catalog
A Registry to store Alliance Cell metadatas.
Definition: Catalog.h:56
CRL::Catalog::State::isPhysical
bool isPhysical() const
Definition: Catalog.h:212
CRL::Catalog::State::GDS
Definition: Catalog.h:83
CRL::CatalogExtension::setDelete
static bool setDelete(const Cell *, bool value)
Definition: Catalog.h:374
CRL::CatalogExtension
Wrapper to access a Hurricane::Cell Catalog::State.
Definition: Catalog.h:250
CRL::Catalog::State::setPhysical
bool setPhysical(bool value)
Definition: Catalog.h:226
CRL::CatalogExtension::isPhysical
static bool isPhysical(const Cell *)
Definition: Catalog.h:318
CRL::CatalogExtension::getDepth
static unsigned int getDepth(const Cell *)
Definition: Catalog.h:402
CRL::Catalog::State::Flags
Flags
Definition: Catalog.h:80
CRL::CatalogExtension::setFlags
static bool setFlags(const Cell *, unsigned int mask, bool value)
Definition: Catalog.h:339

Generated by doxygen 1.8.5 on Thu Mar 19 2020 | Return to top of page

Coriolis Core (CRL) | Copyright © 2008-2016 UPMC All rights reserved