1 /* -*- tab-width: 4 -*- 2 * 3 * Electric(tm) VLSI Design System 4 * 5 * File: database.h 6 * Database manager: header file 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 /*************************** FLAG BIT SETTINGS ****************************/ 38 39 #define MARKN 040 /* NODEINST->userbits: nodeinst is marked */ 40 #define TOUCHN 0100 /* NODEINST->userbits: nodeinst is touched */ 41 42 #define FIXEDMOD 0100000000 /* ARCINST->userbits: fixed arc was changed */ 43 44 #define CELLMOD 0400000 /* NODEPROTO->userbits: cell is changed */ 45 #define CELLNOMOD 01000000 /* NODEPROTO->userbits: cell is not changed */ 46 47 /*************************** CHANGES ****************************/ 48 49 #define NOCHANGE ((CHANGE *)-1) 50 51 /* meaning of "changetype" (when changing this, also change "broadcasttype[]" in "db_change()") */ 52 #define NODEINSTNEW 0 /* new nodeinst */ 53 #define NODEINSTKILL 1 /* killed nodeinst */ 54 #define NODEINSTMOD 2 /* modified nodeinst */ 55 56 #define ARCINSTCHANGE 3 /* base of ARCINST changes */ 57 #define ARCINSTNEW 3 /* new arcinst */ 58 #define ARCINSTKILL 4 /* deleted arcinst */ 59 #define ARCINSTMOD 5 /* modified arcinst */ 60 61 #define PORTPROTOCHANGE 6 /* base of PORTPROTO changes */ 62 #define PORTPROTONEW 6 /* new portinst on a nodeproto */ 63 #define PORTPROTOKILL 7 /* deleted portinst on a nodeproto */ 64 #define PORTPROTOMOD 8 /* motified portinst on a nodeproto */ 65 66 #define NODEPROTOCHANGE 9 /* base of NODEPROTO changes */ 67 #define NODEPROTONEW 9 /* new nodeproto */ 68 #define NODEPROTOKILL 10 /* killed nodeproto */ 69 #define NODEPROTOMOD 11 /* modified nodeproto */ 70 71 #define VARIABLECHANGE 12 /* base of VARIABLE changes */ 72 #define OBJECTSTART 12 /* start of object change */ 73 #define OBJECTEND 13 /* end of object change */ 74 #define OBJECTNEW 14 /* new object */ 75 #define OBJECTKILL 15 /* deleted object */ 76 #define VARIABLENEW 16 /* new variable */ 77 #define VARIABLEKILL 17 /* deleted variable */ 78 #define VARIABLEMOD 18 /* changed single entry in array variable */ 79 #define VARIABLEINS 19 /* inserted single entry in array variable */ 80 #define VARIABLEDEL 20 /* deleted single entry in array variable */ 81 #define DESCRIPTMOD 21 /* changed text descriptor */ 82 83 typedef struct Ichange 84 { 85 INTBIG changetype; /* type of change */ 86 INTBIG entryaddr; /* address of object that was changed */ 87 struct Ichange *nextchange; /* address of next change module in list */ 88 struct Ichange *prevchange; /* address of previous change module */ 89 INTBIG p1,p2,p3,p4,p5,p6; /* old values before the change */ 90 } CHANGE; 91 92 /*************************** CHANGE BATCHES ****************************/ 93 94 #define NOCHANGECELL ((CHANGECELL *)-1) 95 96 typedef struct Ichangecell 97 { 98 NODEPROTO *changecell; /* the cell that changed */ 99 BOOLEAN forcedlook; /* true if library must be re-examined */ 100 struct Ichangecell *nextchangecell; /* next in list */ 101 } CHANGECELL; 102 103 104 #define NOCHANGEBATCH ((CHANGEBATCH *)-1) 105 106 typedef struct Ichangebatch 107 { 108 CHANGE *changehead; /* head of list of things to change */ 109 CHANGE *changetail; /* tail of list of things to change */ 110 struct Ichangebatch *nextchangebatch; /* next in list */ 111 struct Ichangebatch *lastchangebatch; /* last in list */ 112 CHANGECELL *firstchangecell; /* the cell in which this change was made */ 113 TOOL *tool; /* tool that made this batch */ 114 CHAR *activity; /* description of activity */ 115 INTBIG batchnumber; /* identifying index of this batch */ 116 BOOLEAN done; /* true if this batch was done */ 117 } CHANGEBATCH; 118 119 /*************************** BOX MERGING ****************************/ 120 121 /* box descriptor */ 122 typedef struct Iboxpoly 123 { 124 INTBIG ll[2], lr[2], ul[2], ur[2]; 125 INTBIG top, bot, left, right; 126 INTBIG ishor; /* "ishor" unused */ 127 INTBIG numsides, numint[4]; 128 struct Iboxpoly *nextbox; 129 struct Ipolycoord *polyint[4]; 130 struct Ipolycoord *auxpolyint[4]; 131 } BOXPOLY; 132 133 /* box list head */ 134 typedef struct Iboxlisthead 135 { 136 INTBIG layer; 137 TECHNOLOGY *tech; 138 struct Iboxpoly *box; 139 struct Iboxlisthead *nextlayer; 140 } BOXLISTHEAD; 141 142 /* polygon edge descriptor */ 143 typedef struct Ipolycoord 144 { 145 INTBIG indx, ed_or, ed_start[2], ed_end[2], ed_val, seen; 146 struct Ipolycoord *nextpoly; 147 } POLYCOORD; 148 149 /* polygon edge ring head */ 150 typedef struct Ipolylisthead 151 { 152 struct Ipolycoord *firstpoly; 153 INTBIG numedge, modified; 154 } POLYLISTHEAD; 155 156 /*************************** ERROR CODES ****************************/ 157 158 /* error messages */ 159 #define DBNOERROR 0 /* no error */ 160 #define DBNOMEM 1 /* no memory */ 161 #define DBBADTRANS 2 /* bad transposition */ 162 #define DBBADROT 3 /* bad rotation */ 163 #define DBBADPROTO 4 /* bad prototype */ 164 #define DBBADPARENT 5 /* bad parent */ 165 #define DBBADINST 6 /* invalid instance */ 166 #define DBBADNAME 7 /* invalid name */ 167 #define DBBADWIDTH 8 /* bad width */ 168 #define DBBADENDAN 9 /* bad end A node/port */ 169 #define DBBADENDBN 10 /* bad end B node/port */ 170 #define DBBADENDAC 11 /* bad end A connection */ 171 #define DBBADENDBC 12 /* bad end B connection */ 172 #define DBBADENDAP 13 /* bad end A position */ 173 #define DBBADENDBP 14 /* bad end B position */ 174 #define DBBADNEWWID 15 /* bad new width */ 175 #define DBBADCELL 16 /* bad cell */ 176 #define DBBADLIB 17 /* bad library */ 177 #define DBBADSIZE 18 /* bad size */ 178 #define DBBADOBJECT 19 /* bad object type */ 179 #define DBBADSUBPORT 20 /* bad sub port */ 180 #define DBHASARCS 21 /* still has arcs */ 181 #define DBHASPORTS 22 /* still has ports */ 182 #define DBHASINSTANCES 23 /* cell has instances */ 183 #define DBRECURSIVE 24 /* recursive call */ 184 #define DBNOTINPORT 25 /* arc not in port */ 185 #define DBCONFLICT 26 /* conflicts with primitive */ 186 #define DBPORTMM 27 /* port mismatch */ 187 #define DBDUPLICATE 28 /* duplicate name */ 188 #define DBPRIMITIVE 29 /* primitive prototype */ 189 #define DBBADTMAT 30 /* bad transformation matrix */ 190 #define DBNOVAR 31 /* variable does not exist */ 191 #define DBVARFIXED 32 /* variable cannot be set */ 192 #define DBVARARRDIS 33 /* variable cannot be displayable array */ 193 #define DBLASTECH 34 /* this is the last technology */ 194 #define DBTECINUSE 35 /* technology is still in use */ 195 #define DBNOSLIDING 36 /* sliding not allowed */ 196 197 #define DBADDSTRINGTOINFSTR (1<<16) 198 #define DBADDTECHNOLOGY (2<<16) 199 #define DBADDTOINFSTR (3<<16) 200 #define DBALLOCARCINST (4<<16) 201 #define DBALLOCGEOM (5<<16) 202 #define DBALLOCLIBRARY (6<<16) 203 #define DBALLOCNODEINST (7<<16) 204 #define DBALLOCNODEPROTO (8<<16) 205 #define DBALLOCPOLYGON (9<<16) 206 #define DBALLOCPORTARCINST (10<<16) 207 #define DBALLOCPORTEXPINST (11<<16) 208 #define DBALLOCPORTPROTO (12<<16) 209 #define DBALLOCSTRING (13<<16) 210 #define DBALLOCTECHNOLOGY (14<<16) 211 #define DBALLOCVIEW (15<<16) 212 #define DBCOPYNODEPROTO (16<<16) 213 #define DBDELIND (17<<16) 214 #define DBDELINDKEY (18<<16) 215 #define DBDELVALKEY (19<<16) 216 #define DBDESCRIBEVARIABLE (20<<16) 217 #define DBEXTENDPOLYGON (21<<16) 218 #define DBINITINFSTR (22<<16) 219 #define DBINITOBJLIST (23<<16) 220 #define DBINSIND (24<<16) 221 #define DBINSINDKEY (25<<16) 222 #define DBKILLARCINST (26<<16) 223 #define DBKILLLIBRARY (27<<16) 224 #define DBKILLNODEINST (28<<16) 225 #define DBKILLNODEPROTO (29<<16) 226 #define DBKILLPORTPROTO (30<<16) 227 #define DBKILLTECHNOLOGY (31<<16) 228 #define DBMAKEKEY (32<<16) 229 #define DBMODIFYARCINST (33<<16) 230 #define DBMOVEPORTPROTO (34<<16) 231 #define DBNEWARCINST (35<<16) 232 #define DBNEWLIBRARY (36<<16) 233 #define DBNEWNODEINST (37<<16) 234 #define DBNEWNODEPROTO (38<<16) 235 #define DBNEWPORTPROTO (39<<16) 236 #define DBNEWVIEW (40<<16) 237 #define DBREPLACEARCINST (41<<16) 238 #define DBREPLACENODEINST (42<<16) 239 #define DBRETURNINFSTR (43<<16) 240 #define DBSETIND (44<<16) 241 #define DBSETINDKEY (45<<16) 242 #define DBSETVAL (46<<16) 243 #define DBSETVALKEY (47<<16) 244 #define DBTRANSMULT (48<<16) 245 #define DBXFORM (49<<16) 246 247 extern INTBIG db_lasterror; /* last error message */ 248 extern BOOLEAN db_printerrors; /* flag for printing internal errors */ 249 250 /*************************** VARIABLE KEYS ****************************/ 251 252 extern INTBIG db_tech_node_width_offset_key; /* variable "TECH_node_width_offset" */ 253 extern INTBIG db_tech_layer_function_key; /* variable "TECH_layer_function" */ 254 extern INTBIG db_tech_layer_names_key; /* variable "TECH_layer_names" */ 255 extern INTBIG db_tech_arc_width_offset_key; /* variable "TECH_arc_width_offset" */ 256 257 /*************************** MULTIPROCESSOR CONTROL ****************************/ 258 259 extern BOOLEAN db_multiprocessing; /* true if multiprocessing */ 260 261 /*************************** CHANGE CONTROL ****************************/ 262 263 extern BOOLEAN db_donextchangequietly; /* true to do next change quietly */ 264 extern BOOLEAN db_dochangesquietly; /* true to do changes quietly */ 265 extern UINTBIG db_changetimestamp; /* timestamp for changes to database */ 266 extern UINTBIG db_traversaltimestamp; /* timestamp for hierarchy traversal */ 267 extern INTBIG db_broadcasting; /* nonzero if broadcasting */ 268 269 /*************************** LANGUAGE CONTROL ****************************/ 270 271 extern BOOLEAN db_onanobject; /* TRUE if code evaluation is "on an object" (getval, etc.) */ 272 extern INTBIG db_onobjectaddr; /* the address of the first object that we are on */ 273 extern INTBIG db_onobjecttype; /* the type of the first object that we are on */ 274 extern INTBIG db_lastonobjectaddr; /* the address of the last object that we were on */ 275 extern INTBIG db_lastonobjecttype; /* the type of the last object that we were on */ 276 277 /*************************** PROTOTYPES ****************************/ 278 279 /* database prototypes */ 280 void db_addportarcinst(NODEINST*, PORTARCINST*); 281 void db_addportexpinst(NODEINST*, PORTEXPINST*); 282 BOOLEAN db_addtortnode(UINTBIG, RTNODE*, NODEPROTO*); 283 void db_boundcell(NODEPROTO*, INTBIG*, INTBIG*, INTBIG*, INTBIG*); 284 void db_buildnodeprotohashtable(LIBRARY *lib); 285 void db_buildportprotohashtable(NODEPROTO*); 286 CHANGE *db_change(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG); 287 void db_changeport(PORTPROTO*, NODEINST*, PORTPROTO*); 288 void db_checkallmemoryfree(void); 289 void db_clearportcache(NODEPROTO *cell); 290 void db_correctcellgroups(NODEPROTO *cell);; 291 VARIABLE *db_dummyvariable(void); 292 void db_endbatch(void); 293 void db_enterarcinst(ARCINST*); 294 void db_enternodeinst(NODEINST*); 295 void db_enterportproto(PORTPROTO*); 296 BOOLEAN db_enterwindowpart(WINDOWPART *w); 297 INTBIG db_error(INTBIG); 298 NODEPROTO *db_findnodeprotoname(CHAR *name, VIEW *view, LIBRARY *lib); 299 void db_forcehierarchicalanalysis(NODEPROTO*); 300 void db_freearcproto(ARCPROTO *ap); 301 void db_freechangememory(void); 302 void db_freeerrormemory(void); 303 void db_freegeomemory(void); 304 void db_freemathmemory(void); 305 void db_freemergememory(void); 306 void db_freenoprotomemory(void); 307 void db_freertree(RTNODE *rtn); 308 void db_freetclmemory(void); 309 void db_freetechnologymemory(void); 310 void db_freetextmemory(void); 311 void db_freevar(INTBIG, INTBIG); 312 void db_freevariablememory(void); 313 void db_freevars(VARIABLE**, INTSML*); 314 CHANGEBATCH *db_getcurrentbatch(void); 315 float db_getcurrentscale(INTBIG, INTBIG, INTBIG); 316 void db_getinternalunitscale(INTBIG*, INTBIG*, INTBIG, INTBIG); 317 void db_gettraversalpath(NODEPROTO *here, WINDOWPART *win, NODEINST ***nilist, INTBIG *depth); 318 BOOLEAN db_getvarptr(INTBIG, INTBIG, VARIABLE***, INTSML**); 319 void db_initclusters(void); 320 void db_initdatabase(void); 321 void db_initgeometry(void); 322 void db_initializechanges(void); 323 void db_initlanguages(void); 324 void db_inittechcache(void); 325 void db_inittechnologies(void); 326 void db_inittranslation(void); 327 void db_insertnodeproto(NODEPROTO*); 328 void db_killarcinst(ARCINST*); 329 void db_killnodeinst(NODEINST*); 330 void db_mrgdatainit(void); 331 INTBIG db_namehash(CHAR *name); 332 ARCINST *db_newarcinst(ARCPROTO*, INTBIG, INTBIG, NODEINST*, PORTPROTO*, INTBIG, INTBIG, 333 NODEINST*, PORTPROTO*, INTBIG, INTBIG, NODEPROTO*); 334 ARCPROTO *db_newarcproto(TECHNOLOGY*, CHAR*, INTBIG, INTBIG); 335 NODEINST *db_newnodeinst(NODEPROTO*, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, NODEPROTO*); 336 PORTPROTO *db_newportproto(NODEPROTO*, NODEINST*, PORTPROTO*, CHAR*); 337 NODEPROTO *db_newprimnodeproto(CHAR*, INTBIG, INTBIG, INTBIG, TECHNOLOGY*); 338 PORTPROTO *db_newprimportproto(NODEPROTO*, ARCPROTO**, CHAR*); 339 void db_printclusterarena(CHAR*); 340 void db_printrtree(RTNODE*, RTNODE*, INTBIG); 341 void db_removecellfromgroup(NODEPROTO*); 342 void db_removechangecell(NODEPROTO*); 343 void db_removeportexpinst(PORTPROTO*); 344 void db_retractarcinst(ARCINST*); 345 void db_retractnodeinst(NODEINST*); 346 void db_retractnodeproto(NODEPROTO*); 347 void db_retractportproto(PORTPROTO*); 348 void db_retractwindowpart(WINDOWPART *w); 349 void db_rtnbbox(RTNODE*, INTBIG, INTBIG*, INTBIG*, INTBIG*, INTBIG*); 350 void db_setchangecell(NODEPROTO*); 351 void db_setcurrenttool(TOOL*); 352 BOOLEAN db_stillinport(ARCINST*, INTBIG, INTBIG, INTBIG); 353 void db_termlanguage(void); 354 void db_undodlog(void); 355 NODEPROTO *db_whichnodeproto(INTBIG, INTBIG); 356 357 #if defined(__cplusplus) && !defined(ALLCPLUSPLUS) 358 } 359 #endif 360