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

btreefromsstree.cxx

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 #include "btreefromsstree.h"
00036 
00037 #include <fstream>
00038 #include <vector>
00039 using namespace std;
00040 using namespace basepacking_h;
00041 
00042 // --------------------------------------------------------
00043 SoftPackingHardBlockInfoType::SoftPackingHardBlockInfoType(
00044    const SoftPacking& spk)
00045    : HardBlockInfoType()
00046 {
00047    int blocknum = spk.xloc.size();
00048    
00049    in_blocks.resize(blocknum+2);
00050    in_block_names.resize(blocknum+2);
00051    for (int i = 0; i < blocknum; i++)
00052    {
00053       set_dimensions(i, spk.width[i], spk.height[i]);
00054 
00055       char temp[100];
00056       sprintf(temp, "%d", i);
00057       in_block_names[i] = temp;
00058    }
00059 
00060    set_dimensions(blocknum, 0, Dimension::INFTY);
00061    in_block_names[blocknum] = "LEFT";
00062 
00063    set_dimensions(blocknum+1, Dimension::INFTY, 0);
00064    in_block_names[blocknum+1] = "BOTTOM";
00065 }
00066 // --------------------------------------------------------
00067 BTreeFromSoftPacking::BTreeFromSoftPacking(const HardBlockInfoType& nBlockinfo,
00068                                            const SoftPacking& spk)
00069    : BTree(nBlockinfo)
00070 {
00071    EvaluateTree(spk);
00072    evaluate(in_tree);
00073 }
00074 // --------------------------------------------------------
00075 BTreeFromSoftPacking::BTreeFromSoftPacking(const HardBlockInfoType& nBlockinfo,
00076                                            const SoftPacking& spk,
00077                                            double nTolerance)
00078    : BTree(nBlockinfo, nTolerance)
00079 {
00080    EvaluateTree(spk);
00081    evaluate(in_tree);
00082 }
00083 // --------------------------------------------------------
00084 void BTreeFromSoftPacking::EvaluateTree(const SoftPacking& spk)
00085 {
00086    int expr_size = spk.expression.size();
00087    int blocknum = spk.xloc.size();
00088    for (int i = 0; i < expr_size; i++)
00089    {
00090       int sign = spk.expression[i];
00091       if (SoftSTree::isOperand(sign))
00092       {
00093          in_buffer.push_back(SymbolicNodeType(sign, sign, sign, sign,
00094                                               spk.width[sign]));
00095          in_tree[sign].parent = blocknum;
00096          in_tree[sign].left = UNDEFINED;
00097          in_tree[sign].right = UNDEFINED;
00098          in_tree[sign].block_index = sign;
00099          in_tree[sign].orient = 0;
00100       }
00101       else
00102       {
00103          SymbolicNodeType TR_cluster(in_buffer.back());
00104          in_buffer.pop_back();
00105          
00106          SymbolicNodeType BL_cluster(in_buffer.back());
00107          in_buffer.pop_back();
00108 
00109          int new_BL_block = BL_cluster.BL_block;
00110          int new_TL_block = UNDEFINED;
00111          int new_R_block = UNDEFINED;
00112          double new_width = UNDEFINED;
00113          if (sign == SoftSTree::STAR)
00114          {
00115             new_TL_block = BL_cluster.TL_block;
00116             new_R_block = TR_cluster.R_block;
00117             new_width = BL_cluster.width + TR_cluster.width;
00118 
00119             in_tree[TR_cluster.BL_block].parent = BL_cluster.R_block;
00120             in_tree[BL_cluster.R_block].left = TR_cluster.BL_block;
00121          }
00122          else if (sign == SoftSTree::PLUS)
00123          {            
00124             new_TL_block = TR_cluster.TL_block;
00125             new_R_block = (BL_cluster.width > TR_cluster.width)?
00126                BL_cluster.R_block : TR_cluster.R_block;
00127             new_width = max(BL_cluster.width, TR_cluster.width);
00128  
00129             in_tree[TR_cluster.BL_block].parent = BL_cluster.TL_block;
00130             in_tree[BL_cluster.TL_block].right = TR_cluster.BL_block;
00131          }
00132          else
00133          {
00134             cout << "ERROR in BTreeFromSoftPacking::EvaluateTree()" << endl;
00135             exit(1);
00136          }
00137          in_buffer.push_back(SymbolicNodeType(sign,
00138                                               new_BL_block, new_TL_block,
00139                                               new_R_block, new_width));
00140       }
00141    }
00142    in_tree[blocknum].left = spk.expression[0];
00143 }
00144 // --------------------------------------------------------
00145 
00146              
00147             
00148                              
00149 
00150    
00151    
00152      

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