Jspice3
cddefs.h
Go to the documentation of this file.
1 /***************************************************************************
2 SCED - Schematic Capture Editor
3 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
4 Copyright 1990 Regents of the University of California. All rights reserved.
5 Authors: 1981 Giles C. Billingsley, Ken Keller (parts of KIC layout editor)
6  1992 Stephen R. Whiteley
7 ****************************************************************************/
8 
9 /*
10  * CD package data structures.
11  *
12  */
13 
14 #include <stdio.h>
15 #include <math.h>
16 #include "cdmacs.h"
17 #include "cdprpty.h"
18 
19 #define CDDelete CDDeleteObjectDesc
20 
21 #define FILENAMESIZE 32 /* maximum size of a file name */
22 
23 /*
24  * Values routines return in StatusInt of CDOpen, CDBeginMakeCall,
25  * CDTo, CDFrom, or CDParseCIF.
26  */
27 #define CDPARSEFAILED 1 /* (FATAL) parse failed */
28 #define CDOLDSYMBOL 2 /* symbol already exists in database */
29 #define CDNEWSYMBOL 3 /* (empty) symbol not in search path */
30 #define CDSUCCEEDED 4 /* new symbol(s) found in search path */
31 
32 /*
33  * Valid arguments to CDError().
34  */
35 #define CDMALLOCFAILED 11 /* (FATAL) out of memory */
36 #define CDBADBOX 12 /* zero width or length box */
37 #define CDXFORMSTACKFULL 13 /* transform stack overflow */
38 #define CDBADPATH 14 /* bad directory name in search path */
39 
40 /*
41  * Types of geometries
42  */
43 #define CDSYMBOLCALL 'c'
44 #define CDPOLYGON 'p'
45 #define CDROUNDFLASH 'r'
46 #define CDLABEL 'l'
47 #define CDWIRE 'w'
48 #define CDBOX 'b'
49 
50 /*
51  * Types of transformations
52  */
53 #define CDMIRRORX 'x' /* mirror in the direction of x */
54 #define CDMIRRORY 'y' /* mirror in the direction of y */
55 #define CDROTATE 'r' /* rotate by vector X,Y */
56 #define CDTRANSLATE 't' /* translate to X,Y */
57 
58 /*
59  * CD Control flags; See struct d below.
60  */
61 #define DCONTROLCDOPEN 'o'
62 #define DCONTROLPCIF 'p'
63 #define DCONTROLCDTO 't'
64 #define DCONTROLVANILLA 'v'
65 
66 /*
67  * Coordinate system with 1 micron features and 1 cm dice.
68  * Remember that there are 100 CIF units per micron.
69  */
70 #define CDINFINITY 100000000L
71 
72 /*
73  * These are the numbers that CD uses to determine which bin an object
74  * resides in. They should reflect the average size of a layout being
75  * edited by KIC. KIC will not fail if the numbers are too small.
76  * Anything outside of this window is placed in the residual bin.
77  * If these numbers become too large, CDIntersect() must use floating
78  * point calculations.
79  */
80 #define CDBINMAXX 500000L
81 #define CDBINMAXY 500000L
82 #define CDBINMINX (-CDBINMAXX)
83 #define CDBINMINY (-CDBINMAXY)
84 
85 /*
86  * PLEASE NOTE
87  * ^^^^^^^^^^^
88  * Because a char is used as the layer fields, the absolute maximum
89  * number of layers is 127. The may be increase by recompiling
90  * KIC and CD with the Layer typed as ints.
91  */
92 #define CDNUMBINS 10
93 #define CDNUMLAYERS 35
94 
95 /*
96  * Number of symbols stored in the symbol table for any given CIF file.
97  */
98 #define CDNUMREMEMBER 1000
99 
100 /*
101  * Storage for diagnostics of CDError().
102  */
103 extern char *CDStatusString;
104 extern int CDStatusInt;
105 
106 /*
107  * Master list desc.
108  */
109 struct m {
111  char *mName;
112  struct m *mPred,*mSucc;
114 };
115 
116 /*
117  * Symbol desc.
118  */
119 struct s {
120  long sLeft,sBottom,sRight,sTop;
121  long sA,sB;
122  char *sName;
123  /*
124  * One bin foe each layer. Layer 0 is for call descs.
125  * Each bin points to a double linked list of object descs.
126  * Bin[.][0][0] are the RESIDUAL bins--Bin[.][0][1] and Bin[.][1][0]
127  * are unused TUNABLE. NumBins should be as big as it can be.
128  * For 20 layers and 100 bins per layer,
129  * the data structure becomes 2000 words.
130  */
131  struct o ***sBin[CDNUMLAYERS+1];
132  struct m *sMasterList;
133  struct prpty *sPrptyList;
134  char *sHY; /* hypertext entry list */
135  short sInfo;
136  short sBBValid;
137 };
138 
139 /*
140  * Object desc.
141  */
142 struct o {
143  long oLeft,oBottom,oRight,oTop;
144  struct o *oRep;
145  struct o *oPred,*oSucc;
146  struct prpty *oPrptyList;
147  short oInfo;
148  char oType;
149  char oLayer;
150 };
151 
152 /*
153  * Polygon desc.
154  */
155 struct po {
156  struct p *poPath;
157 };
158 
159 /*
160  * Round flash desc.
161  */
162 struct r {
163  long rWidth,rX,rY;
164 };
165 
166 /*
167  * Wire desc.
168  */
169 struct w {
170  long wWidth;
171  struct p *wPath;
172 };
173 
174 /*
175  * Call desc.
176  */
177 struct c {
178  long cDX,cDY; /* center to center array spacing */
179  struct t *cT; /* Pointer to transformation descriptor. */
180  struct m *cMaster; /* Pointer to master list descriptor. */
181  short cNumX,cNumY; /* Array parameters. */
182  int cNum;
183 };
184 
185 /*
186  * Transform desc.
187  * If MX, tType == CDMIRRORX.
188  * If MY, tType == CDMIRRORX.
189  * If R, tType == CDROTATE, tX == XDirection, tY == YDirection.
190  * If T, tType == CDTRANSLATE, tX == TX, tY = TY;
191  */
192 struct t {
193  long tX,tY;
194  struct t *tSucc;
195  char tType;
196 };
197 
198 /*
199  * Label desc.
200  */
201 struct la {
202  long laX,laY;
203  char *laLabel;
204  char laXform;
205  /* laXform bits:
206  * 0-1, 0-no rotation, 1-90, 2-180, 3-270.
207  * 2, mirror y
208  * 3, mirror x
209  */
210 };
211 
212 /*
213  * Linked path structure
214  */
215 struct p {
216  long pX,pY;
217  struct p *pSucc;
218 };
219 
220 /*
221  * Generator desc.
222  * Search Bin[Layer][0][0] first.
223  * Then Bin[Layer][BeginX..EndX][BeginY..EndY].
224  * Bin[Layer][X][Y] is the current bin.
225  * Pointer points to the current desc in the current bin.
226  */
227 struct g {
228  long gLeft,gBottom,gRight,gTop;
229  long gBeginX,gX,gEndX,gBeginY,gY,gEndY;
230  struct o *gPointer;
231  int gLayer;
232 };
233 
234 /*
235  * CD's current parameter struct
236  */
237 struct d {
238 
239  /* Current parameters for symbol being parsed in CDOpen. */
240  int dNumX,dNumY;
241  long dDX,dDY;
242 
243  /* Scale factors for CDTo and CDFrom. */
244  long dA,dB;
245 
246  /* Symbol scale factors. */
247  long dDSA,dDSB;
248 
249  struct o *dPointer;
250  struct s *dSymbolDesc;
251  struct s *dRootCellDesc;
252 
254 
255  /*
256  * Fields used in CDTo follow.
257  */
258 
259  /* True if parsing root symbol. */
260  int dRoot;
261 
262  /* Root's file desc. */
264 
265  /* Current property list for symbol being parsed */
266  struct prpty *dPrptyList;
267 
268  /*
269  * Symbol name table.
270  * Big arrays are allocated in CDInit().
271  */
272  char (*dSymTabNames)[FILENAMESIZE];
275 
276  /*
277  * Because CIF files may have FORWARD references, CDTo must pass
278  * over the CIF file TWICE.
279  * On the first pass, it just fills up the symbol name table.
280  * On the second pass, it does the translation to KIC format.
281  */
283 
284  /*
285  * True if debugging.
286  */
287  int dDebug;
289 
290  /*
291  * DCONTROLCDOPEN => CD is in CDOpen
292  * DCONTROLPCIF => CD is in CDOpen and parsing CIF rather than kic
293  * DCONTROLCDTO => CD is in CDTo
294  * DCONTROLVANILLA => CD is in none of the above
295  */
296  char dControl;
297 
298  /*
299  * dProgram == 'h' if IGS gened it.
300  * == 'i' if Icarus gened it.
301  * == 's' if Sif gened it.
302  * == 'n' if none of the above.
303  */
304  char dProgram;
305  char dSymbolName[FILENAMESIZE];
306 };
307 extern struct d CDDesc;
308 
309 /*
310  * CD layer table
311  */
312 struct l {
314  char lMask[3];
315  /*True if CDFrom should output layer.*/
316  char lCDFrom;
317 };
318 extern struct l CDLayer[CDNUMLAYERS+1];
319 
320 /*
321  * Hash table of symbol descs keyed on symbol's name.
322  */
323 struct bu {
324  struct s *buSymbolDesc;
325  struct bu *buPred;
326  struct bu *buSucc;
327 };
328 extern struct bu *CDSymbolTable[CDNUMLAYERS+1];
329 
330 #include "cdext.h"
struct prpty * sPrptyList
Definition: cddefs.h:133
char dControl
Definition: cddefs.h:296
FILE * dSymbolFileDesc
Definition: cddefs.h:253
long dDSB
Definition: cddefs.h:247
long laY
Definition: cddefs.h:202
struct l CDLayer[CDNUMLAYERS+1]
Definition: cd.c:74
char lCDFrom
Definition: cddefs.h:316
long dDY
Definition: cddefs.h:241
long mTop
Definition: cddefs.h:110
short sBBValid
Definition: cddefs.h:136
long mLeft
Definition: cddefs.h:110
Definition: cddefs.h:119
struct t * cT
Definition: cddefs.h:179
long tY
Definition: cddefs.h:193
char oType
Definition: cddefs.h:148
int CDStatusInt
Definition: cd.c:75
long wWidth
Definition: cddefs.h:170
struct bu * buSucc
Definition: cddefs.h:326
struct d CDDesc
Definition: cd.c:73
Definition: cddefs.h:169
int dRoot
Definition: cddefs.h:260
struct m * mPred
Definition: cddefs.h:112
Definition: cddefs.h:312
long sTop
Definition: cddefs.h:120
long mRight
Definition: cddefs.h:110
Definition: cddefs.h:215
struct o * dPointer
Definition: cddefs.h:249
struct o * oSucc
Definition: cddefs.h:145
struct bu * buPred
Definition: cddefs.h:325
struct bu * CDSymbolTable[CDNUMLAYERS+1]
Definition: cd.c:72
int * dSymTabNumbers
Definition: cddefs.h:273
long rY
Definition: cddefs.h:163
SymbolDesc sLeft
Definition: cd.c:1953
long pY
Definition: cddefs.h:216
char oLayer
Definition: cddefs.h:149
char tType
Definition: cddefs.h:195
struct o * oPred
Definition: cddefs.h:145
long cDY
Definition: cddefs.h:178
struct m * cMaster
Definition: cddefs.h:180
Definition: cddefs.h:237
long gTop
Definition: cddefs.h:228
Definition: cddefs.h:323
short sInfo
Definition: cddefs.h:135
int mReferenceCount
Definition: cddefs.h:113
char * mName
Definition: cddefs.h:111
struct m * sMasterList
Definition: cddefs.h:132
struct o * gPointer
Definition: cddefs.h:230
struct s * buSymbolDesc
Definition: cddefs.h:324
struct o * oRep
Definition: cddefs.h:144
int dNumSymbolsAllocated
Definition: cddefs.h:288
Definition: cddefs.h:201
Definition: cddefs.h:142
struct t * tSucc
Definition: cddefs.h:194
long oTop
Definition: cddefs.h:143
#define CDNUMLAYERS
Definition: cddefs.h:93
Definition: cddefs.h:177
SymbolDesc sRight
Definition: cd.c:1954
int gLayer
Definition: cddefs.h:231
struct m * mSucc
Definition: cddefs.h:112
char * CDStatusString
Definition: cd.c:77
long sB
Definition: cddefs.h:121
char dProgram
Definition: cddefs.h:304
Definition: cddefs.h:162
char * sHY
Definition: cddefs.h:134
char laXform
Definition: cddefs.h:204
char lTechnology
Definition: cddefs.h:313
Definition: cddefs.h:227
int dNumY
Definition: cddefs.h:240
struct p * wPath
Definition: cddefs.h:171
struct p * poPath
Definition: cddefs.h:156
int cNum
Definition: cddefs.h:182
long gY
Definition: cddefs.h:229
char * sName
Definition: cddefs.h:122
char * laLabel
Definition: cddefs.h:203
long dB
Definition: cddefs.h:244
#define FILENAMESIZE
Definition: cddefs.h:21
int dFirstPass
Definition: cddefs.h:282
Definition: cddefs.h:192
struct p * pSucc
Definition: cddefs.h:217
int dNumSymbolTable
Definition: cddefs.h:274
Definition: cdprpty.h:62
Definition: cddefs.h:109
struct s * dSymbolDesc
Definition: cddefs.h:250
short oInfo
Definition: cddefs.h:147
Definition: cddefs.h:155
struct prpty * oPrptyList
Definition: cddefs.h:146
int dDebug
Definition: cddefs.h:287
long mBottom
Definition: cddefs.h:110
struct prpty * dPrptyList
Definition: cddefs.h:266
short cNumY
Definition: cddefs.h:181
struct s * dRootCellDesc
Definition: cddefs.h:251
FILE * dRootFileDesc
Definition: cddefs.h:263