# Coriolis Core (CRLCore) Documentation

# Coriolis Core (CRL) Documentation

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