Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members

plcompact.h

Go to the documentation of this file.
00001 /**************************************************************************
00002 ***    
00003 *** Copyright (c) 1995-2000 Regents of the University of California,
00004 ***               Andrew E. Caldwell, Andrew B. Kahng and Igor L. Markov
00005 *** Copyright (c) 2000-2004 Regents of the University of Michigan,
00006 ***               Saurabh N. Adya, Jarrod A. Roy and Igor L. Markov
00007 ***
00008 ***  Contact author(s): abk@cs.ucsd.edu, imarkov@umich.edu
00009 ***  Original Affiliation:   UCLA, Computer Science Department,
00010 ***                          Los Angeles, CA 90095-1596 USA
00011 ***
00012 ***  Permission is hereby granted, free of charge, to any person obtaining 
00013 ***  a copy of this software and associated documentation files (the
00014 ***  "Software"), to deal in the Software without restriction, including
00015 ***  without limitation 
00016 ***  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
00017 ***  and/or sell copies of the Software, and to permit persons to whom the 
00018 ***  Software is furnished to do so, subject to the following conditions:
00019 ***
00020 ***  The above copyright notice and this permission notice shall be included
00021 ***  in all copies or substantial portions of the Software.
00022 ***
00023 *** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
00024 *** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00025 *** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
00026 *** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00027 *** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
00028 *** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00029 *** THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 // back-end database to determine how much a block can/has to move
00046 // *** NOT INTENDED TO BE USED DIRECTLY, USE ShiftLegalizer INSTEAD ***
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; // 4-elt vector
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 // front-end legalizer to be used
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); // "t" ~ badBlks.empty() 
00106    bool legalizeBlock(int currBlk); // "t" ~ "currBlk" not overlap
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 // IMPLEMENTATIONS
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

Generated on Mon Apr 25 01:09:25 2005 for Parquete by doxygen 1.3.2