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

netlist.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 NETLIST_H
00036 #define NETLIST_H
00037 
00038 #include "basepacking.h"
00039 
00040 #include <iostream>
00041 #include <vector>
00042 using namespace std;
00043 
00044 // --------------------------------------------------------
00045 class NetType
00046 {
00047 public:
00048    class PinType;
00049    class PadType;
00050    NetType(const vector<PinType>& newPins,
00051            const vector<PadType>& newPads)
00052       : pins(in_pins),
00053         pads(in_pads),
00054         in_pins(newPins),
00055         in_pads(newPads) {}
00056 
00057    inline NetType(const NetType& newNet);
00058    inline void operator =(const NetType& newNet);
00059 
00060    const vector<PinType>& pins;
00061    const vector<PadType>& pads;
00062 
00063    double getHPWL(const OrientedPacking& pk) const;
00064 
00065    class PinType
00066    {
00067    public:
00068       int block;       // index of blocks
00069       double x_offset; // offset from center
00070       double y_offset; // offset from center
00071    };
00072 
00073    class PadType
00074    {
00075    public:
00076       double xloc;
00077       double yloc;
00078    };
00079 
00080 private:
00081    vector<PinType> in_pins;
00082    vector<PadType> in_pads;
00083 
00084    inline void getOffsets(double orig_x_offset,
00085                           double orig_y_offset,
00086                           OrientedPacking::ORIENT orient,
00087                           double& x_offset,
00088                           double& y_offset) const;
00089 };
00090 // --------------------------------------------------------
00091 class NetListType
00092 {
00093 public:
00094    inline NetListType(ifstream& infile_pl, ifstream& infile_nets,
00095                       const HardBlockInfoType& blockinfo);
00096 
00097    class PadInfoType;
00098    const vector<NetType>& nets;
00099    const vector<PadInfoType>& padinfo;
00100    inline double getHPWL(const OrientedPacking& pk) const;
00101 
00102    class PadInfoType
00103    {
00104    public:
00105       string pad_name;
00106       double xloc;
00107       double yloc;
00108    };
00109 
00110 private:
00111    vector<NetType> in_nets;
00112    vector<PadInfoType> in_all_pads;
00113 
00114    void ParsePl(ifstream& infile,
00115                 const HardBlockInfoType& blockinfo);
00116    void ParseNets(ifstream& infile,
00117                   const HardBlockInfoType& blockinfo);
00118    inline void get_index(const string& name,
00119                          vector<int>& indices) const;
00120    inline int get_index(const string& name,
00121                         const HardBlockInfoType& blockinfo) const;
00122 
00123    NetListType(const NetListType&);
00124 };
00125 // --------------------------------------------------------
00126 
00127 // ==============
00128 // IMPLEMENTATION
00129 // ==============
00130 inline NetListType::NetListType(ifstream& infile_pl,
00131                                 ifstream& infile_nets,
00132                                 const HardBlockInfoType& blockinfo)
00133    : nets(in_nets),
00134      padinfo(in_all_pads)
00135 {
00136    ParsePl(infile_pl, blockinfo);
00137    ParseNets(infile_nets, blockinfo);
00138 }
00139 // --------------------------------------------------------
00140 inline double NetListType::getHPWL(const OrientedPacking& pk) const
00141 {
00142    int num_nets = in_nets.size();
00143    double HPWL = 0;
00144    for (int i = 0; i < num_nets; i++)
00145    {
00146 //      printf("---Net [%d]---\n", i);
00147       HPWL += in_nets[i].getHPWL(pk);
00148 //      cout.setf(ios::fixed);
00149 //      cout.precision(2);
00150 //      cout << HPWL << endl << endl;
00151    }
00152    return HPWL;
00153 }
00154 // --------------------------------------------------------
00155 inline int NetListType::get_index(const string& name,
00156                                   const HardBlockInfoType& blockinfo) const
00157 {
00158    for (int i = 0; i < blockinfo.blocknum(); i++)
00159       if (name == blockinfo.block_names[i])
00160          return i;
00161    return -1;
00162 }
00163 // --------------------------------------------------------
00164 inline void NetListType::get_index(const string& name,
00165                                    vector<int>& indices) const
00166 {
00167    indices.clear();
00168    for (unsigned int i = 0; i < in_all_pads.size(); i++)
00169    {
00170       const string& this_pad_name = in_all_pads[i].pad_name;
00171       int pos = this_pad_name.find(name, 0);     
00172       if (pos == 0)
00173       {
00174          if (this_pad_name.length() == name.length())
00175             indices.push_back(i);
00176          else if (this_pad_name[name.length()] == '@')
00177             indices.push_back(i);
00178       }
00179    }
00180 }
00181 // --------------------------------------------------------
00182 inline NetType::NetType(const NetType& newNet)
00183    : pins(in_pins),
00184      pads(in_pads)
00185 {
00186    in_pins = newNet.in_pins;
00187    in_pads = newNet.in_pads;
00188 }
00189 // --------------------------------------------------------
00190 inline void NetType::operator =(const NetType& newNet)
00191 {
00192    in_pins = newNet.in_pins;
00193    in_pads = newNet.in_pads;
00194 }
00195 // --------------------------------------------------------
00196 inline void NetType::getOffsets(double orig_x_offset,
00197                                 double orig_y_offset,
00198                                 OrientedPacking::ORIENT blk_orient,
00199                                 double& x_offset,
00200                                 double& y_offset) const
00201 {
00202    switch (blk_orient)
00203    {
00204    case OrientedPacking::N:
00205       x_offset = orig_x_offset;
00206       y_offset = orig_y_offset;
00207       break;
00208       
00209    case OrientedPacking::E:
00210       x_offset = orig_y_offset;
00211       y_offset = -1 * orig_x_offset;
00212       break;
00213       
00214    case OrientedPacking::S:
00215       x_offset = -1 * orig_x_offset;
00216       y_offset = -1 * orig_y_offset;
00217       break;
00218       
00219    case OrientedPacking::W:
00220       x_offset = -1 * orig_y_offset;
00221       y_offset = orig_x_offset;
00222       break;
00223 
00224    case OrientedPacking::FN:
00225       x_offset = -1 * orig_x_offset;
00226       y_offset = orig_y_offset;
00227       break;
00228 
00229    case OrientedPacking::FE:
00230       x_offset = orig_y_offset;
00231       y_offset = orig_x_offset;
00232       break;
00233 
00234    case OrientedPacking::FS:
00235       x_offset = orig_x_offset;
00236       y_offset = -1 * orig_y_offset;
00237       break;
00238 
00239    case OrientedPacking::FW:
00240       x_offset = -1 * orig_y_offset;
00241       y_offset = -1 * orig_x_offset;
00242       break;
00243 
00244    case OrientedPacking::UNDEFINED:
00245       cout << "ERROR: the orientation for this block is undefined."
00246            << endl;
00247       exit(1);
00248       break;
00249                             
00250    default:
00251       cout << "ERROR in specified orientation." << endl;
00252       exit(1);
00253       break;
00254    }
00255 }
00256 // --------------------------------------------------------
00257 #endif

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