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 #ifndef PLCOMPACT_H
00036 #define PLCOMPACT_H
00037
00038 #include "basepacking.h"
00039
00040 #include <iostream>
00041 #include <vector>
00042 using namespace std;
00043
00044
00045
00046
00047 class ShiftBlock
00048 {
00049 public:
00050 ShiftBlock(const vector<double>& xloc,
00051 const vector<double>& yloc,
00052 const vector<double>& widths,
00053 const vector<double>& heights,
00054 double left_bound,
00055 double right_bound,
00056 double top_bound,
00057 double bottom_bound);
00058
00059 class ShiftInfo
00060 {
00061 public:
00062 double shiftRangeMin;
00063 double shiftRangeMax;
00064 double overlapMin;
00065 double overlapMax;
00066 };
00067 void operator ()(int currBlk,
00068 vector<ShiftInfo>& shiftinfo) const;
00069
00070 enum Directions {NORTH, EAST, SOUTH, WEST, DIR_NUM};
00071 static const double INFTY;
00072 static const double NEG_INFTY;
00073 static const int UNDEFINED;
00074
00075 private:
00076 int _blocknum;
00077 vector<double> _xStart;
00078 vector<double> _xEnd;
00079 vector<double> _yStart;
00080 vector<double> _yEnd;
00081
00082 double _epsilon;
00083 };
00084
00085
00086 class ShiftLegalizer
00087 {
00088 public:
00089 ShiftLegalizer(const vector<double>& n_xloc,
00090 const vector<double>& n_yloc,
00091 const vector<double>& n_widths,
00092 const vector<double>& n_heights,
00093 double left_bound,
00094 double right_bound,
00095 double top_bound,
00096 double bottom_bound);
00097
00098 enum AlgoType {NAIVE};
00099
00100 bool legalizeAll(AlgoType algo,
00101 const vector<int>& checkBlks,
00102 vector<int>& badBlks);
00103
00104 bool naiveLegalize(const vector<int>& checkBlks,
00105 vector<int>& badBlks);
00106 bool legalizeBlock(int currBlk);
00107
00108 void putBlockIntoCore(int currBlk);
00109
00110 inline const vector<double>& xloc() const;
00111 inline const vector<double>& yloc() const;
00112 inline const vector<double>& widths() const;
00113 inline const vector<double>& heights() const;
00114
00115 inline double leftBound() const;
00116 inline double rightBound() const;
00117 inline double topBound() const;
00118 inline double bottomBound() const;
00119
00120 static const double INFTY;
00121 static const int UNDEFINED;
00122
00123 class ShiftRotateDecision
00124 {
00125 public:
00126 inline ShiftRotateDecision();
00127
00128 bool rotate;
00129 int shiftDir;
00130 double shiftExtent;
00131 };
00132 bool shiftDecider(ShiftBlock::Directions currDir,
00133 const vector<ShiftBlock::ShiftInfo>& shiftinfo,
00134 ShiftRotateDecision& decision) const;
00135 bool rotateDecider(int currBlk,
00136 const vector<ShiftBlock::ShiftInfo>& shiftinfo,
00137 ShiftRotateDecision& decision) const;
00138
00139 private:
00140 int _blocknum;
00141 vector<double> _xloc;
00142 vector<double> _yloc;
00143 vector<double> _widths;
00144 vector<double> _heights;
00145 double _epsilon;
00146
00147 const double _leftBound;
00148 const double _rightBound;
00149 const double _topBound;
00150 const double _bottomBound;
00151
00152 void adjustBlock(int currBlk, const ShiftRotateDecision& decision);
00153 };
00154 void OutputShiftInfo(ostream& outs,
00155 const vector<ShiftBlock::ShiftInfo>& shiftinfo);
00156
00157
00158
00159
00160
00161 const vector<double>& ShiftLegalizer::xloc() const
00162 { return _xloc; }
00163
00164 const vector<double>& ShiftLegalizer::yloc() const
00165 { return _yloc; }
00166
00167 const vector<double>& ShiftLegalizer::widths() const
00168 { return _widths; }
00169
00170 const vector<double>& ShiftLegalizer::heights() const
00171 { return _heights; }
00172
00173 double ShiftLegalizer::leftBound() const
00174 { return _leftBound; }
00175
00176 double ShiftLegalizer::rightBound() const
00177 { return _rightBound; }
00178
00179 double ShiftLegalizer::topBound() const
00180 { return _topBound; }
00181
00182 double ShiftLegalizer::bottomBound() const
00183 { return _bottomBound; }
00184
00185 ShiftLegalizer::ShiftRotateDecision::ShiftRotateDecision()
00186 : rotate(false),
00187 shiftDir(UNDEFINED),
00188 shiftExtent(INFTY)
00189 {}
00190
00191
00192 #endif