1 /* -*- tab-width: 4 -*-
2  *
3  * Electric(tm) VLSI Design System
4  *
5  * File: iocifpars.h
6  * CIF Parsing header
7  * Written by: Robert W. Hon, Schlumberger Palo Alto Research
8  *
9  * Copyright (c) 2000 Static Free Software.
10  *
11  * Electric(tm) is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * Electric(tm) is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with Electric(tm); see the file COPYING.  If not, write to
23  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
24  * Boston, Mass 02111-1307, USA.
25  *
26  * Static Free Software
27  * 4119 Alpine Road
28  * Portola Valley, California 94028
29  * info@staticfreesoft.com
30  */
31 
32 /******************** parser.h ********************/
33 
34 /* enumerated types for cif 2.0 parser */
35 
36 #define NIL           0
37 
38 #define SEMANTICERROR 0
39 #define SYNTAXERROR   1
40 #define WIRECOM       2
41 #define BOXCOM        3
42 #define POLYCOM       4
43 #define FLASHCOM      5
44 #define DEFSTART      6
45 #define DEFEND        7
46 #define DELETEDEF     8
47 #define LAYER         9
48 #define CALLCOM      10
49 #define COMMENT      11
50 #define NULLCOMMAND  12
51 #define USERS        13
52 #define END          14
53 #define ENDFILE      15
54 #define SYMNAME      16
55 #define INSTNAME     17
56 #define GEONAME      18
57 #define LABELCOM     19
58 
59 /******************** types.h ********************/
60 
61 /* data types for cif 2.0 parser */
62 
63 typedef struct {INTBIG x,y;} point;
64 
65 /* types for tlists */
66 enum ttype {MIRROR, TRANSLATE, ROTATE};
67 
68 typedef struct
69 {
70 	enum ttype kind;
71 	union
72 	{
73 		struct {CHAR xcoord;} mi;		/* whether to mirror x coord */
74 		struct {INTBIG xt,yt;} tr;		/* translation params */
75 		struct {INTBIG xrot,yrot;} ro;	/* rotation vector */
76 	} guts;
77 } tentry;
78 
79 /******************** error.h ********************/
80 
81 /* error codes for reporting errors */
82 
83 #define FATALINTERNAL 0
84 #define FATALSYNTAX   1
85 #define FATALSEMANTIC 2
86 #define FATALOUTPUT   3
87 #define ADVISORY      4
88 #define OTHER         5			/* OTHER must be last */
89 
90 /******************** interpreter.h ********************/
91 
92 /* structures for the interpreter */
93 
94 #define REL       0
95 #define NOREL     1
96 #define SAME      2
97 #define DONTCARE  3
98 
99 #define RECTANGLE 1		/* codes for object types */
100 #define POLY      2
101 #define WIRE      3
102 #define FLASH     4
103 #define CALL      5
104 #define MBOX      6		/* manhattan box */
105 #define NAME      7		/* geometry name */
106 #define LABEL     8		/* label type */
107 
108 /******************** trans.h ********************/
109 
110 /* data types for transformation package */
111 
112 typedef struct tma
113 {
114 	float a11, a12, a21, a22, a31, a32, a33;
115 	struct tma *prev, *next;
116 	INTBIG type;
117 	CHAR multiplied;
118 } tmatrix;
119 
120 typedef tmatrix *transform;
121 
122 /******************** shared.h ********************/
123 
124 /* utility stuff for cif interpreter */
125 
126 
127 typedef CHAR *objectptr;		/* will hold a pointer to any object */
128 
129 typedef struct
130 {
131 	INTBIG l,r,b,t;
132 } bbrecord;						/* bounding box */
133 
134 typedef struct ste
135 {
136 	INTBIG st_symnumber;		/* symbol number for this entry */
137 	struct ste *st_overflow;	/* bucket ovflo */
138 	CHAR st_expanded,st_frozen,st_defined,st_dumped;
139 	bbrecord st_bb;				/* bb as if this symbol were called by itself */
140 	CHAR st_bbvalid;
141 	CHAR *st_name;
142 	INTBIG st_ncalls;			/* number of calls made by this symbol */
143 	objectptr st_guts;			/* pointer to linked list of objects */
144 } stentry;
145 
146 typedef struct
147 {
148 	INTBIG sy_type;				/* type of object, must come first */
149 	bbrecord sy_bb;				/* bb must be next */
150 	objectptr sy_next;			/* for ll */
151 								/* layer is next, if applicable */
152 	INTBIG sy_symnumber;		/* rest is noncritical */
153 	stentry *sy_unid;
154 	CHAR *sy_name;
155 	tmatrix sy_tm;
156 	CHAR *sy_tlist;				/* trans list for this call */
157 } symcall;						/* symbol call object */
158 
159 /* hack structure for referencing first fields of any object */
160 struct cifhack
161 {
162 	INTBIG kl_type;
163 	bbrecord kl_bb;
164 	struct cifhack *kl_next;	/* for ll */
165 	INTBIG kl_layer;			/* may or may not be present */
166 };
167 
168 typedef struct
169 {
170 	INTBIG gn_type;				/* geometry name */
171 	bbrecord gn_bb;
172 	objectptr gn_next;
173 	INTBIG gn_layer;
174 	CHAR *gn_name;
175 	point gn_pos;
176 } gname;
177 
178 typedef struct
179 {
180 	INTBIG la_type;
181 	bbrecord la_bb;
182 	objectptr la_next;
183 	CHAR *la_name;
184 	point la_pos;
185 } label;
186 
187 typedef struct
188 {
189 	INTBIG bo_type;				/* type comes first */
190 	bbrecord bo_bb;				/* then bb */
191 	objectptr bo_next;			/* then link for ll */
192 	INTBIG bo_layer;			/* then layer */
193 	INTBIG bo_length,bo_width;
194 	point bo_center;
195 	INTBIG bo_xrot,bo_yrot;
196 } box;
197 
198 typedef struct
199 {
200 	INTBIG mb_type;				/* type comes first */
201 	bbrecord mb_bb;				/* then bb */
202 	objectptr mb_next;			/* then link for ll */
203 	INTBIG mb_layer;			/* then layer */
204 } mbox;
205 
206 typedef struct
207 {
208 	INTBIG fl_type;
209 	bbrecord fl_bb;
210 	objectptr fl_next;			/* for ll */
211 	INTBIG fl_layer;
212 	point fl_center;
213 	INTBIG fl_diameter;
214 } flash;
215 
216 typedef struct
217 {
218 	INTBIG po_type;
219 	bbrecord po_bb;
220 	objectptr po_next;			/* for ll */
221 	INTBIG po_layer;
222 	INTBIG po_numpts;			/* length of path, points follow */
223 	point po_p[1];				/* array of points in path */
224 } polygon;
225 
226 typedef struct
227 {
228 	INTBIG wi_type;
229 	bbrecord wi_bb;
230 	objectptr wi_next;			/* for ll */
231 	INTBIG wi_layer;
232 	INTBIG wi_width;
233 	INTBIG wi_numpts;			/* length of path, points follow */
234 	point wi_p[1];				/* array of points in path */
235 } wire;
236 
237 /************ types.c **********/
238 
239 typedef struct lp
240 {
241 	point pvalue;
242 	struct lp *pnext;
243 } linkedpoint;
244 
245 typedef struct pathrecord
246 {
247 	linkedpoint *pfirst,*plast;
248 	INTBIG plength;
249 } *path;
250 
251 /* types for tlists */
252 typedef struct lt
253 {
254 	tentry tvalue;
255 	struct lt *tnext;
256 } linkedtentry;
257 
258 typedef struct trecord
259 {
260 	linkedtentry *tfirst,*tlast;
261 	INTBIG tlength;
262 } *tlist;
263 
264 /* prototypes for intramodule interface */
265 INTBIG  io_doneinterpreter(void);
266 INTBIG  io_initparser(void);
267 BOOLEAN io_infromfile(FILE*);
268 INTBIG  io_parsefile(void);
269 INTBIG  io_doneparser(void);
270 INTBIG  io_fatalerrors(void);
271 void    io_iboundbox(INTBIG*, INTBIG*, INTBIG*, INTBIG*);
272 BOOLEAN io_createlist(void);
273 INTBIG  io_initinterpreter(void);
274 INTBIG  io_pathlength(path);
275 point   io_removepoint(path);
276 void    io_bbflash(INTBIG, INTBIG, point, INTBIG*, INTBIG*, INTBIG*, INTBIG*);
277 void    io_bbbox(INTBIG, INTBIG, INTBIG, point, INTBIG, INTBIG, INTBIG*, INTBIG*, INTBIG*, INTBIG*);
278 CHAR   *io_makepath(void);
279 void    io_freepath(path);
280 BOOLEAN io_appendpoint(path, point);
281 tentry io_removetentry(tlist);
282 INTBIG io_tlistlength(tlist);
283 INTBIG io_findlayernum(CHAR*);
284 void io_outputusercommand(INTBIG, CHAR*);
285 void io_outputds(INTBIG, CHAR*, INTBIG, INTBIG, INTBIG, INTBIG);
286 void io_outputpolygon(INTBIG, CHAR*);
287 void io_outputwire(INTBIG, INTBIG, CHAR*);
288 void io_outputbox(INTBIG, INTBIG, INTBIG, point, INTBIG, INTBIG);
289 void io_outputflash(INTBIG, INTBIG, point);
290 void io_outputgeoname(CHAR*, point, INTBIG);
291 void io_outputlabel(CHAR*, point);
292 void io_outputcall(INTBIG, CHAR*, CHAR*);
293 void io_outputdf(void);
294