1 /*
2  * CIFint.h --
3  *
4  * Defines things shared internally by the cif module of Magic,
5  * but not generally needed outside the cif module.
6  *
7  *     *********************************************************************
8  *     * Copyright (C) 1985, 1990 Regents of the University of California. *
9  *     * Permission to use, copy, modify, and distribute this              *
10  *     * software and its documentation for any purpose and without        *
11  *     * fee is hereby granted, provided that the above copyright          *
12  *     * notice appear in all copies.  The University of California        *
13  *     * makes no representations about the suitability of this            *
14  *     * software for any purpose.  It is provided "as is" without         *
15  *     * express or implied warranty.  Export of this software outside     *
16  *     * of the United States of America may require an export license.    *
17  *     *********************************************************************
18  *
19  * rcsid "$Header: /usr/cvsroot/magic-8.0/cif/CIFint.h,v 1.3 2008/12/04 17:10:29 tim Exp $"
20  */
21 
22 #ifndef _CIFINT_H
23 #define _CIFINT_H
24 
25 #include "database/database.h"
26 
27 /* The main data structure used in the cif module is a description
28  * of how to generate CIF layers from the Magic tiles.  There may
29  * be several different styles for generating CIF from the same Magic
30  * information, e.g. for fabricating at different geometries.  Each
31  * of these CIF styles involves three kinds of data.  A "CIFStyle"
32  * record gives overall information such as the number of layers.
33  * One "CIFLayer" gives overall information for each layer, and
34  * then a list of one or more "CIFOp" records describes a sequence
35  * of geometrical operations to perform to generate the layer.  This
36  * data structure is built up by reading the technology file.
37  */
38 
39 /* A CIFOp starts from a partially-completed CIF layer, does something
40  * to it, which may possibly involve some existing layers or temporary
41  * layers, and creates the next stage of the partially-completed
42  * CIF layer.  Example operations are to AND with some existing paint,
43  * or to grow by a certain amount.
44  */
45 
46 typedef struct bloat_data
47 {
48     int bl_plane;		/* Plane on which a bloat or squares
49 				 * operation is valid.  If -1, then the bloat
50 				 * types are CIF types.
51 				 */
52     int bl_distance[TT_MAXTYPES];
53 } BloatData;
54 
55 typedef struct bridge_data
56 {
57     int br_width;		/* Minimum width rule for bridge */
58 } BridgeData;
59 
60 typedef struct squares_data
61 {
62     int sq_border;
63     int sq_size;
64     int sq_sep;
65     int sq_gridx;		/* Only used for "squares-grid" */
66     int sq_gridy;		/* Only used for "squares-grid" */
67 } SquaresData;
68 
69 typedef struct slots_data
70 {
71     int sl_sborder;		/* short tile side */
72     int sl_ssize;
73     int sl_ssep;
74     int sl_lborder;		/* long tile side */
75     int sl_lsize;
76     int sl_lsep;
77     int sl_offset;
78     int sl_start;
79 } SlotsData;
80 
81 typedef struct cifop
82 {
83     TileTypeBitMask co_paintMask;/* Zero or more paint layers to consider. */
84     TileTypeBitMask co_cifMask;	 /* Zero or more other CIF layers. */
85     int co_opcode;		/* Which geometric operation to use.  See
86 				 * below for the legal ones.
87 				 */
88     int co_distance;		/* Grow or shrink distance (if needed). */
89     ClientData co_client;	/* Pointer to a BloatData, SquaresData,
90 				 * SlotsData, or BridgeData structure,
91 				 * or NULL.
92 				 */
93     struct cifop *co_next;	/* Next in list of operations to perform. */
94 } CIFOp;
95 
96 /* The opcodes defined so far are:
97  *
98  * CIFOP_AND -		AND current results with the layers indicated by
99  *			the masks.
100  * CIFOP_ANDNOT -	Wherever there is material indicated by the masks,
101  *			erase those areas from the current results.
102  * CIFOP_OR -		OR current results with the layers indicated by
103  *			the masks.
104  * CIFOP_GROW -		Grow the current results uniformly by co_distance.
105  * CIFOP_GROW_G -	Grow the current results to snap to the indicated grid.
106  * CIFOP_GROWMIN -	Grow result such that no dimension is less than co_distance.
107  * CIFOP_SHRINK -	Shrink the current results uniformly by co_distance.
108  * CIFOP_BLOAT -	Find layers in paintMask, then bloat selectively
109  *			according to bl_distance, and OR the results into
110  *			the current plane
111  * CIFOP_SQUARES -	Generates a pattern of squares (used for making
112  *			contact vias.  Each square is co_distance large,
113  *			the squares are separated from each other by
114  *			co_distance, and they are inside the edge of
115  *			the material by at least co_distance.
116  * CIFOP_SLOTS -	Generate a pattern of rectangles (used for making
117  *			slots and slot vias).  Similar to squares except
118  *			for different dimensions in short and long tile
119  *			dimensions. "0" for the long size indicates that
120  *			the slot should extend the length of the tile
121  *			minus the long-side border length.
122  * CIFOP_BLOATMAX -	Like CIFOP_BLOAT, except whole side of tile gets
123  *			bloated by same amount, which is max bloat from
124  *			anywhere along side.  Bloats can be negative.
125  * CIFOP_BLOATMIN -	Same as CIFOP_BLOAT, except use min bloat from
126  *			anywhere along side.
127  * CIFOP_BLOATALL -	Added 3/21/05---bloat to encompass all connected
128  *			material of the indicated type(s).
129  * CIFOP_BBOX -		Added 4/2/05---create a single rectangle encompassing
130  *			the cell bounding box.  This involves no magic type
131  *			layers but may itself be acted upon with grow/shrink
132  *			rules.
133  * CIFOP_BOUNDARY -	Added 6/5/19---map the FIXED_BBOX property bounding
134  *			box coordinates into CIF layer geometry.
135  * CIFOP_NET -		Added 11/3/08---pull an entire electrical net into
136  *			the CIF layer, selectively picking layers.
137  * CIFOP_MAXRECT -	Reduce all areas to the largest internal fitting
138  *			rectangle.
139  * CIFOP_COPYUP -	Added 5/5/16---make and keep a copy the resulting layer,
140  *			which will be painted into parent cells instead of the
141  *			current cell.  This replaces the "fault" method.
142  * CIFOP_CLOSE -	Added 11/25/19---close up areas smaller than indicated
143  * CIFOP_BRIDGE -	Added 6/11/20---Bridge across catecorner gaps
144  * CIFOP_BRIDGELIM -	Added 27/07/20---Bridge across catecorner gaps, but with limiting layers
145  * CIFOP_MASKHINTS -	Added 12/14/20---Add geometry from cell properties, if any.
146  */
147 
148 #define CIFOP_AND	1
149 #define CIFOP_OR	2
150 #define CIFOP_GROW	3
151 #define CIFOP_GROWMIN	4
152 #define CIFOP_GROW_G	5
153 #define CIFOP_SHRINK	6
154 #define CIFOP_BLOAT	7
155 #define CIFOP_SQUARES	8
156 #define CIFOP_SLOTS	9
157 #define CIFOP_BLOATMAX	10
158 #define CIFOP_BLOATMIN	11
159 #define CIFOP_BLOATALL	12
160 #define CIFOP_ANDNOT	13
161 #define CIFOP_SQUARES_G	14
162 #define CIFOP_BBOX	15
163 #define CIFOP_BOUNDARY	16
164 #define CIFOP_NET	17
165 #define CIFOP_MAXRECT	18
166 #define CIFOP_COPYUP	19
167 #define CIFOP_CLOSE	20
168 #define CIFOP_BRIDGE	21
169 #define CIFOP_BRIDGELIM 22
170 #define CIFOP_MASKHINTS 23
171 
172 
173 /* Added by Tim 10/21/2004 */
174 /* The following structure is used to pass information on how to draw
175  * contact subcell arrays for a specific magic contact tile type.  For
176  * the GDS write routine, the GDS file (FILE *) is passed as the client
177  * data.
178  */
179 
180 typedef struct cifsquaresinfo
181 {
182     SquaresData	*csi_squares;	/* Information on how to generate squares */
183     TileType	 csi_type;	/* Magic contact tile type */
184     ClientData	 csi_client;	/* Used to pass output file info.	*/
185 } CIFSquaresInfo;
186 
187 /* The following data structure contains all the information about
188  * a particular CIF layer.
189  */
190 
191 typedef struct
192 {
193     char *cl_name;		/* Name of layer. */
194     CIFOp *cl_ops;		/* List of operations.  If NULL, layer is
195 				 * determined entirely by cl_initial.
196 				 */
197     int cl_growDist;		/* Largest distance material may move in
198 				 * this layer from its original Magic
199 				 * position, due to grows.  Expressed
200 				 * in CIF units.  If this layer uses temp
201 				 * layers, this distance must include grows
202 				 * from the temp layers.
203 				 */
204     int cl_shrinkDist;		/* Same as above, except for shrinks. */
205     int cl_flags;		/* Bunches of flags:  see below. */
206     int cl_calmanum;		/* Number (0-63) of this layer for output as
207 				 * Calma (GDS-II stream format), or -1 if
208 				 * this layer should not be output.
209 				 */
210     int cl_calmatype;		/* Data type (0-63) for Calma output, or -1
211 				 * if this layer should not be output.
212 				 */
213     int min_width;		/* the minimum width rule in centi-microns
214 				 * for the layer. This is used by Grow Sliver
215 				 * to generate drc correct parent slivers
216 				 */
217 #ifdef THREE_D
218     int	   cl_renderStyle;	/* Style to render CIF layer with */
219     float  cl_height;		/* (rendered) height of CIF layer above substrate */
220     float  cl_thick;		/* (rendered) thickness of CIF layer */
221 #endif
222 
223 } CIFLayer;
224 
225 /* The CIFLayer flags are:
226  *
227  * CIF_TEMP:	Means that this is a temporary layer used to build
228  *		up CIF information.  It isn't output in the CIF file.
229  * CIF_LABEL:	This layer is used to generate fixed labels in the
230  *		output file.
231  */
232 
233 #define CIF_TEMP 		1
234 #define CIF_LABEL 		2
235 
236 /* The following data structure describes a complete set of CIF
237  * layers.  The number of CIF layers (MAXCIFLAYERS) must not be
238  * greater than the number of tile types (TT_MAXTYPES)!!
239  */
240 
241 #define MAXCIFLAYERS (TT_MAXTYPES - 1)
242 
243 typedef struct cifkeep
244 {
245     struct cifkeep	*cs_next;
246     char		*cs_name;
247 } CIFKeep;
248 
249 typedef struct cifstyle
250 {
251     char cs_status;		/* Status:  Loaded, not loaded, or pending. */
252     char *cs_name;		/* Name used for this kind of CIF. */
253     int cs_nLayers;		/* Number of layers. */
254     int cs_radius;		/* Radius of interaction for hierarchical
255 				 * processing (expressed in Magic units).
256 				 */
257     int cs_stepSize;		/* If non-zero, user-specified step size
258 				 * for hierarchical processing (in Magic
259 				 * units).
260 				 */
261     int cs_gridLimit;		/* The limit of grid scaling.  This limits
262 				 * the use of "scalegrid" to prevent Magic
263 				 * from generating geometry smaller than the
264 				 * process minimum grid.
265 				 */
266     int cs_scaleFactor;		/* Number of CIF units per Magic unit.
267  				 * CIF units are usually centimicrons, but
268 				 * see cs_expander below.
269 				 */
270     int cs_reducer;		/* Reduction factor (used only to reduce
271 				 * number of zeroes in CIF files and make
272 				 * file more readable).  Default of 1.
273 				 * Unused for GDS input/output.
274 				 */
275     int cs_expander;		/* cs_scaleFactor / cs_expander = scale in
276 				 * centimicrons.  Default of 1.  Value 10
277 				 * means cs_scaleFactor is measured in
278 				 * nanometers (millimicrons)
279                                  */
280 
281     TileTypeBitMask cs_yankLayers;
282 				/* For hierarchical processing, only these
283 				 * Magic types need to be yanked.
284 				 */
285     TileTypeBitMask cs_hierLayers;
286 				/* For hierarchical processing, only these
287 				 * CIF layers need to be generated.
288 				 */
289     int cs_labelLayer[TT_MAXTYPES];
290 				/* Each entry corresponds to one Magic layer,
291 				 * and gives index of CIF real layer to use
292 				 * for labels attached to this Magic layer.
293 				 * -1 means no known CIF layer for this Magic
294 				 * layer.
295 				 */
296     int cs_portLayer[TT_MAXTYPES];
297 				/* Similar to cs_labelLayer, to distinguish
298 				 * between output types used for "normal"
299 				 * text and those used specifically for ports.
300 				 */
301     CIFLayer *cs_layers[MAXCIFLAYERS];
302 				/* Describes how to generate each layer.*/
303     int cs_flags;		/* bitmask of boolean-valued output options */
304 
305 } CIFStyle;
306 
307 /* values for cs_flags */
308 #define CWF_PERMISSIVE_LABELS	0x01
309 #define CWF_GROW_SLIVERS	0x02
310 #define CWF_ANGSTROMS 		0x04
311 #define CWF_GROW_EUCLIDEAN	0x08
312 #define CWF_SEE_NO_VENDOR	0x10	/* Hide magic's GDS from vendor cells	*/
313 #define CWF_NO_ERRORS		0x20	/* Do not generate error msgs and fdbk	*/
314 #define CWF_STRING_LIMIT	0x40	/* Use older Calma format character limit */
315 
316 /* procedures */
317 
318 extern bool CIFNameToMask();
319 extern void CIFGenSubcells();
320 extern void CIFGenArrays();
321 extern void CIFGen();
322 extern void CIFClearPlanes();
323 extern Plane *CIFGenLayer();
324 extern void CIFInitCells();
325 extern int cifHierCopyFunc();
326 extern int cifHierCopyMaskHints();
327 extern void CIFLoadStyle();
328 extern void CIFCopyMaskHints();
329 
330 /* Shared variables and structures: */
331 
332 extern Plane *CIFPlanes[];		/* Normal place to store CIF. */
333 extern CIFKeep *CIFStyleList;		/* List of all CIF styles. */
334 extern CIFStyle *CIFCurStyle;		/* Current style being used. */
335 extern CIFStyle *CIFDRCStyle;		/* CIF style for DRC checking (optional) */
336 extern CellUse *CIFComponentUse;	/* Flatten stuff in here if needed. */
337 extern CellDef *CIFComponentDef;	/* Corresponds to CIFComponentUse. */
338 extern CellUse *CIFDummyUse;		/* Used to dummy up a CellUse for a
339 					 * def.
340 					 */
341 
342 /* Valid values of CIFWarningLevel (see cif.h) */
343 
344 typedef enum {CIF_WARN_DEFAULT, CIF_WARN_NONE, CIF_WARN_ALIGN,
345 	CIF_WARN_LIMIT, CIF_WARN_REDIRECT, CIF_WARN_END} CIFWarningTypes;
346 
347 /* Statistics counters: */
348 
349 extern int CIFTileOps;
350 extern int CIFHierTileOps;
351 extern int CIFRects;
352 extern int CIFHierRects;
353 
354 /* Tables used for painting and erasing CIF. */
355 
356 extern PaintResultType CIFPaintTable[], CIFEraseTable[];
357 
358 /* Procedures and variables for reporting errors. */
359 
360 extern int CIFErrorLayer;
361 extern CellDef *CIFErrorDef;
362 extern void CIFError();
363 
364 /* The following determines the tile type used to hold the CIF
365  * information on its paint plane.
366  */
367 
368 #define CIF_SOLIDTYPE 1
369 extern TileTypeBitMask CIFSolidBits;
370 
371 #endif /* _CIFINT_H */
372