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


Generated by doxygen 1.16.1 on Return to top of page
Coriolis Core (CRL) Copyright © 2008-2020 Sorbonne Universite, All rights reserved