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


Generated by doxygen 1.9.7 on Fri Sep 27 2024 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved