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