1 /* -*- tab-width: 4 -*- 2 * 3 * Electric(tm) VLSI Design System 4 * 5 * File: network.h 6 * Network tool: header file for fully instantiated networks 7 * Written by: Steven M. Rubin, Static Free Software 8 * 9 * Copyright (c) 2000 Static Free Software. 10 * 11 * Electric(tm) is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * Electric(tm) is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with Electric(tm); see the file COPYING. If not, write to 23 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 24 * Boston, Mass 02111-1307, USA. 25 * 26 * Static Free Software 27 * 4119 Alpine Road 28 * Portola Valley, California 94028 29 * info@staticfreesoft.com 30 */ 31 32 #if defined(__cplusplus) && !defined(ALLCPLUSPLUS) 33 extern "C" 34 { 35 #endif 36 37 /* the meaning of tool:network.NET_options */ 38 #define NETCONPWRGND 1 /* set to connect power and ground */ 39 #define NETCONCOMMONNAME 2 /* set to connect commonly named nets */ 40 #define NETDEFBUSBASE1 010 /* set to have default bus base at 1 (instead of 0) */ 41 #define NETDEFBUSBASEDESC 020 /* set to have default busses numbered descending */ 42 #define NETIGNORERESISTORS 040 /* set to ignore resistors */ 43 #define NETDEFAULTABBREVLEN 8 /* default length of cell name abbreviations on nodes */ 44 45 #define HASHTYPE INTHUGE /* the size of hash values */ 46 47 /* the meaning of NODEPROTO->temp1 by various network tools */ 48 #define NETNCCCHECKSTATE 03 /* state of NCC check for this cell */ 49 #define NETNCCNOTCHECKED 0 /* NCC not checked for this cell */ 50 #define NETNCCCHECKEDGOOD 01 /* NCC checked successfully for this cell */ 51 #define NETNCCCHECKEDBAD 02 /* NCC checked unsuccessfully for this cell */ 52 #define NETGLOBALCHECKED 04 /* global analysis flag for this cell */ 53 #define NETCELLCODE 0777777770 /* coding for this cell when matching without expansion */ 54 #define NETCELLCODESH 3 /* right shift of NETCELLCODE */ 55 56 extern INTBIG net_options; /* cached value for "NET_options" */ 57 extern INTBIG net_unifystringskey; /* key for "NET_unify_strings" */ 58 extern INTBIG net_unifystringskey; /* key for "NET_component_tolerance" */ 59 extern INTBIG net_node_abbrev_key; /* key for "NET_node_abbreviations" */ 60 extern INTBIG net_node_abbrevlen_key; /* key for "NET_node_abbreviation_length" */ 61 extern INTBIG net_ncc_optionskey; /* key for "NET_ncc_options" */ 62 extern INTBIG net_ncc_comptolerancekey; /* key for "NET_ncc_component_tolerance" */ 63 extern INTBIG net_ncc_comptoleranceamtkey; /* key for "NET_ncc_component_tolerance_amt" */ 64 extern INTBIG net_ncc_matchkey; /* key for "NET_ncc_match" */ 65 extern INTBIG net_ncc_forcedassociationkey;/* key for "NET_ncc_forcedassociation" */ 66 extern INTBIG net_ncc_processors_key; /* key for "NET_ncc_num_processors" */ 67 extern INTBIG net_ncc_function_key; /* key for "NET_ncc_function" */ 68 extern INTBIG net_ncc_options; /* options to use in NCC */ 69 70 /* the meaning of tool:network.NET_ncc_options */ 71 #define NCCHIERARCHICAL 01 /* set to expand hierarchy during NCC */ 72 #define NCCCHECKEXPORTNAMES 02 /* set to check export names during NCC */ 73 #define NCCVERBOSETEXT 04 /* set to dump information during NCC */ 74 #define NCCVERBOSEGRAPHICS 010 /* set to display information during NCC */ 75 #define NCCIGNOREPWRGND 020 /* set to ignore power/ground during NCC */ 76 #define NCCRECURSE 040 /* set to do NCC recursively */ 77 #define NCCHIDEMATCHTAGS 0200 /* set to hide "NCCMatch" tags */ 78 #define NCCINCLUDENOCOMPNETS 0400 /* set to include no-component nets */ 79 #define NCCCHECKSIZE 01000 /* set to check component size during NCC */ 80 #define NCCNOMERGEPARALLEL 04000 /* set to not merge parallel components during NCC */ 81 #define NCCNOMERGEPARALLELOVER 010000 /* set to override parallel component nonmerge for a cell */ 82 #define NCCMERGESERIES 020000 /* set to merge series transistors during NCC */ 83 #define NCCMERGESERIESOVER 040000 /* set to override series transistors merge for a cell */ 84 #define NCCHIERARCHICALOVER 0100000 /* set to override hierarchy expansion during NCC */ 85 #define NCCEXPERIMENTAL 0200000 /* set to use experimental NCC */ 86 #define NCCGRAPHICPROGRESS 0400000 /* set to show NCC progress graphically */ 87 #define NCCDISLOCAFTERMATCH 01000000 /* set to disable local processing after NCC match */ 88 #define NCCENAFOCSYMGRPFRE 02000000 /* set to enable focus on "fresh" symmetry groups during NCC */ 89 #define NCCSUPALLAMBREP 04000000 /* set to supress all ambiguous messages during NCC */ 90 #define NCCENAFOCSYMGRPPRO 010000000 /* set to enable focus on "promising" symmetry groups during NCC */ 91 #define NCCENASTATISTICS 020000000 /* set to enable statistics during NCC */ 92 #define NCCRESISTINCLUSION 0140000000 /* how to treat resistors during NCC */ 93 #define NCCRESISTLEAVE 0 /* leave current state alone */ 94 #define NCCRESISTINCLUDE 040000000 /* make sure they are included */ 95 #define NCCRESISTEXCLUDE 0100000000 /* make sure they are excluded */ 96 97 /*********************** NET CELL PRIVATE ************************/ 98 99 #ifdef __cplusplus 100 101 #if 1 102 # define NEWRENUM /* new network renumbering algorithm */ 103 #endif 104 105 class NetCellPrivate; /* private network data */ 106 class NetName; /* name of network */ 107 class NetCellShorts; /* electrical shortcuts between exports inside cell */ 108 109 class NetCellPrivate 110 { 111 friend class NetName; 112 public: 113 void* operator new( size_t size ); 114 void* operator new( size_t size, CLUSTER *cluster ); 115 void operator delete( void* obj ); 116 #ifndef MACOS 117 void operator delete( void *obj, CLUSTER *cluster ); 118 #endif 119 NetCellPrivate( NODEPROTO *np, CLUSTER *cluster ); 120 ~NetCellPrivate(); 121 BOOLEAN updateShorts(); netshorts()122 NetCellShorts *netshorts() { return _netshorts; }; 123 NetName *findNetName( CHAR *name, BOOLEAN insert ); 124 void docheck(); 125 #ifdef NEWRENUM 126 void clearConns(); 127 void calcConns(INTBIG *count); 128 void showConns(INTBIG *deepmap); 129 #endif cluster()130 CLUSTER *cluster() { return _cluster; }; 131 private: 132 void rehashNetNames(); 133 void insertNetName( NetName *nn, INTBIG hash ); 134 #ifdef NEWRENUM 135 NetName *addNetName( CHAR *name ); 136 #endif 137 NODEPROTO *_np; 138 CLUSTER *_cluster; 139 NetName **_netnamehash; 140 INTBIG _netnametotal; 141 INTBIG _netnamecount; 142 NetCellShorts *_netshorts; 143 }; 144 145 class NetCellShorts 146 { 147 public: 148 void* operator new( size_t size ); 149 void* operator new( size_t size, CLUSTER *cluster ); 150 void operator delete( void* obj ); 151 #ifndef MACOS 152 void operator delete( void *obj, CLUSTER *cluster ); 153 #endif 154 NetCellShorts( NODEPROTO *np, CLUSTER *cluster ); 155 ~NetCellShorts(); 156 BOOLEAN isConsistent(); 157 void printf(); 158 INTBIG portwidth( INTBIG portno ); portcount()159 INTBIG portcount() { return _portcount; }; globalcount()160 INTBIG globalcount() { return _portbeg[0]; }; portdeepcount()161 INTBIG portdeepcount() { return _portbeg[_portcount] - _portbeg[0]; }; 162 #ifdef NEWRENUM portbeg(INTBIG i)163 INTBIG portbeg(INTBIG i) { return _portbeg[i]; } globalname(INTBIG i)164 CHAR *globalname(INTBIG i) { return _globalnames[i]; } isolated(INTBIG portno)165 BOOLEAN isolated(INTBIG portno) { return _isolated[portno]; }; portdeepmap(INTBIG portno)166 INTBIG portdeepmap(INTBIG portno) { return _portdeepmap[portno]; }; 167 #endif portshallowmap(INTBIG portno)168 INTBIG portshallowmap(INTBIG portno) { return _portshallowmap[portno]; }; globalshort()169 BOOLEAN globalshort() { return _globalshort; }; 170 private: 171 static void clearNetworks(NODEPROTO *np); 172 NODEPROTO *_np; 173 INTBIG _portcount; 174 INTBIG *_portbeg; 175 #ifdef NEWRENUM 176 BOOLEAN *_isolated; 177 #endif 178 CHAR **_globalnames; 179 INTBIG *_portshallowmap; 180 INTBIG *_portdeepmap; 181 BOOLEAN _globalshort; 182 }; 183 184 /*********************** NET NAME ************************/ 185 186 class NetName 187 { 188 friend class NetCellPrivate; 189 public: 190 void* operator new( size_t size ); 191 void* operator new( size_t size, CLUSTER *cluster ); 192 void operator delete( void* obj ); 193 #ifndef MACOS 194 void operator delete( void *obj, CLUSTER *cluster ); 195 #endif 196 NetName( NetCellPrivate *npd, CHAR *name ); 197 ~NetName(); 198 NETWORK *firstNet(); 199 void addNet(NETWORK *net); 200 void removeNet(NETWORK *net); name()201 CHAR *name() { return _name; }; 202 void checkArity(); 203 #ifdef NEWRENUM busWidth()204 INTBIG busWidth() { return _busWidth; }; subName(INTBIG i)205 class NetName *subName(INTBIG i) { return _netNameList[i]; }; 206 void setBusWidth( INTBIG busWidth, CHAR **strings ); conn()207 INTBIG conn() { return _conn; } 208 void markConn(); 209 #endif 210 private: 211 void docheck(); 212 void checkNet(NETWORK *net); 213 NetCellPrivate *_npd; 214 CHAR *_name; 215 INTBIG _netcount; 216 INTBIG _netaddr; 217 class NetName *_baseNetName; 218 INTBIG _baseRefCount; 219 #ifdef NEWRENUM 220 INTBIG _busWidth; /* width of bus */ 221 class NetName **_netNameList; /* list of single-wire netnames on bus */ 222 INTBIG _conn; /* connection index */ 223 #endif 224 }; 225 226 #endif 227 228 /*********************** PCOMP MODULES ***********************/ 229 230 #define NOPCOMP ((PCOMP *)-1) 231 232 /* meaning of PCOMP->state */ 233 #define NEGATEDPORT 1 /* if port is negated */ 234 #define EXPORTEDPORT 2 /* if port is exported */ 235 236 /* meaning of PCOMP->flags */ 237 #define COMPUNIQUEHASH 1 /* if component has unique hash */ 238 #define COMPHASWIDLEN 2 /* if component has width and length size info */ 239 #define COMPHASAREA 4 /* if component has area size info */ 240 #define COMPDELETED 010 /* if component has been deleted */ 241 #define COMPPARALLELSEEN 020 /* if component has been seen in parallel merge */ 242 #define COMPTEMPFLAG 040 /* flag used in parallel merging */ 243 #define COMPLOCALFLAG 0100 /* flag used in NCC */ 244 #define COMPMATCHED 0200 /* if component has been matched */ 245 246 typedef struct Ipcomp 247 { 248 INTBIG numactual; /* number of components associated with this */ 249 void *actuallist; /* actual components */ 250 NODEINST *topactual; /* actual component at topmost level */ 251 NODEINST **hierpath; /* hierarchical path to this */ 252 INTBIG *hierindex; /* hierarchical path index to this */ 253 INTBIG hierpathcount; /* length of hierarchical path */ 254 INTSML flags; /* state bits */ 255 INTSML function; /* component function */ 256 INTSML wirecount; /* number of unconnected ports (wires) */ 257 INTSML truewirecount; /* number of unconnected ports, excluding ignored Pwr&Gnd */ 258 INTBIG timestamp; /* time stamp for entry into symmetry group */ 259 INTBIG forcedassociation; /* extra factor used to force associations */ 260 HASHTYPE hashvalue; /* hash value for NCC */ 261 CHAR *hashreason; /* the explanation of the hash value */ 262 float length; /* length/size of component */ 263 float width; /* width of component (if FET) */ 264 INTSML *portindices; /* normalized indices for each wire */ 265 PORTPROTO **portlist; /* PORTPROTOs on each wire */ 266 struct Ipnet **netnumbers; /* initial netnumbers for each wire */ 267 INTSML *state; /* information about the connection */ 268 void *symgroup; /* symmetry group (used during NCC) */ 269 struct Ipcomp *nextpcomp; /* next in list of pseudocomponents */ 270 } PCOMP; 271 extern PCOMP *net_pcompfree; 272 273 /*********************** PNET MODULES ***********************/ 274 275 /* #define PATHTOPNET 1 */ /* uncomment to preserve and show the path to a net */ 276 277 #define NOPNET ((PNET *)-1) 278 279 /* meaning of PNET->flags */ 280 #define POWERNET 1 /* if net is power */ 281 #define GROUNDNET 2 /* if net is ground */ 282 #define EXPORTEDNET 4 /* if net is exported */ 283 #define GLOBALNET 010 /* if net is a global signal */ 284 #define NETUNIQUEHASH 020 /* if net has unique hash */ 285 #define NETLOCALFLAG 040 /* flag used in NCC */ 286 #define NETMATCHED 0100 /* if network has been matched */ 287 288 typedef struct Ipnet 289 { 290 INTSML flags; /* state bits */ 291 INTSML realportcount; /* number of top-level exports on this net */ 292 void *realportlist; /* top-level export(s) on this net */ 293 NETWORK *network; /* real network that this references */ 294 #ifdef PATHTOPNET 295 NODEINST **hierpath; /* hierarchical path to this */ 296 INTBIG *hierindex; /* hierarchical path index to this */ 297 INTBIG hierpathcount; /* length of hierarchical path */ 298 #endif 299 HASHTYPE hashvalue; /* hash value for NCC */ 300 CHAR *hashreason; /* the explanation of the hash value */ 301 INTBIG timestamp; /* time stamp for entry into symmetry group */ 302 INTBIG nodecount; /* number of pnodes on this network */ 303 INTBIG nodetotal; /* allocated space for pnodes and wires on this network */ 304 INTBIG forcedassociation;/* extra factor used to force associations */ 305 PCOMP **nodelist; /* list of pnodes on this network */ 306 INTBIG *nodewire; /* list of which wire on the pnode attaches to network */ 307 void *symgroup; /* symmetry group (used during NCC) */ 308 struct Ipnet *nextpnet; /* next in list */ 309 } PNET; 310 extern PNET *net_pnetfree; 311 312 /*********************** AREAPERIM and TRANSISTORINFO MODULES ***********************/ 313 314 #define NOAREAPERIM ((AREAPERIM *)-1) 315 316 typedef struct Iareaperim 317 { 318 float area; 319 INTBIG perimeter; 320 INTBIG layer; 321 TECHNOLOGY *tech; 322 struct Iareaperim *nextareaperim; 323 } AREAPERIM; 324 325 typedef struct 326 { 327 INTBIG count; /* number of transistors found */ 328 INTBIG area; /* sum of area of transistors */ 329 INTBIG width; /* sum of width of transistors */ 330 INTBIG length; /* sum of length of transistors */ 331 } TRANSISTORINFO; 332 333 extern TRANSISTORINFO net_transistor_p_gate; /* info on P transistors connected at gate */ 334 extern TRANSISTORINFO net_transistor_n_gate; /* info on N transistors connected at gate */ 335 extern TRANSISTORINFO net_transistor_p_active; /* info on P transistors connected at active */ 336 extern TRANSISTORINFO net_transistor_n_active; /* info on N transistors connected at active */ 337 338 /* prototypes for tool interface */ 339 void net_init(INTBIG*, CHAR1*[], TOOL*); 340 void net_done(void); 341 void net_set(INTBIG, CHAR*[]); 342 INTBIG net_request(CHAR*, va_list); 343 void net_examinenodeproto(NODEPROTO*); 344 void net_slice(void); 345 void net_startbatch(TOOL*, BOOLEAN); 346 void net_endbatch(void); 347 void net_modifyportproto(PORTPROTO*, NODEINST*, PORTPROTO*); 348 void net_newobject(INTBIG, INTBIG); 349 void net_killobject(INTBIG, INTBIG); 350 void net_newvariable(INTBIG, INTBIG, INTBIG, INTBIG); 351 void net_killvariable(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, UINTBIG*); 352 void net_readlibrary(LIBRARY*); 353 void net_eraselibrary(LIBRARY*); 354 355 /* prototypes for intratool interface */ 356 int net_areaperimdepthascending(const void *e1, const void *e2); 357 NETWORK **net_gethighlightednets(BOOLEAN disperror); 358 void net_freeallpcomp(PCOMP*); 359 void net_freeallpnet(PNET*); 360 void net_freepcomp(PCOMP*); 361 void net_freepnet(PNET*); 362 void net_initnetflattening(void); 363 PCOMP *net_makepseudo(NODEPROTO*, INTBIG*, INTBIG*, INTBIG*, INTBIG*, PNET**, 364 BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN, BOOLEAN); 365 AREAPERIM *net_gathergeometry(NETWORK *net, TRANSISTORINFO **p_gate, TRANSISTORINFO **n_gate, 366 TRANSISTORINFO **p_active, TRANSISTORINFO **n_active, BOOLEAN recurse); 367 BOOLEAN net_equate(BOOLEAN); 368 INTBIG net_getequivalentnet(NETWORK *net, NETWORK ***equiv, INTBIG *numequiv, BOOLEAN allowchild); 369 BOOLEAN net_compare(BOOLEAN preanalyze, BOOLEAN interactive, NODEPROTO *cell1, NODEPROTO *cell2); 370 INTBIG net_buswidth(CHAR*); 371 INTBIG net_evalbusname(INTBIG, CHAR*, CHAR***, ARCINST*, NODEPROTO*, INTBIG); 372 void net_freediffmemory(void); 373 void net_freeflatmemory(void); 374 BOOLEAN net_samenetworkname(NETWORK *net1, NETWORK *net2); 375 INTBIG net_mergeparallel(PCOMP **pcomp, PNET *pnet, INTBIG *components); 376 BOOLEAN net_comparewirelist(PCOMP *p1, PCOMP *p2, BOOLEAN useportnames); 377 void net_dumpnetwork(PCOMP *pclist, PNET *pnlist); 378 void net_removeextraneous(PCOMP **pcomplist, PNET **pnetlist, INTBIG *comp); 379 CHAR *net_describepnet(PNET *pn); 380 CHAR *net_describepcomp(PCOMP *pc); 381 HASHTYPE net_getcomphash(PCOMP *pc, INTBIG verbose); 382 HASHTYPE net_getnethash(PNET *pn, INTBIG verbose); 383 NETWORK *net_getnetwork(CHAR *netname, NODEPROTO *cell); 384 void net_redoprim(void); 385 void net_initnetprivate(NODEPROTO*); 386 void net_freenetprivate(NODEPROTO*); 387 void net_checknetprivate(NODEPROTO*); 388 void net_initdiff(void); 389 void net_showcomphash(WINDOWPART *win, PCOMP *pc, HASHTYPE hashvalue, INTBIG hashindex, INTBIG verbose); 390 void net_shownethash(WINDOWPART *win, PNET *pn, HASHTYPE hashvalue, INTBIG hashindex, INTBIG verbose); 391 void net_freenetwork(NETWORK*, NODEPROTO*); 392 void net_conv_to_internal(NODEPROTO *np); 393 void net_removeassociations(void); 394 void net_fillinnetpointers(PCOMP *pcomplist, PNET *pnetlist); 395 BOOLEAN net_nccalreadydone(NODEPROTO *cell1, NODEPROTO *cell2); 396 void net_nccremovematches(NODEPROTO *np); 397 INTBIG net_ncchasmatch(NODEPROTO *np); 398 void net_nccmatchinfo(NODEPROTO *np, NODEPROTO **cellmatch, UINTBIG *celldate); 399 void net_parsenccresult(NODEPROTO *np, VARIABLE *var, NODEPROTO **cellmatch, 400 UINTBIG *celldate); 401 VARIABLE *net_nccfindmatch(NODEPROTO *np, NODEPROTO *onp, UINTBIG *matchdate); 402 void net_setnodewidth(NODEINST *ni); 403 INTBIG net_gathernodenames(NODEPROTO *np, CHAR ***namelist); 404 BOOLEAN net_getcells(NODEPROTO**, NODEPROTO**); 405 void net_listnccoverrides(BOOLEAN usetemp1); 406 BOOLEAN net_componentequalvalue(float v1, float v2); 407 INTBIG net_findglobalnet(NODEPROTO *np, CHAR *name); 408 #ifdef FORCESUNTOOLS 409 BOOLEAN net_analyzecell(void); 410 void net_freeexpdiffmemory(void); 411 INTBIG net_doexpgemini(PCOMP *pcomp1, PNET *pnet1, PCOMP *pcomp2, PNET *pnet2, 412 BOOLEAN checksize, BOOLEAN checkexportnames, BOOLEAN ignorepwrgnd); 413 BOOLEAN net_equateexp(BOOLEAN noise); 414 INTBIG net_expanalyzesymmetrygroups(BOOLEAN reporterrors, BOOLEAN checksize, 415 BOOLEAN checkexportname, BOOLEAN ignorepwrgnd, INTBIG *errorcount); 416 #endif 417 418 #if defined(__cplusplus) && !defined(ALLCPLUSPLUS) 419 } 420 #endif 421