1 /* 2 * CIFread.h -- 3 * 4 * This file contains definitions used by the CIF reader, but not 5 * by the CIF writing code. The definitions are only used internally 6 * to this module. 7 * 8 * ********************************************************************* 9 * * Copyright (C) 1985, 1990 Regents of the University of California. * 10 * * Permission to use, copy, modify, and distribute this * 11 * * software and its documentation for any purpose and without * 12 * * fee is hereby granted, provided that the above copyright * 13 * * notice appear in all copies. The University of California * 14 * * makes no representations about the suitability of this * 15 * * software for any purpose. It is provided "as is" without * 16 * * express or implied warranty. Export of this software outside * 17 * * of the United States of America may require an export license. * 18 * ********************************************************************* 19 * 20 * 21 * rcsid "$Header: /usr/cvsroot/magic-8.0/cif/CIFread.h,v 1.3 2010/08/25 17:33:55 tim Exp $ 22 */ 23 24 #ifndef _CIFREAD_H 25 #define _CIFREAD_H 26 27 #include "cif/CIFint.h" 28 29 /* The structures below are built up by CIFreadtech.c to describe 30 * various styles for reading CIF. 31 */ 32 33 /* The following structure describes a sequence of geometric 34 * operations used to produce information for a single Magic 35 * layer. There may be several of these structures for the 36 * same Magic layer; in that case, the results end up being 37 * OR'ed together. 38 */ 39 40 typedef struct 41 { 42 TileType crl_magicType; /* Magic layer to paint results. */ 43 CIFOp *crl_ops; /* List of operations to generate 44 * info for Magic layer. 45 */ 46 int crl_flags; /* Miscellaneous flags (see below). */ 47 } CIFReadLayer; 48 49 /* The CIFReadLayer flags are: 50 * 51 * CIFR_SIMPLE: Means this layer is a simple one, coming from only 52 * a single OR operation, so it can be handled specially. 53 * CIFR_TEMPLAYER: Means this layer is a temporary CIF layer, and that 54 * the "crl_magicType" should be interpreted as a CIF layer. 55 */ 56 57 #define CIFR_SIMPLE 1 58 #define CIFR_TEMPLAYER 2 59 60 /* The following structure defines a complete CIF read-in style. 61 * The constant MAXCIFRLAYERS must be less than TT_MAXTYPES, and 62 * is used both as the largest number of distinct CIF layer names 63 * in all read styles, and as the larges number of distinct "layer" 64 * commands in any one read style. 65 */ 66 67 #define MAXCIFRLAYERS (TT_MAXTYPES - 1) 68 69 /* 70 * To avoid the large memory demands of maintaining all CIF styles in 71 * memory, we keep only the style names and re-read the technology file 72 * as necessary 73 */ 74 75 typedef struct cifrkeep 76 { 77 struct cifrkeep *crs_next; 78 char *crs_name; 79 } CIFReadKeep; 80 81 typedef struct cifrstyle 82 { 83 char crs_status; /* Status: Loaded, not loaded, or pending. */ 84 char *crs_name; /* Name for this style of CIF input. */ 85 TileTypeBitMask crs_cifLayers; 86 /* Mask of CIF layers understood in 87 * this style. 88 */ 89 int crs_nLayers; /* Number of CIFReadLayers involved. */ 90 int crs_scaleFactor; /* Number of CIF units per Magic unit. */ 91 int crs_multiplier; /* crs_scaleFactor / crs_multiplier = 92 * units in traditional centimicrons. 93 * So if crs_multiplier = 10, CIF units 94 * are in nanometers (millimicrons). 95 */ 96 int crs_gridLimit; /* Input is considered off-grid if on 97 * a pitch less than crs_gridLimit CIF 98 * units, and input will be snapped to 99 * grid rather than scaling the grid 100 * to accomodate the data. 0 = no limit. 101 */ 102 103 TileType crs_labelLayer[MAXCIFRLAYERS]; 104 /* Gives the Magic layer to use for labels 105 * on each possible CIF layer. 106 */ 107 bool crs_labelSticky[MAXCIFRLAYERS]; 108 /* Marker if label layer makes sticky labels */ 109 CIFReadLayer *crs_layers[MAXCIFRLAYERS]; 110 HashTable cifCalmaToCif; /* Table mapping from Calma layer numbers to 111 * CIF layers 112 */ 113 int crs_flags; /* Mask of boolean cif-reading options */ 114 } CIFReadStyle; 115 116 /* option bitmasks used in crs_flags */ 117 #define CRF_IGNORE_UNKNOWNLAYER_LABELS 1 118 #define CRF_NO_RECONNECT_LABELS 2 119 120 /* Methods to deal with fractional results of conversion from CIF to magic */ 121 /* units (see routine CIFScaleCoord() for details). */ 122 123 #define COORD_EXACT 0 124 #define COORD_HALF_U 1 125 #define COORD_HALF_L 2 126 #define COORD_ANY 3 127 128 /* For parsing CIF, we need to keep track of paths (wire locations 129 * or polygon boundaries. These are just linked lists of points. 130 */ 131 132 #define CIF_ZERO 0 133 #define CIF_LEFT 1 134 #define CIF_UP 2 135 #define CIF_RIGHT 3 136 #define CIF_DOWN 4 137 #define CIF_DIAG 5 138 139 /* Specific diagonal directions */ 140 #define CIF_DIAG_UL 5 141 #define CIF_DIAG_UR 6 142 #define CIF_DIAG_DL 7 143 #define CIF_DIAG_DR 8 144 145 typedef struct cifpath 146 { 147 Point cifp_point; /* A point in the path. */ 148 struct cifpath *cifp_next; /* The next point in the path, or NULL. */ 149 } CIFPath; 150 151 #define cifp_x cifp_point.p_x 152 #define cifp_y cifp_point.p_y 153 154 /* Procedures */ 155 156 extern bool CIFParseBox(), CIFParseWire(), CIFParsePoly(); 157 extern bool CIFParseFlash(), CIFParseLayer(), CIFParseStart(); 158 extern bool CIFParseFinish(), CIFParseDelete(), CIFParseUser(); 159 extern bool CIFParseCall(), CIFParseTransform(), CIFParseInteger(); 160 extern bool CIFParsePath(), CIFParsePoint(), CIFParseSInteger(); 161 extern void CIFSkipToSemi(), CIFSkipSep(), CIFSkipBlanks(); 162 extern void CIFFreePath(), CIFCleanPath(); 163 extern void CIFReadCellInit(), CIFReadCellCleanup(); 164 extern LinkedRect *CIFPolyToRects(); 165 extern Transform *CIFDirectionToTrans(); 166 extern int CIFReadNameToType(); 167 168 /* Variable argument procedures require complete prototype */ 169 170 extern void CIFReadError(char *format, ...); 171 extern void CIFReadWarning(char *format, ...); 172 173 /* Variables shared by the CIF-reading modules, see CIFreadutils.c 174 * for more details: 175 */ 176 177 extern int cifReadScale1, cifReadScale2; 178 extern int cifNReadLayers; 179 extern Plane *cifReadPlane; 180 extern Plane **cifCurReadPlanes; 181 extern TileType cifCurLabelType; 182 extern CIFReadStyle *cifCurReadStyle; 183 extern bool cifSubcellBeingRead; 184 extern CellDef *cifReadCellDef; 185 extern FILE *cifInputFile; 186 extern bool cifParseLaAvail; 187 extern int cifParseLaChar; 188 189 /* Macros to read characters, with one-character look-ahead. */ 190 191 #define PEEK() ( cifParseLaAvail \ 192 ? cifParseLaChar \ 193 : (cifParseLaAvail = TRUE, \ 194 cifParseLaChar = getc(cifInputFile))) 195 196 #define TAKE() ( cifParseLaAvail \ 197 ? (cifParseLaAvail = FALSE, cifParseLaChar) \ 198 : (cifParseLaChar = getc(cifInputFile))) 199 200 #endif /* _CIFREAD_H */ 201