00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef DB_H
00048 #define DB_H
00049
00050 #include <vector>
00051 #include <algorithm>
00052 #include <math.h>
00053 #include <stdlib.h>
00054 #include "Nets.h"
00055 #include "Nodes.h"
00056
00057
00058 namespace parquetfp
00059 {
00060 class DB
00061 {
00062 protected:
00063 Nodes* _nodes;
00064 Nets* _nets;
00065
00066 Nodes* _nodesBestCopy;
00067
00068
00069 mutable double _area;
00070 mutable bool _initArea;
00071
00072 double _rowHeight;
00073 double _siteSpacing;
00074
00075 public:
00076 bool successAR;
00077 DB(char* baseName);
00078 DB(DB * db, vector<int>& subBlocksIndices, Point& dbLoc, double reqdAR);
00079 DB(void);
00080
00081
00082
00083
00084 DB(DB& db2, bool compressDB=false);
00085
00086 ~DB();
00087
00088 DB& operator=(DB& db2);
00089 void clean(void);
00090
00091 unsigned getNumNodes(void) const;
00092 Nodes* getNodes(void);
00093 Nets* getNets(void);
00094
00095 vector<double> getNodeWidths() const;
00096 vector<double> getNodeHeights() const;
00097 vector<double> getXLocs() const;
00098 vector<double> getYLocs() const;
00099
00100
00101 inline double getNodeArea(unsigned index) const;
00102 inline double getNodeWidth(unsigned index) const;
00103 inline double getNodeHeight(unsigned index) const;
00104 inline double getXLoc(unsigned index) const;
00105 inline double getYLoc(unsigned index) const;
00106 inline ORIENT getOrient(unsigned index) const;
00107
00108 inline double getNodeMaxAR(unsigned index) const;
00109 inline double getNodeMinAR(unsigned index) const;
00110 inline double getNodeAR(unsigned index) const;
00111
00112 inline bool isMacro(unsigned index) const;
00113 inline bool isOrientFixed(unsigned index) const;
00114 inline bool isNodeSoft(unsigned index) const;
00115 inline bool isNodeHard(unsigned index) const;
00116
00117
00118 inline void setNodeWidth(unsigned index, double width);
00119 inline void setNodeHeight(unsigned index, double height);
00120 inline void setNodeAR(unsigned index, double ar);
00121
00122 inline void setXLoc(unsigned index, double newX);
00123 inline void setYLoc(unsigned index, double newY);
00124 inline void setOrient(unsigned index,
00125 ORIENT newOrient, bool ignoreNets = false);
00126 inline void setOrient(unsigned index,
00127 const char* newOrient, bool ignoreNets = false);
00128
00129 Point getBottomLeftCorner() const;
00130 Point getTopRightCorner() const;
00131
00132
00133
00134
00135
00136 enum Corner {BOTTOM_LEFT, BOTTOM_RIGHT, TOP_LEFT, TOP_RIGHT, NUM_CORNERS};
00137 inline static string toString(Corner corner);
00138 void packToCorner(vector< vector<double> >& xlocsAt,
00139 vector< vector<double> >& ylocsAt) const;
00140
00141
00142 void cornerOptimizeDesign();
00143
00144
00145 double getNodesArea(void) const;
00146 double getRowHeight(void) const;
00147 double getSiteSpacing(void) const;
00148 void setRowHeight(double rowHeight);
00149 void setSiteSpacing(double siteSpacing);
00150
00151
00152
00153
00154
00155 inline bool updateNodeSlim(int index, const Node& newNode);
00156 inline bool updateNodeLocation(int index,
00157 double xloc, double yloc);
00158 inline bool updateNodeDimensions(int index,
00159 double width, double height);
00160
00161 void updatePlacement(const vector<double>& xloc,
00162 const vector<double>& yloc);
00163 void initPlacement(const Point& loc);
00164 void updateSlacks(const vector<double>& xSlack,
00165 const vector<double>& ySlack);
00166
00167
00168 void plot(char* fileName, double area, double whitespace, double aspectRatio,
00169 double time, double HPWL,
00170 bool plotSlacks, bool plotNets, bool plotNames) const;
00171
00172
00173 void saveCapo(char *baseFileName, double reqdAR=1, double reqdWS=30) const;
00174 void saveCapoNets(char* baseFileName) const;
00175
00176
00177 void save(char* baseFileName) const;
00178 void saveNets(char* baseFileName) const;
00179 void saveWts(char* baseFileName) const;
00180
00181 void saveBestCopyPl(char* baseFileName) const;
00182 void saveInBestCopy(void);
00183
00184 double evalHPWL(bool useWts=true) const;
00185
00186 double evalHPWL(double xSize, double ySize, bool useWts=true) const;
00187 double evalArea(void) const;
00188 double getXSize(void) const;
00189 double getYSize(void) const;
00190 double getAvgHeight(void) const;
00191
00192
00193 void shiftOptimizeDesign(double outlineWidth,
00194 double outlineHeight);
00195 void shiftOptimizeDesign(const Point& bottomLeft,
00196 const Point& topRight);
00197
00198 void shiftDesign(Point& offset);
00199
00200 void expandDesign(double maxWidth, double maxHeight);
00201
00202
00203
00204
00205 void markTallNodesAsMacros(double maxHeight);
00206
00207
00208
00209 void reduceCoreCellsArea(double layoutArea, double maxWS);
00210
00211
00212 double getXSizeWMacroOnly();
00213 double getYSizeWMacroOnly();
00214
00215 double getXMaxWMacroOnly();
00216 double getYMaxWMacroOnly();
00217
00218 private:
00219
00220 double getOptimalRangeStart(bool isHorizontal);
00221 };
00222
00223
00224
00225
00226 double DB::getNodeArea(unsigned index) const
00227 { return getNodeWidth(index) * getNodeHeight(index); }
00228
00229 double DB::getNodeWidth(unsigned index) const
00230 { return _nodes->getNodeWidth(index); }
00231
00232 double DB::getNodeHeight(unsigned index) const
00233 { return _nodes->getNodeHeight(index); }
00234
00235 double DB::getXLoc(unsigned index) const
00236 { return (_nodes->getNode(index)).getX(); }
00237
00238 double DB::getYLoc(unsigned index) const
00239 { return (_nodes->getNode(index)).getY(); }
00240
00241 ORIENT DB::getOrient(unsigned index) const
00242 { return (_nodes->getNode(index)).getOrient(); }
00243
00244 double DB::getNodeMinAR(unsigned index) const
00245 { return (_nodes->getNode(index)).getminAR(); }
00246
00247 double DB::getNodeMaxAR(unsigned index) const
00248 { return (_nodes->getNode(index)).getmaxAR(); }
00249
00250 double DB::getNodeAR(unsigned index) const
00251 { return getNodeWidth(index) / getNodeHeight(index); }
00252
00253 bool DB::isMacro(unsigned index) const
00254 { return (_nodes->getNode(index)).isMacro(); }
00255
00256 bool DB::isOrientFixed(unsigned index) const
00257 { return (_nodes->getNode(index)).isOrientFixed(); }
00258
00259 bool DB::isNodeSoft(unsigned index) const
00260 { return getNodeMaxAR(index) - getNodeMinAR(index) > 1e-6; }
00261
00262 bool DB::isNodeHard(unsigned index) const
00263 { return !isNodeSoft(index); }
00264
00265 void DB::setNodeWidth(unsigned index, double width)
00266 { (_nodes->getNode(index)).putWidth(width); }
00267
00268 void DB::setNodeHeight(unsigned index, double height)
00269 { (_nodes->getNode(index)).putHeight(height); }
00270
00271 void DB::setNodeAR(unsigned index, double ar)
00272 {
00273 const double area = getNodeArea(index);
00274 setNodeWidth(index, sqrt(area * ar));
00275 setNodeHeight(index, sqrt(area / ar));
00276 }
00277
00278 void DB::setXLoc(unsigned index, double newX)
00279 { (_nodes->getNode(index)).putX(newX); }
00280
00281 void DB::setYLoc(unsigned index, double newY)
00282 { (_nodes->getNode(index)).putY(newY); }
00283
00284 void DB::setOrient(unsigned index, ORIENT newOrient, bool ignoreNets)
00285 {
00286 if (ignoreNets)
00287 (_nodes->getNode(index)).putOrient(newOrient);
00288 else
00289 _nodes->changeOrient(index, newOrient, *_nets);
00290 }
00291
00292 void DB::setOrient(unsigned index, const char *newOrient, bool ignoreNets)
00293 {
00294 setOrient(index,
00295 toOrient(const_cast< char* >(newOrient)), ignoreNets);
00296 }
00297
00298 bool DB::updateNodeSlim(int index,
00299 const Node& newNode)
00300 {
00301 if (index < int(_nodes->getNumNodes()))
00302 {
00303 Node& oldNode = _nodes->getNode(index);
00304
00305 oldNode.putX(newNode.getX());
00306 oldNode.putY(newNode.getY());
00307 oldNode.changeOrient(newNode.getOrient(), *_nets);
00308 oldNode.putWidth(newNode.getWidth());
00309 oldNode.putHeight(newNode.getHeight());
00310 return true;
00311 }
00312 else
00313 return false;
00314 }
00315
00316 bool DB::updateNodeLocation(int index,
00317 double xloc, double yloc)
00318 {
00319 if (index < int(_nodes->getNumNodes()))
00320 {
00321 Node& oldNode = _nodes->getNode(index);
00322 oldNode.putX(xloc);
00323 oldNode.putY(yloc);
00324 return true;
00325 }
00326 else
00327 return false;
00328 }
00329
00330 bool DB::updateNodeDimensions(int index,
00331 double width, double height)
00332 {
00333 if (index <int( _nodes->getNumNodes()))
00334 {
00335 Node& oldNode = _nodes->getNode(index);
00336
00337 oldNode.putWidth(width);
00338 oldNode.putHeight(height);
00339 return true;
00340 }
00341 else
00342 return false;
00343 }
00344
00345 string DB::toString(DB::Corner corner)
00346 {
00347 switch (corner)
00348 {
00349 case BOTTOM_LEFT: return "bottom-left";
00350 case BOTTOM_RIGHT: return "bottom-right";
00351 case TOP_LEFT: return "top-left";
00352 case TOP_RIGHT: return "top-right";
00353 default: return "INVALID CORNER";
00354 }
00355 }
00356
00357 }
00358
00359
00360 #endif