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

NetListType Class Reference

#include <netlist.h>

Collaboration diagram for NetListType:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 NetListType (ifstream &infile_pl, ifstream &infile_nets, const HardBlockInfoType &blockinfo)
double getHPWL (const OrientedPacking &pk) const

Public Attributes

const vector< NetType > & nets
const vector< PadInfoType > & padinfo

Private Member Functions

void ParsePl (ifstream &infile, const HardBlockInfoType &blockinfo)
void ParseNets (ifstream &infile, const HardBlockInfoType &blockinfo)
void get_index (const string &name, vector< int > &indices) const
int get_index (const string &name, const HardBlockInfoType &blockinfo) const
 NetListType (const NetListType &)

Private Attributes

vector< NetTypein_nets
vector< PadInfoTypein_all_pads

Constructor & Destructor Documentation

NetListType::NetListType ifstream &  infile_pl,
ifstream &  infile_nets,
const HardBlockInfoType blockinfo
[inline]
 

Definition at line 130 of file netlist.h.

References ParseNets(), and ParsePl().

00133    : nets(in_nets),
00134      padinfo(in_all_pads)
00135 {
00136    ParsePl(infile_pl, blockinfo);
00137    ParseNets(infile_nets, blockinfo);
00138 }

Here is the call graph for this function:

NetListType::NetListType const NetListType  )  [private]
 


Member Function Documentation

int NetListType::get_index const string &  name,
const HardBlockInfoType blockinfo
const [inline, private]
 

Definition at line 155 of file netlist.h.

References HardBlockInfoType::block_names, and HardBlockInfoType::blocknum().

00157 {
00158    for (int i = 0; i < blockinfo.blocknum(); i++)
00159       if (name == blockinfo.block_names[i])
00160          return i;
00161    return -1;
00162 }

Here is the call graph for this function:

void NetListType::get_index const string &  name,
vector< int > &  indices
const [inline, private]
 

Definition at line 164 of file netlist.h.

References in_all_pads.

Referenced by ParseNets().

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 }

double NetListType::getHPWL const OrientedPacking pk  )  const [inline]
 

Definition at line 140 of file netlist.h.

References in_nets.

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 }

void NetListType::ParseNets ifstream &  infile,
const HardBlockInfoType blockinfo
[private]
 

Definition at line 136 of file netlist.cxx.

References NetType::PinType::block, get_index(), in_all_pads, in_nets, NetType::PinType::x_offset, NetType::PadType::xloc, NetType::PinType::y_offset, and NetType::PadType::yloc.

Referenced by NetListType().

00138 {
00139    string line;
00140    int numNets = -1;
00141    int numPins = -1;
00142    if(!infile.good())
00143    {
00144       cout << "ERROR: .nets file could not be opened successfully" << endl;
00145       exit(1);
00146    }
00147 
00148    // get NumNets
00149    getline(infile, line);
00150    while(getline(infile, line))
00151    {
00152       char first_word[100];
00153       char ch;
00154                  
00155       if ((sscanf(line.c_str(), "%s %c %d",
00156                   first_word, &ch, &numNets) == 3) &&
00157           !strcmp(first_word, "NumNets"))
00158          break;
00159       
00160    }
00161 
00162    if (!infile.good())
00163    {
00164       cout << "ERROR in reading .net file (# nets)." << endl;
00165       exit(1);
00166    }
00167    
00168    // get NumPins
00169    while(getline(infile, line))
00170    {
00171       char first_word[100];
00172       char ch;
00173 
00174       if ((sscanf(line.c_str(), "%s %c %d",
00175                   first_word, &ch, &numPins) == 3) &&
00176           !strcmp(first_word, "NumPins"))
00177          break;
00178    }   
00179 
00180    if (!infile.good())
00181    {
00182       cout << "ERROR in reading .net file (# pins)." << endl;
00183       exit(1);
00184    }
00185 
00186 
00187    // parse the contents of the nets
00188    int netDegree = -1;               // degree of the current net
00189    int degreeCount = 0;
00190    int pinCount = 0;
00191    vector<NetType::PadType> netPads; // vector of pads for the current net;
00192    vector<NetType::PinType> netPins; // vector of pins for the current net;
00193    for (int lineCount = 0; infile.good(); lineCount++)
00194    {
00195       char dummy_word[1000];
00196       char block_name[1000];
00197       char dummy_chars[100];
00198       int number;
00199       double x_percent, y_percent;
00200 
00201       getline(infile, line);
00202       if (sscanf(line.c_str(), "%s", dummy_word) < 1)
00203       {
00204          // blank line
00205          if (infile.eof())
00206          {
00207             // wrap up the last net.
00208             int degreeCount = netPins.size() + netPads.size();
00209             if (degreeCount == netDegree)
00210             {
00211                NetType temp(netPins, netPads);
00212                in_nets.push_back(temp);
00213 
00214                degreeCount = 0;
00215                netPins.clear();
00216                netPads.clear();
00217             }
00218             else
00219             {
00220                printf("ERROR: netDegree in net %d does not tally\n",
00221                       in_nets.size());
00222                exit(1);
00223             }
00224          }
00225       }
00226       else if ((sscanf(line.c_str(), "%c", dummy_chars+0) == 1) &&
00227                dummy_chars[0] == '#')
00228       {  /* comments (starts with '#') */ }
00229       else if (sscanf(line.c_str(), "%s %c %c %c%lf %c%lf",
00230                       block_name, dummy_chars+0, dummy_chars+1,
00231                       dummy_chars+2, &x_percent,
00232                       dummy_chars+3, &y_percent) == 7)
00233       {
00234          // consider a pin, on the block "block_name".
00235          int index = get_index(string(block_name), blockinfo);
00236          if (index == -1)
00237          {
00238             printf("ERROR: Unrecognized block \"%s\"\n", block_name);
00239             exit(1);
00240          }
00241          else
00242          {
00243             x_percent /= 100;
00244             y_percent /= 100;
00245             
00246             NetType::PinType temp;
00247             temp.block = index;
00248             temp.x_offset = (blockinfo[index].width[0] * x_percent) / 2;
00249             temp.y_offset = (blockinfo[index].height[0] * y_percent) / 2;
00250 //            printf("block %d: x_offset: %.2lf y_offset: %.2lf width: %.2lf height: %2.lf\n",
00251 //                   index, temp.x_offset, temp.y_offset,
00252 //                   blockinfo[index].width[0], blockinfo[index].height[0]);
00253             netPins.push_back(temp);
00254             degreeCount++;
00255             pinCount++;
00256          }
00257       }
00258       else if (sscanf(line.c_str(), "%s %c %d",
00259                       dummy_word, dummy_chars+0, &number) == 3)
00260       {
00261          if (!strcmp(dummy_word, "NetDegree"))
00262          {
00263             // see "NetDegree : x, wrap up previous net
00264             if (netDegree == -1)
00265                netDegree = number;
00266             else if (degreeCount == netDegree)
00267             {
00268                NetType temp(netPins, netPads);
00269                in_nets.push_back(NetType(netPins, netPads));
00270 
00271                netDegree = number;
00272                degreeCount = 0;
00273                netPins.clear();
00274                netPads.clear();
00275             }
00276             else
00277             {
00278                printf("ERROR: netDegree in net %d does not tally (%d vs. %d).\n",
00279                       in_nets.size(), degreeCount, netDegree);
00280                exit(1);
00281             }            
00282          }
00283          else
00284          {
00285             printf("ERROR in parsing .net file (line %d after NumPins).\n",
00286                    lineCount+1);
00287             printf("line: %s\n", line.c_str());
00288             exit(1);
00289          }
00290       }
00291       else if (sscanf(line.c_str(), "%s %c",
00292                       block_name, dummy_chars+0) == 2)
00293       {
00294          // consider a pad, with name "block_name".
00295          vector<int> indices;
00296          get_index(string(block_name), indices);
00297          if (indices.empty())
00298          {
00299             printf("ERROR: unrecognized pad \"%s\"\n", block_name);
00300             exit(1);
00301          }
00302          else
00303          {
00304             for (unsigned int i = 0; i < indices.size(); i++)
00305             {
00306                NetType::PadType temp;
00307                temp.xloc = in_all_pads[indices[i]].xloc;
00308                temp.yloc = in_all_pads[indices[i]].yloc;
00309                netPads.push_back(temp);
00310                pinCount++;
00311             }
00312             degreeCount++;
00313          }               
00314          
00315       }
00316       else
00317       {
00318          printf("ERROR in parsing .net file (line %d after NumPins).\n",
00319                 lineCount+1);
00320          printf("line: %s\n", line.c_str());
00321          exit(1); 
00322       }
00323    }
00324 
00325    if (pinCount != numPins)
00326    {
00327       printf("ERROR: # pins does not tally (%d vs. %d).",
00328              pinCount, numPins);
00329       exit(1);
00330    }
00331    else if (int(in_nets.size()) != numNets)
00332    {
00333       printf("ERROR: # nets does not tally (%d vz. %d).",
00334              in_nets.size(), numNets);
00335       exit(1);
00336    }
00337    infile.close();
00338 }

Here is the call graph for this function:

void NetListType::ParsePl ifstream &  infile,
const HardBlockInfoType blockinfo
[private]
 

Definition at line 102 of file netlist.cxx.

References HardBlockInfoType::blocknum(), in_all_pads, NetListType::PadInfoType::pad_name, NetListType::PadInfoType::xloc, and NetListType::PadInfoType::yloc.

Referenced by NetListType().

00104 {
00105    in_all_pads.clear();
00106    
00107    ofstream outfile;
00108    outfile.open("dummy_pl");
00109    
00110    string line;
00111    int objCount = 0;
00112    for (int lineCount = 0;
00113         getline(infile, line); lineCount++)
00114    {
00115       char name[100];
00116       double xloc, yloc;
00117 
00118       outfile << line << endl;
00119       if (sscanf(line.c_str(), "%s %lf %lf",
00120                  name, &xloc, &yloc) == 3)
00121       {
00122          if (objCount >= blockinfo.blocknum())
00123          {
00124             PadInfoType temp_pad;
00125             temp_pad.pad_name = name;
00126             temp_pad.xloc = xloc;
00127             temp_pad.yloc = yloc;
00128             
00129             in_all_pads.push_back(temp_pad);
00130          }
00131          objCount++;
00132       }
00133    }
00134 }   

Here is the call graph for this function:


Member Data Documentation

vector<PadInfoType> NetListType::in_all_pads [private]
 

Definition at line 112 of file netlist.h.

Referenced by get_index(), ParseNets(), and ParsePl().

vector<NetType> NetListType::in_nets [private]
 

Definition at line 111 of file netlist.h.

Referenced by getHPWL(), and ParseNets().

const vector<NetType>& NetListType::nets
 

Definition at line 98 of file netlist.h.

const vector<PadInfoType>& NetListType::padinfo
 

Definition at line 99 of file netlist.h.


The documentation for this class was generated from the following files:
Generated on Mon Apr 25 01:14:52 2005 for Parquete by doxygen 1.3.2