1 /* 2 * drc.h -- 3 * 4 * Definitions for the DRC module. 5 * 6 * ********************************************************************* 7 * * Copyright (C) 1985, 1990 Regents of the University of California. * 8 * * Permission to use, copy, modify, and distribute this * 9 * * software and its documentation for any purpose and without * 10 * * fee is hereby granted, provided that the above copyright * 11 * * notice appear in all copies. The University of California * 12 * * makes no representations about the suitability of this * 13 * * software for any purpose. It is provided "as is" without * 14 * * express or implied warranty. Export of this software outside * 15 * * of the United States of America may require an export license. * 16 * ********************************************************************* 17 * 18 * Needs to include: magic.h database.h 19 * 20 * rcsid $Header: /usr/cvsroot/magic-8.0/drc/drc.h,v 1.6 2010/09/20 21:13:22 tim Exp $ 21 */ 22 23 #ifndef _DRC_H 24 #define _DRC_H 25 26 #include "database/database.h" 27 28 /* ----------------- component of DRC table ---------------------------- */ 29 30 typedef struct drccookie 31 { 32 int drcc_dist; /* Extent of rule from edge. */ 33 unsigned char drcc_mod; /* Fractional part of drcc_dist */ 34 int drcc_cdist; /* Size of corner extension.* */ 35 unsigned char drcc_cmod; /* Fractional part of drcc_cdist */ 36 TileTypeBitMask drcc_mask; /* Legal types on RHS */ 37 TileTypeBitMask drcc_corner; /* Types that trigger corner check */ 38 unsigned short drcc_flags; /* Miscellaneous flags, see below. */ 39 int drcc_edgeplane; /* Plane of edge */ 40 int drcc_plane; /* Index of plane on which to check 41 * legal types. */ 42 int drcc_tag; /* Tag to explanation of error found */ 43 struct drccookie *drcc_next; 44 } DRCCookie; 45 46 /* These DRC tags in DRCcookie are predefined. */ 47 #define DRC_ARRAY_OVERLAP_TAG 1 48 #define DRC_OVERLAP_TAG 2 49 #define DRC_SUBCELL_OVERLAP_TAG 3 50 #define DRC_IN_SUBCELL_TAG 4 51 #define DRC_OFFGRID_TAG 5 52 53 /* *This is size "int" because it holds an area for DRC_AREA rules, */ 54 /* and therefore may have twice the bit length of a normal rule distance. */ 55 56 /* DRCCookie flags: 57 * DRC_FORWARD: Rule applies from left to right (or bottom to top). 58 * DRC_REVERSE: Rule applies from right to left (or top to bottom). 59 * DRC_BOTHCORNERS: Must make corner extensions in both directions. 60 * DRC_OUTSIDE: Rule applies only to the outside edge of the rule area. 61 * DRC_TRIGGER: Violation of rule triggers a secondary rule. 62 * 63 * All other flags denote special DRC rules that do not use the standard 4-way 64 * edge processing. 65 */ 66 67 #define DRC_FORWARD 0x000 68 #define DRC_REVERSE 0x001 69 #define DRC_BOTHCORNERS 0x002 70 #define DRC_TRIGGER 0x004 71 #define DRC_BENDS 0x008 72 #define DRC_OUTSIDE 0x010 73 #define DRC_AREA 0x020 74 #define DRC_OFFGRID 0x040 75 #define DRC_MAXWIDTH 0x080 76 #define DRC_MAXWIDTH_BOTH 0x100 77 #define DRC_RECTSIZE 0x200 78 #define DRC_ANGLES 0x400 79 #define DRC_NONSTANDARD (DRC_AREA|DRC_MAXWIDTH|DRC_RECTSIZE\ 80 |DRC_ANGLES|DRC_OFFGRID) 81 82 /* More flags for indicating what the rule type represents */ 83 #define DRC_CIFRULE 0x400 84 85 #define DRC_PENDING 0 86 #define DRC_UNPROCESSED CLIENTDEFAULT 87 #define DRC_PROCESSED 1 88 89 /* 90 * Background DRC (DRC Idle proc) for Tcl-based Magic 91 */ 92 #ifdef MAGIC_WRAPPER 93 enum { DRC_NOT_RUNNING, DRC_IN_PROGRESS, DRC_BREAK_PENDING }; 94 extern unsigned char DRCStatus; 95 #endif 96 97 /* 98 * States of the background checker. This allows us to force an off state 99 * during initialization while allowing the startup scripts to set the 100 * state on or off. 101 */ 102 enum { DRC_SET_OFF, DRC_SET_ON, DRC_NOT_SET }; 103 104 /* This is client data passed down through the various DRC checking 105 * routines, and contains information about the area and rule being 106 * checked. 107 */ 108 struct drcClientData 109 { 110 CellDef * dCD_celldef; /* CellDef, plane and area to DRC. */ 111 int dCD_plane; 112 Rect * dCD_rect; 113 Tile * dCD_initial; /* Initial tile for search (left side 114 * for forward rules, right for reverse 115 * rules). 116 */ 117 Rect * dCD_clip; /* Clip error tiles against this. */ 118 int * dCD_errors; /* Count of errors found. */ 119 int dCD_radial; /* Radial check for corner extensions */ 120 DRCCookie * dCD_cptr; /* Rule being checked. */ 121 Rect * dCD_constraint; /* Constraint area from rule. */ 122 Rect * dCD_rlist; /* Multiple constraints for triggered rules */ 123 int dCD_entries; /* Number of constraints for triggered rules */ 124 void (* dCD_function)(); /* Function to call for each 125 * error found. */ 126 ClientData dCD_clientData; /* Parameter for dCD_function */ 127 }; 128 129 /* Describes a cell whose contents require design-rule checking of 130 * some sort. These are linked together for processing by the 131 * continuous checker. 132 */ 133 #define DRCYANK "__DRCYANK__" /* predefined DRC yank buffer */ 134 135 typedef struct drcpendingcookie 136 { 137 CellDef *dpc_def; 138 struct drcpendingcookie *dpc_next; 139 } DRCPendingCookie; 140 141 /* Structure used to pass back lists of cell definitions and error tile counts */ 142 143 typedef struct drccountlist 144 { 145 CellDef *dcl_def; 146 int dcl_count; 147 struct drccountlist *dcl_next; 148 } DRCCountList; 149 150 /* Structure used to keep information about the current DRC style */ 151 152 typedef struct drckeep 153 { 154 struct drckeep *ds_next; 155 char *ds_name; 156 } DRCKeep; 157 158 /* 159 * Structure defining a DRC style 160 */ 161 162 typedef struct drcstyle 163 { 164 char ds_status; /* Status: Loaded, not loaded, or pending */ 165 char *ds_name; /* Name of this DRC style */ 166 DRCCookie *DRCRulesTbl[TT_MAXTYPES][TT_MAXTYPES]; 167 TileTypeBitMask DRCExactOverlapTypes; 168 int DRCScaleFactorN; /* Divide dist by this to get magic units */ 169 int DRCScaleFactorD; /* Multiply dist by this to get magic units */ 170 int DRCTechHalo; /* largest action distance of design rules */ 171 int DRCStepSize; /* chunk size for decomposing large areas */ 172 unsigned short DRCFlags; /* Option flags */ 173 char **DRCWhyList; /* Indexed list of "why" text strings */ 174 int DRCWhySize; /* Length of DRCWhyList */ 175 PaintResultType DRCPaintTable[NP][NT][NT]; 176 } DRCStyle; 177 178 /* flag values used by DRCFlags */ 179 180 /* DRC_FLAGS_WIDEWIDTH_NONINCLUSIVE: If set, indicates that the ruleset */ 181 /* defines "wide" as material of MORE THAN the given DRC rule width value, as */ 182 /* opposed to the default behavior, which is to define "wide" as material of */ 183 /* AT LEAST the given DRC rule width value. */ 184 185 /* (Note that at least for now, there is no similar flag for "maxwidth" rules, */ 186 /* which are always interpreted as inclusive, meaning that material of the */ 187 /* exact width of the DRC rule width value is legal.) */ 188 189 #define DRC_FLAGS_WIDEWIDTH_NONINCLUSIVE 0x01 190 191 /* Things shared between DRC functions, but not used by the 192 * outside world: 193 */ 194 195 extern int DRCstatEdges; /* counters for statistics gathering */ 196 extern int DRCstatSlow; 197 extern int DRCstatRules; 198 extern int DRCstatTiles; 199 extern int DRCstatInteractions; 200 extern int DRCstatIntTiles; 201 extern int DRCstatCifTiles; 202 extern int DRCstatSquares; 203 extern int DRCstatArrayTiles; 204 205 #ifdef DRCRULESHISTO 206 # define DRC_MAXRULESHISTO 30 /* Max rules per edge for statistics */ 207 extern int DRCstatHRulesHisto[DRC_MAXRULESHISTO]; 208 extern int DRCstatVRulesHisto[DRC_MAXRULESHISTO]; 209 #endif /* DRCRULESHISTO */ 210 211 extern int DRCTechHalo; /* Current halo being used */ 212 extern int DRCStepSize; /* Current step size being used */ 213 extern DRCPendingCookie * DRCPendingRoot; 214 215 extern unsigned char DRCBackGround; /* global flag to enable/disable 216 * continuous DRC 217 */ 218 extern bool DRCEuclidean; /* global flag to enable/disable 219 * Euclidean distance measure 220 */ 221 extern int dbDRCDebug; 222 extern bool DRCForceReload; /* TRUE if we have to reload DRC on a 223 * change of the CIF output style 224 */ 225 226 extern DRCKeep *DRCStyleList; /* List of available DRC styles */ 227 extern DRCStyle *DRCCurStyle; /* Current DRC style in effect */ 228 extern CellDef *DRCdef; /* Current cell being checked for DRC */ 229 extern CellUse *DRCuse, *DRCDummyUse; 230 231 /* 232 * Internal procedures 233 */ 234 235 extern void drcPaintError(); 236 extern void drcPrintError(); 237 extern int drcIncludeArea(); 238 extern int drcExactOverlapTile(); 239 extern void drcInitRulesTbl(); 240 extern void drcAssign(); 241 extern void drcCifAssign(); 242 extern int drcWhyCreate(); 243 244 /* 245 * Exported procedures 246 */ 247 248 extern int DRCGetDefaultLayerWidth(); 249 extern int DRCGetDefaultLayerSpacing(); 250 extern int DRCGetDefaultWideLayerSpacing(); 251 extern int DRCGetDefaultLayerSurround(); 252 253 extern int DRCInteractionCheck(); 254 extern int drcArrayFunc(); 255 256 extern void DRCTechInit(); 257 extern bool DRCTechLine(); 258 extern bool DRCTechAddRule(); 259 extern void DRCTechStyleInit(); 260 extern void DRCTechFinal(); 261 extern void DRCTechRuleStats(); 262 extern void DRCTechScale(); 263 extern void DRCReloadCurStyle(); 264 265 extern void DRCInit(); 266 extern void DRCContinuous(); 267 extern void DRCCheckThis(); 268 extern void DRCRemovePending(); 269 extern void DRCPrintRulesTable(); 270 extern void DRCWhy(); 271 extern void DRCPrintStats(); 272 extern void DRCCheck(); 273 extern DRCCountList *DRCCount(); 274 extern int DRCFind(); 275 extern void DRCCatchUp(); 276 extern bool DRCFindInteractions(); 277 extern int DRCBasicCheck(); 278 extern void DRCOffGridError(); 279 280 extern void DRCPrintStyle(); 281 extern void DRCSetStyle(); 282 extern void DRCLoadStyle(); 283 284 /* The following macro can be used by the outside world to see if 285 * the background checker needs to be called. 286 */ 287 288 #ifdef MAGIC_WRAPPER 289 #define DRCHasWork ((DRCPendingRoot != NULL) && (DRCBackGround == DRC_SET_ON)) 290 #else 291 #define DRCHasWork ((DRCPendingRoot != NULL) && (DRCBackGround != DRC_SET_OFF)) 292 #endif 293 294 #endif /* _DRC_H */ 295