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

VoltageIsland.cxx

Go to the documentation of this file.
00001 #include "Annealer.h"
00002  
00003 #include <fstream>
00004 #include <vector>
00005 #include <algorithm>
00006 #include <cmath>
00007 #include <cstdlib>
00008 
00009 using namespace parquetfp;
00010 
00011 
00012 IslandNodes::IslandNodes()
00013 {
00014 }
00015 
00016 IslandNodes::IslandNodes(int node0, int node1, int group, int vdd)
00017 {
00018   nodes.push_back(node0);
00019   nodes.push_back(node1);
00020   groupID = group;
00021   voltage = vdd;
00022 }
00023 /*
00024 IslandNodes::~IslandNodes()
00025 {
00026 
00027            cout << "destruct IslandNodes " << endl;
00028 //         delete &voltage;
00029 //         delete &groupID;
00030 //         delete [] &nodes;
00031 }
00032 */
00033 void IslandNodes::setGroupID(int group)
00034 {
00035         groupID = group;
00036 }
00037 
00038 SetOfVoltages::SetOfVoltages()
00039 {
00040         numCurrentGroups = 0;
00041 }
00042 
00043 SetOfVoltages::~SetOfVoltages()
00044 {
00045 /*
00046           int i;
00047           delete &numCurrentGroups;                 //set to 0 on start and displays number of distinct voltage islands
00048 
00049           for(i=0;i<islandNodes.size();i++){
00050              delete &islandNodes[i];
00051           }
00052 
00053           cout << "destruct setofvoltages" << endl;
00054 
00055 //        delete [] &islandNodes;
00056 */
00057 }
00058 
00059 
00060 void SetOfVoltages::addIslandNodes(int vdd, int node0, int node1)
00061 {
00062   for(int i = 0; i < islandNodes.size();  i++) {
00063           if(islandNodes[i].voltage == vdd){
00064                  if((islandNodes[i].nodes[0] == node0) && (islandNodes[i].nodes[1] == node1))
00065                         return;
00066                  else if((islandNodes[i].nodes[1] == node0) && (islandNodes[i].nodes[0] == node1))
00067                         return;
00068           }
00069   }
00070   islandNodes.push_back(IslandNodes(node0,node1,numCurrentGroups,vdd));
00071   numCurrentGroups++;
00072 }
00073   
00074 void SetOfVoltages::createVoltageIslands()
00075 {
00076         int i,j, currentID, currentVoltage, currentNode0, currentNode1;
00077         for(i = 0; i<islandNodes.size();i++){
00078                         currentID = islandNodes[i].groupID;
00079                         currentVoltage = islandNodes[i].voltage;
00080                         currentNode0 = islandNodes[i].nodes[0];
00081                         currentNode1 = islandNodes[i].nodes[1];
00082                         for(j=0;j<islandNodes.size();j++){
00083                                 if( (islandNodes[j].voltage == currentVoltage) && (islandNodes[j].groupID != currentID) ){
00084                                         if( (islandNodes[j].nodes[0] == currentNode0) || (islandNodes[j].nodes[1] == currentNode0) ){
00085                                                 islandNodes[j].setGroupID(currentID);
00086                                                 if((islandNodes[j].nodes[0] == currentNode0) && (islandNodes[j].nodes.size() == 2)){
00087                                                         islandNodes[j].nodes.erase(islandNodes[j].nodes.begin() + 0, islandNodes[j].nodes.begin() + 1);
00088                                                 }
00089                                                 else if((islandNodes[j].nodes[1] == currentNode0) && (islandNodes[j].nodes.size() == 2)){
00090                                                         islandNodes[j].nodes.erase(islandNodes[j].nodes.begin() + 1, islandNodes[j].nodes.begin() + 2);
00091                                                 }
00092                                                 else islandNodes[j].nodes.clear();
00093                                                 numCurrentGroups--;
00094                                         }
00095                                         else if( (islandNodes[j].nodes[0] == currentNode1) || (islandNodes[j].nodes[1] == currentNode1) ){
00096                                                 islandNodes[j].setGroupID(currentID);
00097                                                 if((islandNodes[j].nodes[0] == currentNode0) && (islandNodes[j].nodes.size() == 2)){
00098                                                         islandNodes[j].nodes.erase(islandNodes[j].nodes.begin() + 0, islandNodes[j].nodes.begin() + 1);
00099                                                 }
00100                                                 else if((islandNodes[j].nodes[1] == currentNode0) && (islandNodes[j].nodes.size() == 2)){
00101                                                         islandNodes[j].nodes.erase(islandNodes[j].nodes.begin() + 1, islandNodes[j].nodes.begin() + 2);
00102                                                 }
00103                                                 else islandNodes[j].nodes.clear();
00104                                                 numCurrentGroups--;
00105                                         }
00106                                 }
00107                         }
00108         }
00109 
00110  arrangeGroups();
00111 }
00112 
00113 void SetOfVoltages::printIslands()
00114 {
00115         int i,j,k,currentID,printVoltage=1;
00116         for(i=0;i<numCurrentGroups;i++){
00117                 currentID = i;
00118                 for(j=0;j<islandNodes.size();j++){
00119                         if( (islandNodes[j].groupID == currentID) ){
00120                                 if(printVoltage){
00121                                         printVoltage = 0;
00122                                         cout << "nodes in voltage island " << islandNodes[j].voltage << endl;
00123                                 }
00124                                 for(k=0;k<islandNodes[j].nodes.size();k++){
00125                                         cout << islandNodes[j].nodes[k] << " ";
00126                                 }
00127                         }
00128                 }
00129                 cout << endl;
00130                 printVoltage = 1;
00131         }
00132 }
00133 
00134 void SetOfVoltages::arrangeGroups()
00135 {
00136         int i,j,k,idCounter=islandNodes.size(),currentID;
00137         for(i=0;i<islandNodes.size();i++){
00138                 currentID = islandNodes[i].groupID;
00139                 if(currentID < islandNodes.size()){
00140                         for(j=0;j<islandNodes.size();j++){
00141                                 if(islandNodes[j].groupID == currentID)
00142                                         islandNodes[j].groupID = idCounter;
00143                         }
00144                         idCounter++;
00145                 }
00146         }
00147         for(i=0;i<islandNodes.size();i++){
00148                 islandNodes[i].groupID -= islandNodes.size();
00149         }
00150 }
00151 
00152 int SetOfVoltages::numIslandNodes()
00153 {
00154   int i, j, count=0;
00155  
00156   for(i=0;i<islandNodes.size();i++){
00157     for(j=0;j<islandNodes[i].nodes.size();j++){
00158         count++;
00159     }
00160   }
00161 
00162  return count;
00163 }
00164 
00165 int SetOfVoltages::numIslandInGroup(int groupID)
00166 {
00167   int j, k, currentID, count;
00168 
00169       currentID = groupID;
00170       count = 0;
00171       for(j=0;j<islandNodes.size();j++){
00172          if( (islandNodes[j].groupID == currentID) ){
00173            for(k=0;k<islandNodes[j].nodes.size();k++){
00174                 count++;
00175                }
00176          }
00177       }
00178   return count;
00179 }
00180 
00181 int SetOfVoltages::voltageInGroup(int groupID)
00182 {
00183 
00184    int j, k, currentID;
00185 
00186       currentID = groupID;
00187       for(j=0;j<islandNodes.size();j++){
00188          if( (islandNodes[j].groupID == currentID) ){
00189             return islandNodes[j].voltage;
00190          }
00191       }
00192 
00193 }
00194 
00195 int SetOfVoltages::maxIslandNodes()
00196 {
00197   int i, j, k, currentID, count=0, prev_count=0;
00198 
00199   for(i=0;i<numCurrentGroups;i++){
00200       currentID = i;
00201       count = 0;
00202       for(j=0;j<islandNodes.size();j++){
00203          if( (islandNodes[j].groupID == currentID) ){
00204            for(k=0;k<islandNodes[j].nodes.size();k++){
00205                 count++;
00206                }
00207          }
00208       }
00209      if(prev_count > count) count = prev_count;
00210      prev_count = count;
00211   }
00212 
00213  return count;
00214 }
00215 
00216 void SetOfVoltages::clearIslandNodes()
00217 {
00218 
00219         for(int i=0;i<islandNodes.size();i++){
00220                 islandNodes[i].nodes.clear();
00221         }
00222         islandNodes.erase(islandNodes.begin()+0,islandNodes.begin() + islandNodes.size());
00223     numCurrentGroups = 0;
00224 }
00225 
00226 
00227 
00228 
00229 

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