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


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