# Hurricane Documentation

# Hurricane VLSI Database

Instance.h
1 // ****************************************************************************************************
2 // File: ./hurricane/Instance.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_INSTANCE_H
21 #define HURRICANE_INSTANCE_H
22
23 #include "hurricane/Go.h"
24 #include "hurricane/Plug.h"
25 #include "hurricane/SharedPath.h"
26 //#include "hurricane/IntrusiveMap.h"
27
28 namespace Hurricane {
29
30 class Net;
31 class BasicLayer;
32
33 // ****************************************************************************************************
34 // Instance declaration
35 // ****************************************************************************************************
36
37 class Instance : public Go {
38 // ***********************
39
40 // Types
41 // *****
42
43 public: typedef Go Inherit;
44
45 public: class PlacementStatus {
46 // **************************
47
48 public: enum Code {UNPLACED=0, PLACED=1, FIXED=2};
49
50 private: Code _code;
51
52 public: PlacementStatus(const Code& code = UNPLACED);
53 public: PlacementStatus(const PlacementStatus& placementstatus);
54 public: PlacementStatus(string);
55
56 public: PlacementStatus& operator=(const PlacementStatus& placementstatus);
57
58 public: operator const Code&() const {return _code;};
59
60 public: const Code& getCode() const {return _code;};
61
62 public: string _getTypeName() const { return _TName("Instance::PlacementStatus"); };
63 public: string _getString() const;
64 public: Record* _getRecord() const;
65
66 };
67
68 public: class PlugMap : public IntrusiveMap<const Net*, Plug> {
69 // **********************************************************
70
71 public: typedef IntrusiveMap<const Net*, Plug> Inherit;
72
73 public: PlugMap();
74
75 public: virtual const Net* _getKey(Plug* plug) const;
76 public: virtual unsigned _getHashValue(const Net* masterNet) const;
77 public: virtual Plug* _getNextElement(Plug* plug) const;
78 public: virtual void _setNextElement(Plug* plug, Plug* nextPlug) const;
79
80 };
81
82 public: class SharedPathMap : public IntrusiveMap<const SharedPath*, SharedPath> {
83 // *****************************************************************************
84
85 public: typedef IntrusiveMap<const SharedPath*, SharedPath> Inherit;
86
87 public: SharedPathMap();
88
89 public: virtual const SharedPath* _getKey(SharedPath* sharedPath) const;
90 public: virtual unsigned _getHashValue(const SharedPath* tailSharedPath) const;
91 public: virtual SharedPath* _getNextElement(SharedPath* sharedPath) const;
92 public: virtual void _setNextElement(SharedPath* sharedPath, SharedPath* nextSharedPath) const;
93
94 };
95
96 // Attributes
97 // **********
98
99 private: Cell* _cell;
100 private: Name _name;
101 private: Cell* _masterCell;
102 private: Transformation _transformation;
103 private: PlacementStatus _placementStatus;
104 private: PlugMap _plugMap;
105 private: SharedPathMap _sharedPathMap;
106 private: Instance* _nextOfCellInstanceMap;
107 private: Instance* _nextOfCellSlaveInstanceSet;
108
109 // Constructors
110 // ************
111
112 protected: Instance(Cell* cell, const Name& name, Cell* masterCell, const Transformation& transformation, const PlacementStatus& placementstatus, bool secureFlag);
113
114 public: static Instance* create(Cell* cell, const Name& name, Cell* masterCell, bool secureFlag = true);
115 public: static Instance* create(Cell* cell, const Name& name, Cell* masterCell, const Transformation& transformation, const PlacementStatus& placementstatus, bool secureFlag = true);
116
117 // Accessors
118 // *********
119
120 public: virtual Cell* getCell() const {return _cell;};
121 public: virtual Box getBoundingBox() const;
122 public: const Name& getName() const {return _name;};
123 public: Cell* getMasterCell() const {return _masterCell;};
124 public: const Transformation& getTransformation() const {return _transformation;};
125 public: const PlacementStatus& getPlacementStatus() const {return _placementStatus;};
126 public: Plug* getPlug(const Net* masterNet) const {return _plugMap.getElement(masterNet);};
127 public: Plugs getPlugs() const {return _plugMap.getElements();};
128 public: Plugs getConnectedPlugs() const;
129 public: Plugs getUnconnectedPlugs() const;
130 public: Path getPath(const Path& tailPath = Path()) const;
131 public: Box getAbutmentBox() const;
132
133 // Predicates
134 // **********
135
136 public: bool isUnplaced() const {return _placementStatus == PlacementStatus::UNPLACED;};
137 public: bool isPlaced() const {return _placementStatus == PlacementStatus::PLACED;};
138 public: bool isFixed() const {return _placementStatus == PlacementStatus::FIXED;};
139 public: bool isTerminal() const;
140 public: bool isTerminalNetlist() const;
141 public: bool isUnique() const;
142 public: bool isUniquified() const;
143 public: bool isUniquifyMaster() const;
144
145 // Filters
146 // *******
147
148 public: static InstanceFilter getIsUnderFilter(const Box& area);
149 public: static InstanceFilter getIsTerminalFilter();
150 public: static InstanceFilter getIsTerminalNetlistFilter();
151 public: static InstanceFilter getIsUnplacedFilter();
152 public: static InstanceFilter getIsPlacedFilter();
153 public: static InstanceFilter getIsFixedFilter();
154 public: static InstanceFilter getIsNotUnplacedFilter();
155
156 // Updators
157 // ********
158
159 public: virtual void materialize();
160 public: virtual void unmaterialize();
161 public: virtual void invalidate(bool propagateFlag = true);
162 public: virtual void translate(const DbU::Unit& dx, const DbU::Unit& dy);
163
164 public: void setName(const Name& name);
165 public: void setTransformation(const Transformation& transformation);
166 public: void setPlacementStatus(const PlacementStatus& placementstatus);
167 public: void setMasterCell(Cell* masterCell, bool secureFlag = true);
168 public: void uniquify();
169 public: void slaveAbutmentBox();
170 public: Instance* getClone(Cell* cloneCell) const;
171
172 // Others
173 // ******
174
175 protected: virtual void _postCreate();
176
177 protected: virtual void _preDestroy();
178
179 public: virtual string _getTypeName() const {return _TName("Instance");};
180 public: virtual string _getString() const;
181 public: virtual Record* _getRecord() const;
182 public: virtual void _toJson(JsonWriter*) const;
183 public: virtual void _toJsonCollections(JsonWriter*) const;
184 public: PlugMap& _getPlugMap() {return _plugMap;};
185 public: SharedPath* _getSharedPath(const SharedPath* tailSharedPath) const {return _sharedPathMap.getElement(tailSharedPath);}
186 public: SharedPathes _getSharedPathes() const {return _sharedPathMap.getElements();};
187 public: SharedPathMap& _getSharedPathMap() {return _sharedPathMap;};
188 public: Instance* _getNextOfCellInstanceMap() const {return _nextOfCellInstanceMap;};
189 public: Instance* _getNextOfCellSlaveInstanceSet() const {return _nextOfCellSlaveInstanceSet;};
190
191 public: void _setNextOfCellInstanceMap(Instance* instance) {_nextOfCellInstanceMap = instance;};
192 public: void _setNextOfCellSlaveInstanceSet(Instance* instance) {_nextOfCellSlaveInstanceSet = instance;};
193
194 };
195
196
197 class JsonInstance : public JsonEntity {
198 // *************************************
199
200 public: static void initialize();
201 public: JsonInstance(unsigned long flags);
202 public: virtual string getTypeName() const;
203 public: virtual JsonInstance* clone(unsigned long) const;
204 public: virtual void toData(JsonStack&);
205 };
206
207 } // End of Hurricane namespace.
208
209
210 // -------------------------------------------------------------------
211 // Inspector Support for : Instance::PlacementStatus::Code*".
212
213 template<>
214 inline std::string getString<const Hurricane::Instance::PlacementStatus::Code*>
215 ( const Hurricane::Instance::PlacementStatus::Code* object )
216 {
217 switch ( *object ) {
218 case Hurricane::Instance::PlacementStatus::UNPLACED: return "UNPLACED";
219 case Hurricane::Instance::PlacementStatus::PLACED: return "PLACED";
220 case Hurricane::Instance::PlacementStatus::FIXED: return "FIXED";
221 }
222 return "ABNORMAL";
223 }
224
225 template<>
226 inline std::string getString<Hurricane::Instance::PlacementStatus::Code>
227 ( Hurricane::Instance::PlacementStatus::Code object )
228 {
229 switch ( object ) {
230 case Hurricane::Instance::PlacementStatus::UNPLACED: return "UNPLACED";
231 case Hurricane::Instance::PlacementStatus::PLACED: return "PLACED";
232 case Hurricane::Instance::PlacementStatus::FIXED: return "FIXED";
233 }
234 return "ABNORMAL";
235 }
236
237 template<>
238 inline Hurricane::Record* getRecord<const Hurricane::Instance::PlacementStatus::Code*>
239 ( const Hurricane::Instance::PlacementStatus::Code* object )
240 {
241 Hurricane::Record* record = new Hurricane::Record(getString(object));
242 record->add(getSlot("Code", (unsigned int*)object));
243 return record;
244 }
245
246 template<>
247 inline Hurricane::Record* getRecord<const Hurricane::Instance::PlacementStatus::Code>
248 ( const Hurricane::Instance::PlacementStatus::Code object )
249 {
250 Hurricane::Record* record = new Hurricane::Record(getString(object));
251 record->add(getSlot("Code", (unsigned int)object));
252 return record;
253 }
254
255
256 INSPECTOR_P_SUPPORT(Hurricane::Instance);
257 INSPECTOR_P_SUPPORT(Hurricane::Instance::PlacementStatus);
258 INSPECTOR_P_SUPPORT(Hurricane::Instance::PlugMap);
259 INSPECTOR_P_SUPPORT(Hurricane::Instance::SharedPathMap);
260
261 inline void jsonWrite ( JsonWriter* w, const std::string& key, const Hurricane::Instance::PlacementStatus& status )
262 {
263 w->key( key );
264 w->write( getString(status.getCode()) );
265 }
266
267 #endif // HURRICANE_INSTANCE
268
269
270 // ****************************************************************************************************
271 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
272 // ****************************************************************************************************
Hurricane::Path
Path description (API)
Definition: Path.h:37
Hurricane::Go
Go description (API)
Definition: Go.h:36
Hurricane::Instance::PlacementStatus::getCode
const Code & getCode() const
Definition: Instance.h:60
Hurricane::Instance::PlacementStatus::PlacementStatus
PlacementStatus(const Code &code=UNPLACED)
Hurricane::InstanceFilter
GenericFilter< Instance * > InstanceFilter
Definition: Instances.h:51
Hurricane::Instance::getMasterCell
Cell * getMasterCell() const
Definition: Instance.h:123
Hurricane::Instance::getPlugs
Plugs getPlugs() const
Definition: Instance.h:127
Hurricane::Instance::getConnectedPlugs
Plugs getConnectedPlugs() const
Hurricane::Name
Name description (API)
Definition: Name.h:35
Hurricane::Instance::getIsUnderFilter
static InstanceFilter getIsUnderFilter(const Box &area)
Hurricane::Instance::PlacementStatus::Code
Code
Definition: Instance.h:48
Hurricane::DbU::Unit
std::int64_t Unit
Definition: DbU.h:70
Hurricane::Instance::PlacementStatus::FIXED
Definition: Instance.h:48
Hurricane::Cell
The model (API).
Definition: Cell.h:66
Hurricane::Instance::PlacementStatus::UNPLACED
Definition: Instance.h:48
Hurricane::Instance::getClone
Instance * getClone(Cell *cloneCell) const
Hurricane::Instance::getAbutmentBox
Box getAbutmentBox() const
Hurricane::Instance::uniquify
void uniquify()
Hurricane::Instance::setName
void setName(const Name &name)
Hurricane::Transformation
Transformation description (API)
Definition: Transformation.h:32
Hurricane::GenericCollection
Generic Collection auto-pointer.
Definition: Collection.h:28
Hurricane::Instance::getPath
Path getPath(const Path &tailPath=Path()) const
Hurricane::Instance::getName
const Name & getName() const
Definition: Instance.h:122
Hurricane::Box
Box description (API)
Definition: Box.h:31
Hurricane::Instance
Instance description (API)
Definition: Instance.h:37
Hurricane::Instance::Inherit
Go Inherit
Definition: Instance.h:43
Hurricane::Instance::setTransformation
void setTransformation(const Transformation &transformation)
Hurricane::Instance::create
static Instance * create(Cell *cell, const Name &name, Cell *masterCell, bool secureFlag=true)
Hurricane::Instance::PlacementStatus
Instance Placement Status (API)
Definition: Instance.h:45
Hurricane::Instance::setMasterCell
void setMasterCell(Cell *masterCell, bool secureFlag=true)
Hurricane::Plug
Plug description (API)
Definition: Plug.h:37
Hurricane
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5
Hurricane::Instance::getPlug
Plug * getPlug(const Net *masterNet) const
Definition: Instance.h:126
Hurricane::Instance::getTransformation
const Transformation & getTransformation() const
Definition: Instance.h:124
Hurricane::Instance::getUnconnectedPlugs
Plugs getUnconnectedPlugs() const
Hurricane::Instance::PlacementStatus::PLACED
Definition: Instance.h:48
Hurricane::Net
Net description (API)
Definition: Net.h:48