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 00036 00037 00038 00039 00040 00041 00042 00043 #ifndef NET_H 00044 #define NET_H 00045 00046 #include "FPcommon.h" 00047 00048 #include <vector> 00049 #include <algorithm> 00050 #include <math.h> 00051 #include <stdlib.h> 00052 00053 namespace parquetfp 00054 { 00055 00056 class pin; 00057 typedef std::vector<pin>::iterator itPin; 00058 00059 00060 //this class holds the pin offsets and pinindex on a particular node 00061 class pin 00062 { 00063 private: 00064 Point _origOffset; //original offset wrt center. In relative terms 00065 Point _offset; //offsets during iteration. to account for orientation changes 00066 ORIENT _orient; //keeps track of orientation of the node 00067 string _name; 00068 bool _type; 00069 int _nodeIndex; //index of the node in which the pin is located 00070 int _netIndex; //index of net to which pin is attached 00071 00072 public: 00073 00074 pin(const char* name, bool type, double xoffset, double yoffset, int netIndex) 00075 :_type(type) 00076 { 00077 //strncpy(_name,name,199); 00078 //_name[199] = '\0'; 00079 _name = name; 00080 _origOffset.x=xoffset; 00081 _origOffset.y=yoffset; 00082 _offset.x=xoffset; 00083 _offset.y=yoffset; 00084 _orient=N; 00085 _netIndex=netIndex; 00086 } 00087 pin() 00088 { 00089 } 00090 00091 bool getType() const 00092 { return _type;} 00093 char* getName(void) 00094 {return const_cast<char*>(_name.c_str());} 00095 int getNodeIndex() const 00096 {return _nodeIndex;} 00097 int getNetIndex() const 00098 { return _netIndex; } 00099 void putNodeIndex(int nodeIndex) 00100 { _nodeIndex = nodeIndex; } 00101 void putNetIndex(int netIndex) 00102 { _netIndex = netIndex; } 00103 void putType(bool type) 00104 { _type = type; } 00105 00106 double getXOffset(void) const 00107 { return _offset.x; } 00108 double getYOffset(void) const 00109 { return _offset.y; } 00110 double getOrigXOffset(void) const 00111 { return _origOffset.x; } 00112 double getOrigYOffset(void) const 00113 { return _origOffset.y; } 00114 00115 ORIENT getOrient(void) const 00116 { return _orient; } 00117 00118 void changeOrient(ORIENT newOrient); 00119 00120 }; 00121 00122 00123 00124 class Net 00125 { 00126 00127 public: 00128 vector<pin> _pins; 00129 00130 private: 00131 int _index; 00132 string _name; 00133 double _weight; 00134 00135 public: 00136 Net() 00137 { 00138 _weight = 1.0; 00139 } 00140 00141 void putName(const char* name) 00142 { 00143 _name = name; 00144 // strncpy(_name, name, 99); 00145 // _name[99] = '\0'; 00146 } 00147 00148 void addNode(pin node) 00149 { 00150 _pins.push_back(node); 00151 } 00152 void clean(void) 00153 { 00154 _pins.resize(0); 00155 } 00156 itPin pinsBegin() 00157 { 00158 return _pins.begin(); 00159 } 00160 itPin pinsEnd() 00161 { 00162 return _pins.end(); 00163 } 00164 00165 pin& getPin(unsigned pinOffset) 00166 { return _pins[pinOffset]; } 00167 00168 int getIndex() const 00169 { 00170 return _index; 00171 } 00172 void putIndex(int netIndex) 00173 { 00174 _index = netIndex; 00175 } 00176 double getWeight() const 00177 { 00178 return _weight; 00179 } 00180 void putWeight(double netWeight) 00181 { 00182 _weight = netWeight; 00183 } 00184 char* getName(void) 00185 { return const_cast<char*>(_name.c_str()); } 00186 00187 unsigned getDegree(void) const 00188 { return _pins.size(); } 00189 00190 }; 00191 00192 } 00193 00194 //using namespace parquetfp; 00195 00196 #endif