Hurricane VLSI Database


Net.h
1 // ****************************************************************************************************
2 // File: ./hurricane/Net.h
3 // Authors: R. Escassut
4 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
5 //
6 // This file is part of Hurricane.
7 //
8 // Hurricane is free software: you can redistribute it and/or modify it under the terms of the GNU
9 // Lesser General Public License as 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 WITHOUT ANY WARRANTY; without even
13 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy of the Lesser GNU General Public License along with Hurricane. If
17 // not, see <http://www.gnu.org/licenses/>.
18 // ****************************************************************************************************
19 
20 #ifndef HURRICANE_NET
21 #define HURRICANE_NET
22 
23 #include <functional>
24 #include "hurricane/Entity.h"
25 #include "hurricane/Nets.h"
26 #include "hurricane/Component.h"
27 #include "hurricane/Rubbers.h"
28 #include "hurricane/Rubber.h"
29 #include "hurricane/RoutingPads.h"
30 #include "hurricane/Plugs.h"
31 #include "hurricane/Pins.h"
32 #include "hurricane/Contacts.h"
33 #include "hurricane/Segments.h"
34 #include "hurricane/Verticals.h"
35 #include "hurricane/Horizontals.h"
36 #include "hurricane/Pads.h"
37 #include "hurricane/IntrusiveSet.h"
38 #include "hurricane/Path.h"
39 #include "hurricane/NetAlias.h"
40 
41 namespace Hurricane {
42 
43 
44 // ****************************************************************************************************
45 // Net declaration
46 // ****************************************************************************************************
47 
48 class Net : public Entity {
49 // **********************
50 
51 // Types
52 // *****
53 
54  public: typedef Entity Inherit;
55 
56  public: typedef unsigned Arity;
57 
58  public: class Type {
59  // ***************
60 
61  public: enum Code {UNDEFINED=0, LOGICAL=1, CLOCK=2, POWER=3, GROUND=4, BLOCKAGE=5, FUSED=6};
62 
63  private: Code _code;
64 
65  public: Type(const Code& code = UNDEFINED);
66  public: Type(const Type& type);
67  public: Type(string);
68 
69  public: Type& operator=(const Type& type);
70 
71  public: operator const Code&() const {return _code;};
72 
73  public: const Code& getCode() const {return _code;};
74 
75  public: string _getTypeName() const { return _TName("Net::type"); };
76  public: string _getString() const;
77  public: Record* _getRecord() const;
78 
79  };
80 
81  public: class Direction {
82  // ********************
83 
84  public: enum Code { DirIn = 0x0001
85  , DirOut = 0x0002
86  , DirUndefined = 0x0000
87  , ConnTristate = 0x0100
88  , ConnWiredOr = 0x0200
90  , IN = DirIn
91  , OUT = DirOut
97  , DirMask = DirIn | DirOut | DirUndefined
98  };
99 
100  private: Code _code;
101 
102  public: Direction(const Code& code = UNDEFINED);
103  public: Direction(const Direction& direction);
104  public: Direction(string);
105 
106  public: Direction& operator =(const Direction& direction);
107  public: Direction& operator|=(const Direction& direction);
108 
109  public: operator const Code&() const {return _code;};
110 
111  public: const Code& getCode() const {return _code;};
112 
113  public: string _getTypeName() const { return _TName("Net::Direction"); };
114  public: string _getString() const;
115  public: Record* _getRecord() const;
116 
117  };
118 
119  class ComponentSet : public IntrusiveSet<Component> {
120  // ************************************************
121 
122  public: typedef IntrusiveSet<Component> Inherit;
123 
124  public: ComponentSet();
125 
126  public: virtual unsigned _getHashValue(Component* component) const;
127  public: virtual Component* _getNextElement(Component* component) const;
128  public: virtual void _setNextElement(Component* component, Component* nextComponent) const;
129 
130  };
131 
132  class RubberSet : public IntrusiveSet<Rubber> {
133  // ******************************************
134 
135  public: typedef IntrusiveSet<Rubber> Inherit;
136 
137  public: RubberSet();
138 
139  public: virtual unsigned _getHashValue(Rubber* rubber) const;
140  public: virtual Rubber* _getNextElement(Rubber* rubber) const;
141  public: virtual void _setNextElement(Rubber* rubber, Rubber* nextRubber) const;
142 
143  };
144 
145 // Attributes
146 // **********
147 
148  private: Cell* _cell;
149  private: Name _name;
150  private: Arity _arity;
151  private: bool _isGlobal;
152  private: bool _isExternal;
153  private: bool _isAutomatic;
154  private: Type _type;
155  private: Direction _direction;
156  private: Point _position;
157  private: ComponentSet _componentSet;
158  private: RubberSet _rubberSet;
159  private: Net* _nextOfCellNetMap;
160  private: NetMainName _mainName;
161 
162 // Constructors
163 // ************
164 
165  protected: Net(Cell* cell, const Name& name);
166 
167  public: static Net* create(Cell* cell, const Name& name);
168 
169 // Accessors
170 // *********
171 
172  public: virtual Cell* getCell() const {return _cell;};
173  public: virtual Box getBoundingBox() const;
174  public: const Name& getName() const {return _name;};
175  public: const NetMainName* getMainName() const { return &_mainName; }
176  public: const Arity& getArity() const {return _arity;};
177  public: const Type& getType() const {return _type;};
178  public: const Direction& getDirection() const {return _direction;};
179  public: const Point& getPosition() const {return _position;};
180  public: const DbU::Unit& getX() const {return _position.getX();};
181  public: const DbU::Unit& getY() const {return _position.getY();};
182  public: Components getComponents() const {return _componentSet.getElements();};
183  public: Rubbers getRubbers() const {return _rubberSet.getElements();};
184  public: RoutingPads getRoutingPads() const;
185  public: Plugs getPlugs() const;
186  public: Pins getPins() const;
187  public: Contacts getContacts() const;
188  public: Segments getSegments() const;
189  public: Verticals getVerticals() const;
190  public: Horizontals getHorizontals() const;
191  public: Pads getPads() const;
192  public: Plugs getSlavePlugs() const;
193  public: Plugs getConnectedSlavePlugs() const;
195  public: Aliases getAliases() const { return new AliasList(this); };
196 
197 // Filters
198 // *******
199 
200  public: static NetFilter getIsCellNetFilter();
201  public: static NetFilter getIsDeepNetFilter();
202  public: static NetFilter getIsGlobalFilter();
203  public: static NetFilter getIsExternalFilter();
204  public: static NetFilter getIsInternalFilter();
205  public: static NetFilter getIsClockFilter();
206  public: static NetFilter getIsSupplyFilter();
207  public: static NetFilter getIsPowerFilter();
208  public: static NetFilter getIsGroundFilter();
209 
210 // Predicates
211 // **********
212 
213  public: virtual bool isDeepNet () const {return false;};
214  public: bool isGlobal () const {return _isGlobal;};
215  public: bool isExternal () const {return _isExternal;};
216  public: bool isAutomatic() const {return _isAutomatic;};
217  public: bool isBlockage () const {return (_type == Type::BLOCKAGE);};
218  public: bool isFused () const {return (_type == Type::FUSED);};
219  public: bool isLogical () const {return (_type == Type::LOGICAL);};
220  public: bool isClock () const {return (_type == Type::CLOCK);};
221  public: bool isPower () const {return (_type == Type::POWER);};
222  public: bool isGround () const {return (_type == Type::GROUND);};
223  public: bool isSupply () const {return (isPower() || isGround());};
224  public: bool hasAlias (const Name& ) const;
225  public: NetAliasHook* getAlias (const Name& ) const;
226 
227 // Updators
228 // ********
229 
230  public: void setName(Name name);
231  public: void setArity(const Arity& arity);
232  public: void setGlobal(bool isGlobal);
233  public: void setExternal(bool isExternal);
234  public: void setAutomatic(bool isAutomatic);
235  public: void setType(const Type& type);
236  public: void setDirection(const Direction& direction);
237  public: void setPosition(const Point& position);
238  public: void setRoutingState(uint32_t state);
239  public: void materialize();
240  public: void unmaterialize();
241  public: bool addAlias(const Name& name, bool isExternal=false);
242  public: bool removeAlias(const Name& name);
243  public: void merge(Net* net);
244  public: Net* getClone(Cell* cloneCell);
245 
246 // Others
247 // ******
248 
249  protected: virtual void _postCreate();
250  protected: virtual void _preDestroy();
251 
252  public: virtual void _toJson(JsonWriter*) const;
253  public: virtual void _toJsonSignature(JsonWriter*) const;
254  public: virtual void _toJsonCollections(JsonWriter*) const;
255  public: virtual string _getTypeName() const {return _TName("Net");};
256  public: virtual string _getString() const;
257  public: virtual Record* _getRecord() const;
258  public: NetMainName& _getMainName() { return _mainName; }
259  public: ComponentSet& _getComponentSet() {return _componentSet;};
260  public: RubberSet& _getRubberSet() {return _rubberSet;};
261  public: Net* _getNextOfCellNetMap() const {return _nextOfCellNetMap;};
262 
263  public: void _setNextOfCellNetMap(Net* net) {_nextOfCellNetMap = net;};
264 
265  public: struct CompareByName {
266  inline bool operator() ( const Net* lhs, const Net* rhs ) const { return lhs->getName() < rhs->getName(); }
267  };
268 
269 };
270 
271 
272 // -------------------------------------------------------------------
273 // Class : "HookKey".
274 
275  class HookKey {
276  public:
277  inline HookKey ( unsigned int id, const std::string& tname );
278  inline unsigned int id () const;
279  inline std::string tname () const;
280  private:
281  unsigned int _id;
282  std::string _tname;
283  };
284 
285 
286  inline HookKey::HookKey ( unsigned int id, const std::string& tname ) : _id(id), _tname(tname) { }
287  inline unsigned int HookKey::id () const { return _id; }
288  inline std::string HookKey::tname () const { return _tname; }
289 
290  inline bool operator< ( const HookKey& lhs, const HookKey& rhs )
291  {
292  if (lhs.id() != rhs.id()) return lhs.id() < rhs.id();
293  return lhs.tname() < rhs.tname();
294  }
295 
296 
297 // -------------------------------------------------------------------
298 // Class : "HookElement".
299 
300  class HookElement {
301  public:
302  enum Flags { OpenRingStart = (1<<0)
303  , ClosedRing = (1<<1)
304  };
305  public:
306  inline HookElement ( Hook*, unsigned long flags=0 );
307  inline Hook* hook () const;
308  inline HookElement* next () const;
309  inline void setHook ( Hook* );
310  inline void setNext ( HookElement* );
311  inline unsigned long flags () const;
312  inline HookElement& setFlags ( unsigned long mask );
313  inline HookElement& resetFlags ( unsigned long mask );
314  inline bool issetFlags ( unsigned long mask ) const;
315  private:
316  Hook* _hook;
317  HookElement* _next;
318  unsigned long _flags;
319  };
320 
321 
322  inline HookElement::HookElement ( Hook* hook, unsigned long flags ) : _hook(hook), _next(NULL), _flags(flags) { }
323  inline Hook* HookElement::hook () const { return _hook; }
324  inline HookElement* HookElement::next () const { return _next; }
325  inline void HookElement::setHook ( Hook* hook ) { _hook = hook; }
326  inline void HookElement::setNext ( HookElement* element ) { _next = element; }
327  inline unsigned long HookElement::flags () const { return _flags; }
328  inline HookElement& HookElement::setFlags ( unsigned long mask ) { _flags |= mask; return *this; }
329  inline HookElement& HookElement::resetFlags ( unsigned long mask ) { _flags &= ~mask; return *this; }
330  inline bool HookElement::issetFlags ( unsigned long mask ) const { return _flags & mask; }
331 
332 
333  typedef map<HookKey,HookElement> HookLut;
334 
335 
336 // -------------------------------------------------------------------
337 // Class : "JsonNet".
338 
339  class JsonNet : public JsonEntity {
340  public:
341  static bool hookFromString ( std::string s, unsigned int& id, std::string& tname );
342  static void initialize ();
343  JsonNet ( unsigned long flags );
344  virtual ~JsonNet ();
345  virtual string getTypeName () const;
346  virtual JsonNet* clone ( unsigned long ) const;
347  virtual void toData ( JsonStack& );
348  void addHookLink ( Hook*, unsigned int jsonId, const std::string& jsonNext );
349  Hook* getHook ( unsigned int jsonId, const std::string& tname ) const;
350  bool checkRings () const;
351  void buildRings () const;
352  inline void clearHookLinks ();
353  protected:
354  bool _autoMaterialize;
355  Net* _net;
356  HookLut _hooks;
357  };
358 
359 
360  inline void JsonNet::clearHookLinks () { _hooks.clear(); }
361 
362 
363 } // Hurricane namespace.
364 
365 
366 // -------------------------------------------------------------------
367 // Inspector Support for : Net::Type::Code*".
368 
369 template<>
370 inline std::string getString<const Hurricane::Net::Type::Code*>
371  ( const Hurricane::Net::Type::Code* object )
372  {
373  switch ( *object ) {
374  case Hurricane::Net::Type::UNDEFINED: return "UNDEFINED";
375  case Hurricane::Net::Type::LOGICAL: return "LOGICAL";
376  case Hurricane::Net::Type::CLOCK: return "CLOCK";
377  case Hurricane::Net::Type::POWER: return "POWER";
378  case Hurricane::Net::Type::GROUND: return "GROUND";
379  case Hurricane::Net::Type::BLOCKAGE: return "BLOCKAGE";
380  case Hurricane::Net::Type::FUSED: return "FUSED";
381  }
382  return "ABNORMAL";
383  }
384 
385 template<>
386 inline Hurricane::Record* getRecord<const Hurricane::Net::Type::Code*>
387  ( const Hurricane::Net::Type::Code* object )
388  {
389  Hurricane::Record* record = new Hurricane::Record(getString(object));
390  record->add(getSlot("Code", (unsigned int*)object));
391  return record;
392  }
393 
394 
395 // -------------------------------------------------------------------
396 // Inspector Support for : "const Net::Direction::Code*".
397 
398 template<>
399 inline std::string getString<const Hurricane::Net::Direction::Code*>
400  ( const Hurricane::Net::Direction::Code* object )
401  {
402  std::ostringstream s;
403  s << (((*object) & Hurricane::Net::Direction::DirIn ) ? 'i' : '-');
404  s << (((*object) & Hurricane::Net::Direction::DirOut ) ? 'o' : '-');
405  s << (((*object) & Hurricane::Net::Direction::ConnTristate) ? 't' : '-');
406  s << (((*object) & Hurricane::Net::Direction::ConnWiredOr ) ? 'w' : '-');
407 
408  switch ( (int)*object ) {
409  case Hurricane::Net::Direction::UNDEFINED: s << " (UNDEFINED)"; break;
410  case Hurricane::Net::Direction::IN: s << " (IN)"; break;
411  case Hurricane::Net::Direction::OUT: s << " (OUT)"; break;
412  case Hurricane::Net::Direction::INOUT: s << " (INOUT)"; break;
413  case Hurricane::Net::Direction::TRISTATE: s << " (TRISTATE)"; break;
414  case Hurricane::Net::Direction::TRANSCV: s << " (TRANSCV)"; break;
415  case Hurricane::Net::Direction::WOR_OUT: s << " (WOR_OUT)"; break;
416  case Hurricane::Net::Direction::WOR_INOUT: s << " (WOR_INOUT)"; break;
417  }
418  return s.str();
419  }
420 
421 template<>
422 inline Hurricane::Record* getRecord<const Hurricane::Net::Direction::Code*>
423  ( const Hurricane::Net::Direction::Code* object )
424  {
425  Hurricane::Record* record = new Hurricane::Record(getString(object));
426  record->add(getSlot("Code", (unsigned int*)object));
427  return record;
428  }
429 
430 
431 INSPECTOR_P_SUPPORT(Hurricane::Net);
432 INSPECTOR_P_SUPPORT(Hurricane::Net::ComponentSet);
433 INSPECTOR_P_SUPPORT(Hurricane::Net::RubberSet);
434 INSPECTOR_PR_SUPPORT(Hurricane::Net::Type);
435 INSPECTOR_PR_SUPPORT(Hurricane::Net::Direction);
436 IOSTREAM_POINTER_SUPPORT(Hurricane::Net::Type::Code);
437 IOSTREAM_VALUE_SUPPORT(Hurricane::Net::Type::Code);
438 IOSTREAM_POINTER_SUPPORT(Hurricane::Net::Direction::Code);
439 IOSTREAM_VALUE_SUPPORT(Hurricane::Net::Direction::Code);
440 
441 
442 namespace Hurricane {
443 
444 // Force SlotTemplate<> expansion on Net* type.
445 // Because sometimes it didn't happens (?).
446  const SlotTemplate<Net*> dummyNetSlot ( string("dummyNetSlot"), NULL );
447 
448 }
449 
450 #endif // HURRICANE_NET
451 
452 
453 // ****************************************************************************************************
454 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
455 // ****************************************************************************************************
Box description (API)
Definition: Box.h:31
The model (API).
Definition: Cell.h:64
std::int64_t Unit
Definition: DbU.h:67
Occurrenceable objects root class (API).
Definition: Entity.h:37
Generic Collection auto-pointer.
Definition: Collection.h:235
Generic Filter auto-pointer.
Definition: Filter.h:86
Name description (API)
Definition: Name.h:35
Definition: Net.h:81
Code
Definition: Net.h:84
@ ConnWiredOr
Definition: Net.h:88
@ DirOut
Definition: Net.h:85
@ WOR_OUT
Definition: Net.h:95
@ OUT
Definition: Net.h:91
@ WOR_INOUT
Definition: Net.h:96
@ DirUndefined
Definition: Net.h:86
@ DirIn
Definition: Net.h:84
@ TRISTATE
Definition: Net.h:93
@ INOUT
Definition: Net.h:92
@ IN
Definition: Net.h:90
@ TRANSCV
Definition: Net.h:94
@ UNDEFINED
Definition: Net.h:89
@ ConnTristate
Definition: Net.h:87
Definition: Net.h:58
Code
Definition: Net.h:61
@ POWER
Definition: Net.h:61
@ GROUND
Definition: Net.h:61
@ LOGICAL
Definition: Net.h:61
@ CLOCK
Definition: Net.h:61
@ UNDEFINED
Definition: Net.h:61
Net description (API)
Definition: Net.h:48
Plugs getConnectedSlavePlugs() const
void setPosition(const Point &position)
const Type & getType() const
Definition: Net.h:177
RoutingPads getRoutingPads() const
static NetFilter getIsGlobalFilter()
void setName(Name name)
Components getComponents() const
Definition: Net.h:182
const DbU::Unit & getX() const
Definition: Net.h:180
bool isGlobal() const
Definition: Net.h:214
void setGlobal(bool isGlobal)
unsigned Arity
Definition: Net.h:56
static NetFilter getIsExternalFilter()
Entity Inherit
Definition: Net.h:54
void merge(Net *net)
Net * getClone(Cell *cloneCell)
Pads getPads() const
void setExternal(bool isExternal)
Rubbers getRubbers() const
Definition: Net.h:183
const Arity & getArity() const
Definition: Net.h:176
static NetFilter getIsInternalFilter()
void setType(const Type &type)
bool isClock() const
Definition: Net.h:220
Plugs getPlugs() const
Verticals getVerticals() const
Contacts getContacts() const
Plugs getSlavePlugs() const
bool isLogical() const
Definition: Net.h:219
void unmaterialize()
const Direction & getDirection() const
Definition: Net.h:178
const DbU::Unit & getY() const
Definition: Net.h:181
Plugs getUnconnectedSlavePlugs() const
Segments getSegments() const
bool isSupply() const
Definition: Net.h:223
const Point & getPosition() const
Definition: Net.h:179
static Net * create(Cell *cell, const Name &name)
static NetFilter getIsSupplyFilter()
void setDirection(const Direction &direction)
Horizontals getHorizontals() const
void materialize()
const Name & getName() const
Definition: Net.h:174
bool isExternal() const
Definition: Net.h:215
void setArity(const Arity &arity)
static NetFilter getIsClockFilter()
Point description (API)
Definition: Point.h:32
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5


Generated by doxygen 1.9.1 on Thu Aug 11 2022 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved