1 /* 2 * $Id: util_Defs.h,v 1.5 2005/02/17 15:34:44 jpc Exp $ 3 * 4 * /----------------------------------------------------------------\ 5 * | | 6 * | A l l i a n c e C A D S y s t e m | 7 * | S i l i c o n E n s e m b l e / A l l i a n c e | 8 * | | 9 * | Author : Jean-Paul CHAPUT | 10 * | E-mail : alliance-users@asim.lip6.fr | 11 * | ============================================================== | 12 * | C Header : "./util_Defs.h" | 13 * | ************************************************************** | 14 * | U p d a t e s | 15 * | | 16 * \----------------------------------------------------------------/ 17 */ 18 19 20 # ifndef __util_Defs__ 21 # define __util_Defs__ 22 23 24 # include <unistd.h> 25 # include <stdlib.h> 26 # include <stdio.h> 27 # include <signal.h> 28 # include <ctype.h> 29 # include <string.h> 30 # include <strings.h> 31 # include <math.h> 32 33 34 /* ---------------------------------------------------------------------- 35 * Looks if functions prototypes are availables. 36 */ 37 38 # ifndef __FP 39 # ifdef __STDC__ 40 /* Compiler is ANSI C compliant. */ 41 # include <unistd.h> 42 # include <stdarg.h> 43 44 # define __FP( arguments ) arguments 45 # define __FPV( arguments ) arguments 46 47 # define __KR_C( code ) 48 # define __ANSI_C( code ) code 49 # else 50 /* Compiler is K&R C. */ 51 # include <unistd.h> 52 # include <varargs.h> 53 54 # define __FP( arguments ) () 55 # define __FPV( arguments ) (va_alist) va_dcl 56 57 # define __KR_C( code ) code 58 # define __ANSI_C( code ) 59 # endif 60 # endif 61 62 63 /* ---------------------------------------------------------------------- 64 * Missing GNU functions prototypes under GCC/SunOS 4.1.4. 65 */ 66 67 # include "GNU_Defs.h" 68 69 70 /* ---------------------------------------------------------------------- 71 * Miscellaneous. 72 */ 73 74 # define TRUE 1 75 # define FALSE 0 76 77 # define m_Max(a,b) (((a) > (b)) ? (a) : (b)) 78 # define m_Min(a,b) (((a) > (b)) ? (b) : (a)) 79 # define ABS(a) (((a) > 0 ) ? (a) : -(a)) 80 81 82 /* Usual types shortcut. */ 83 84 85 86 87 /* ---------------------------------------------------------------------- 88 * Alliance Includes. 89 */ 90 91 # include <mut.h> 92 # include <mlo.h> 93 # include <mph.h> 94 # include <mut.h> 95 # include <mlu.h> 96 # include <mpu.h> 97 # include <aut.h> 98 99 100 101 102 /* ---------------------------------------------------------------------- 103 * Module : "util_Sys.c" 104 */ 105 106 # define F_DUMPCORE 0 107 # define F_NOCORE 1 108 109 # define C_SIGTFLT ((int)1) 110 # define C_SIGERR ((int)2) 111 112 # define C_VerboseLevel0 (0L) 113 # define C_VerboseLevel1 (1L) 114 # define C_VerboseLevel2 (2L) 115 116 # define SIZE_S64 2048 117 118 119 /* External variables from the various modules. */ 120 extern long util_VL; 121 extern long util_flags; 122 extern char util_binName[1024]; 123 124 /* Interruptions handling functions. */ 125 extern void trapInit __FP((void)); 126 /*extern void sendGSignal __FP((int aSig));*/ 127 extern void setBinName __FP((char *asName)); 128 129 /* Errors printing functions. */ 130 extern void stdflush __FP((void)); 131 extern void errMBK __FP((char *asName)); 132 extern void eprinth __FP((char *asName)); 133 extern int eprintf __FPV((char *aFormat, ...)); 134 extern int eprints __FP((char *aS)); 135 136 /* Warnings printing functions. */ 137 extern void warnMBK __FP((char *asName)); 138 extern void wprinth __FP((char *asName)); 139 extern int wprintf __FPV((char *aFormat, ...)); 140 extern int wprints __FP((char *aS)); 141 142 /* Messages printing functions. */ 143 extern void setVL __FP((long aVL)); 144 extern long getVL __FP((void)); 145 extern int vmprintf __FP((long aVL, char *aFormat, va_list aArgList)); 146 extern int mprintf __FPV((long aVL, char *aFormat, ...)); 147 extern int mprints __FP((long aVL, char *aS)); 148 extern int mprintf0 __FPV((char *aFormat, ...)); 149 extern int mprintf1 __FPV((char *aFormat, ...)); 150 extern int mprintf2 __FPV((char *aFormat, ...)); 151 152 /* "util_init" global initialisation function. */ 153 extern void util_init __FP((long aVL, long aFlags, char *asName)); 154 155 /* Persistent strings printing function (up to 64 strings). */ 156 extern char *s64printf __FPV((char *aFormat, ...)); 157 158 /* Miscellaneous. */ 159 extern char *strtoup __FP((char *aS)); 160 161 162 163 164 /* ---------------------------------------------------------------------- 165 * Module : "util_Inter.c" 166 */ 167 168 169 /* Interval list element. */ 170 typedef struct eInter_s { 171 long min; 172 long max; 173 struct eInter_s *next; 174 } eInter_t; 175 176 /* Interval list head. */ 177 typedef struct lInter_s { 178 long min; 179 long max; 180 long len; 181 struct eInter_s *l; 182 } lInter_t; 183 184 185 extern void printinter __FP((struct lInter_s *apInter)); 186 extern struct lInter_s *addinter __FP((struct lInter_s *apInter, 187 long aMin, 188 long aMax)); 189 extern void freeinter __FP((struct lInter_s *apInter)); 190 191 192 /* ---------------------------------------------------------------------- 193 * Module : "util_MBK.c" 194 */ 195 196 197 # define F_EQUAL (1L) 198 # define F_CALU (2L) 199 # define F_TALU (4L) 200 # define F_EQUAL_M (F_EQUAL) 201 # define F_EQUAL_C (F_EQUAL | F_CALU) 202 # define F_EQUAL_T (F_EQUAL | F_TALU) 203 204 # define PTYPE_LOSEG 512 205 # define PTYPE_TLOSEG 513 206 # define PTYPE_ULOCON 514 207 208 # define LOSEG_VIA 1 209 # define LOSEG_SEG 2 210 # define LOSEG_CON 3 211 # define LOSEG_SEGCON 4 212 213 # define F_HAS_SUBNET (1L<<0) 214 # define F_NET_ROUTED (1L<<1) 215 # define F_SUBNET_ROUTED (1L<<2) 216 217 218 # define MBKSCALE(l) ((l) * SCALE_X) 219 # define MBKUNSCALE(l) ((l) / SCALE_X) 220 # define NEWSIGINDEX (++MBK_sigIndex) 221 222 223 /* Model of physical VIA. */ 224 typedef struct eMVIA_s { 225 char type; 226 long width; 227 long height; 228 struct eMVIA_s *next; 229 } eMVIA_t; 230 231 232 /* Added to each segment (USER pointer). */ 233 typedef struct eLoseg_s { 234 long type; 235 void *MBKobj; 236 struct eLoseg_s *next; 237 } eLoseg_t; 238 239 240 /* Added to the phfig (USER pointer). */ 241 typedef struct tLoseg_s { 242 long sigNB; /* Number of signals. */ 243 long tSize; /* Real table size. */ 244 struct authtable *tHT; /* Sig name --> tLoseg index. */ 245 long *tAccess; /* Number of signal accesses. */ 246 long *tFlags; /* Some flags... */ 247 struct eLoseg_s **tLoseg; /* Head of signal seg list. */ 248 struct eMVIA_s *tMVIA; /* list of model VIAS. */ 249 } tLoseg_t; 250 251 252 extern long MBK_sigIndex; 253 254 255 extern long isobs __FP((struct phseg *apSeg)); 256 extern long getsigaliasnumber __FP((struct losig *apLosig)); 257 extern long signamecmp __FP((char *aLoname, char *aPhname)); 258 extern char **makesegnamelist __FP((char *aName)); 259 extern void printMBKEnv __FP((void)); 260 extern char getAltVIALayer __FP((char aVIA, char aLayer)); 261 extern char getTopVIALayer __FP((char aVIA)); 262 extern char getBottomVIALayer __FP((char aVIA)); 263 extern char getTurnVIA __FP((char aLayer)); 264 extern long isVIALayer __FP((char aVIA, char aLayer)); 265 extern long getUpVIALayer __FP((char aVIA, char aLayer)); 266 extern char getUpLayer __FP((char aLayer)); 267 extern long cmpALU __FP((char aLayer1, char aLayer2)); 268 extern char getALU __FP((char aLayer)); 269 extern char getCALU __FP((char aLayer)); 270 extern long isCALU __FP((char aLayer)); 271 extern char getTALU __FP((char aLayer)); 272 extern long getLayerTrackWidth __FP((char aLayer)); 273 extern void xyflatseg __FP((struct phseg *apFlatSeg, 274 struct phseg *apSeg, 275 long aXINS, long aYINS, 276 long aXAB1, long aYAB1, 277 long aXAB2, long aYAB2, 278 char aTransf)); 279 extern void xyflatvia __FP((struct phvia *apFlatVIA, 280 struct phvia *apVIA, 281 long aXINS, long aYINS, 282 long aXAB1, long aYAB1, 283 long aXAB2, long aYAB2, 284 char aTransf)); 285 286 /* Utilities for pad power splitting. */ 287 extern long isPad __FP((char *asCell)); 288 extern long initSigIndex __FP((struct losig *apLoSig)); 289 extern long cmpSigName __FP((struct losig *apLoSig, char *asName)); 290 extern struct locon *addInsLoCon __FP((struct loins *apIns, 291 char *asName, 292 struct losig *apSig, 293 char aDir)); 294 extern void splitPowerNet __FP((struct lofig *apLoFig, 295 char *asPower)); 296 extern struct phins *findphins __FP((struct phfig *apPhfig, 297 char *insName)); 298 extern struct phins *findphmodel __FP((struct phfig *apPhfig, 299 char *modelName)); 300 extern struct locon *findlocon __FP((struct lofig *apLofig, 301 char *conName)); 302 303 extern loins_list *addloins_noSig __FP((lofig_list *apFig, 304 char *asIns, 305 lofig_list *apModel)); 306 307 extern locon_list *addlosig_insCon __FP((loins_list *apIns, 308 char *asCon, 309 losig_list *apSig)); 310 311 extern void checkLofig __FP((struct lofig *apLofig)); 312 extern void addfeed __FP((struct lofig *apLofig, 313 struct phfig *apPhfig)); 314 extern void delfeed __FP((struct lofig *apLofig)); 315 extern void copyUpCALU __FP((struct lofig *apLofig, 316 struct phfig *apPhfig, 317 long aExit)); 318 319 extern struct eMVIA_s *addmvia __FP((struct eMVIA_s *apHead, 320 struct phvia *apVIA)); 321 extern struct eMVIA_s *getmvia __FP((struct eMVIA_s *apHead, 322 struct phvia *apVIA)); 323 extern struct eLoseg_s *addloseg __FP((struct eLoseg_s *apHead, 324 long aType, 325 void *apSegvia)); 326 extern struct eLoseg_s *delloseg __FP((struct eLoseg_s *apLoseg)); 327 extern struct tLoseg_s *gettloseg __FP((struct phfig *apPhfig)); 328 extern struct tLoseg_s *addtloseg __FP((struct phfig *apPhfig)); 329 extern struct authelem *gettlosegitem __FP((struct tLoseg_s *apTLoseg, 330 char *asKey)); 331 extern void freeloseg __FP((struct phfig *apPhfig)); 332 extern void phsegchain __FP((struct lofig *apLofig, 333 struct phfig *apPhfig)); 334 extern struct eLoseg_s *getloseglist __FP((struct phfig *apPhfig, 335 char *aName)); 336 extern void checklosegaccess __FP((struct phfig *apPhfig)); 337 extern void shiftphfig __FP((struct phfig *apPhfig, 338 long DX, 339 long DY)); 340 341 342 343 344 /* ---------------------------------------------------------------------- 345 * Module : "util_Power.c" 346 */ 347 348 349 # define F_POWER_COMPLETE 0x00000001 350 # define C_POWER_ISNONE ((char)0) 351 # define C_POWER_ISVDD ((char)1) 352 # define C_POWER_ISVSS ((char)2) 353 # define C_POWER_VERTICAL ((char)1) 354 # define C_POWER_HORIZONTAL ((char)2) 355 356 # define F_POWER_MERGE 0x00000001 357 358 359 typedef struct ePow_s { 360 long flags; 361 long y; 362 long w; 363 long xMin; 364 long xMax; 365 long min; 366 long max; 367 char *Name; 368 char Type; 369 struct lInter_s *inter; 370 struct ePow_s *Next; 371 } ePow_t; 372 373 374 extern ePow_t *addPow __FP((ePow_t **applPow, 375 long aY, 376 long aW, 377 char *aName, 378 char aType, 379 char aDir)); 380 extern void freePow __FP((struct ePow_s *aplPow)); 381 extern struct ePow_s *getPow __FP((struct ePow_s *aplPow, long aY)); 382 extern void mergeXPow __FP((struct ePow_s *apPow, 383 long axMin, 384 long axMax, 385 long aW)); 386 extern ePow_t *buildPow __FP((phfig_list *apPhfig, 387 char aLayer, 388 char aDir, 389 char *asSuffix)); 390 extern void powToCon __FP(( struct phfig *apPhfig, 391 char aLayer, 392 char aDir, 393 struct ePow_s *aplPow, 394 long aFlags)); 395 396 397 398 399 /* ---------------------------------------------------------------------- 400 * Module : "util_RTU.c" 401 */ 402 403 404 extern void rtu __FP((struct phfig *aPhfig)); 405 406 407 408 409 /* ---------------------------------------------------------------------- 410 * Module : "util_Floorplan.c" 411 */ 412 413 # define F_FLOOR_LAYERS_3 0x00000010 /* 16. */ 414 # define F_FLOOR_LAYERS_4 0x00000020 /* 16. */ 415 # define F_FLOOR_LAYERS_6 0x00000040 /* 32. */ 416 # define F_FLOOR_MARGIN 0x00000080 /* 64. */ 417 # define F_FLOOR_ROW_NUMBER 0x00000100 /* 128. */ 418 # define F_FLOOR_X_SIZE 0x00000200 /* 256. */ 419 # define F_FLOOR_Y_SIZE 0x00000400 /* 512. */ 420 # define F_FLOOR_ASPECT_RATIO 0x00000800 /* 1024. */ 421 422 # define FLOOR_XY_EXPAND MBKSCALE(50) 423 424 425 extern void placeTerms __FP((struct lofig *apLofig, 426 struct phfig *apPhfig)); 427 extern struct phfig *makeFloorplan __FP((struct lofig *apLofig, 428 long aMargin, 429 long aXSize, 430 long aYSize, 431 double aAspectRatio, 432 long aPower, 433 long aFlags)); 434 extern void expandFloorplan __FP((struct phfig *apPhfig)); 435 extern void shrinkFloorplan __FP((struct phfig *apPhfig)); 436 extern void protectPowmid __FP((struct phfig *apPhfig)); 437 438 439 440 441 /* ---------------------------------------------------------------------- 442 * Module : "util_LEFDEF.c" 443 */ 444 445 446 # include "DEF_actions.h" 447 448 449 /* LEF/DEF terminal direction. */ 450 # define C_DIRECTION_NONE ((char)0) 451 # define C_DIRECTION_INPUT ((char)1) 452 # define C_DIRECTION_OUTPUT ((char)2) 453 # define C_DIRECTION_TRISTATE ((char)3) 454 # define C_DIRECTION_INOUT ((char)4) 455 # define C_DIRECTION_FEEDTHRU ((char)5) 456 457 # define X_GRID 5 458 # define Y_SLICE 50 459 # define WIDTH_VDD 6 460 # define WIDTH_VSS 6 461 # define VIA_SIDE 2 462 # define ALU1_SPACING 3 463 # define MBK_X_GRID (X_GRID * SCALE_X) 464 # define MBK_Y_SLICE (Y_SLICE * SCALE_X) 465 # define MBK_WIDTH_VDD (WIDTH_VDD * SCALE_X) 466 # define MBK_WIDTH_VSS (WIDTH_VSS * SCALE_X) 467 # define MBK_VIA_SIDE (MBKSCALE (VIA_SIDE)) 468 # define MBK_ALU1_SPACING (MBKSCALE (ALU1_SPACING)) 469 # define DEF_X_GRID (X_GRID * DEF_UNITS_MICRONS) 470 # define DEF_Y_SLICE (Y_SLICE * DEF_UNITS_MICRONS) 471 472 473 extern long DEF_UNITS_MICRONS; 474 475 476 extern long DEF2MBK_length __FP((long aL)); 477 extern char *DEF2MBK_name __FP((char *aS)); 478 extern char DEF2MBK_transf __FP((double aO)); 479 extern char DEF2MBK_direction __FP((double aDEFdir)); 480 extern struct phref *DEF2MBK_row __FP((struct phfig *apPhfig, 481 char *aRowName, 482 char *aRowType, 483 long aOrient, 484 long aDoNumber, 485 long aByNumber, 486 long aStepX, 487 long aStepY, 488 long aX, 489 long aY)); 490 extern struct phref *DEF2MBK_track __FP((struct phfig *apPhfig, 491 char *aAxisName, 492 long aStart, 493 long aDoNumber, 494 long aStep, 495 char *asLayers, 496 long aX, 497 long aY)); 498 extern struct phref *DEF2MBK_blockage __FP((struct phfig *apPhfig, 499 long aXB1, 500 long aYB1, 501 long aWidth, 502 long aHeight)); 503 504 extern long MBK2DEF_length __FP((long aL)); 505 extern char *MBK2DEF_name __FP((char *asLEF, char *asMBK)); 506 extern char MBK2DEF_direction __FP((char acDir)); 507 extern char MBK2DEF_transf __FP((char aO)); 508 extern void MBK2DEF_row __FP((struct phref *apPhref, 509 char **appRowName, 510 char **appRowType, 511 long *apOrient, 512 long *apDoNumber, 513 long *apByNumber, 514 long *apStepX, 515 long *apStepY, 516 long *apX, 517 long *apY)); 518 extern void MBK2DEF_track __FP((struct phref *apPhref, 519 char *apAxisName, 520 long *apStart, 521 long *apDoNumber, 522 long *apStep, 523 char **apsLayers, 524 long *apX, 525 long *apY)); 526 extern void MBK2DEF_blockage __FP((struct phref *apPhref, 527 long *apXB1, 528 long *apYB1, 529 long *apWidth, 530 long *apHeight)); 531 extern char MBK2DEF_locondir __FP((struct locon *apLocon)); 532 extern char *DEF_orient2a __FP((long aT)); 533 extern long DEF_a2orient __FP((char *aT)); 534 extern char *DEF_side2a __FP((char aSide)); 535 extern char *DEF_layer2a __FP((char aLayer)); 536 extern char *DEF_via2a __FP((char aType, 537 long aDX, 538 long aDY, 539 char *aViaName)); 540 541 extern char BEH2DEF_direction __FP((char acDir)); 542 543 544 # endif 545