1 /* -*- tab-width: 4 -*-
2  *
3  * Electric(tm) VLSI Design System
4  *
5  * File: conlin.h
6  * Linear inequality constraint system header file
7  * Written by: Steven M. Rubin, Static Free Software
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 #if defined(__cplusplus) && !defined(ALLCPLUSPLUS)
33 extern "C"
34 {
35 #endif
36 
37 extern CONSTRAINT *cli_constraint;		/* the constraint object for this solver */
38 extern BOOLEAN     cli_manhattan;		/* nonzero to assume Manhattan constraints */
39 extern INTBIG      cli_properties_key;	/* variable key for "CONLIN_properties" */
40 
41 /***************** CONSTRAINT DATA STORED ON ARCS *************/
42 
43 #define NOLINCON ((LINCON *)-1)
44 
45 #define CLGEQUALS    0				/* greater than or equal */
46 #define CLEQUALS     1				/* equals */
47 #define CLLEQUALS    2				/* less than or equal */
48 
49 #define CLLEFT       0				/* constraint left */
50 #define CLRIGHT      1				/* constraint right */
51 #define CLDOWN       2				/* constraint down */
52 #define CLUP         3				/* constraint up */
53 
54 typedef struct
55 {
56 	INTBIG variable;				/* 0=left  1=right  2=up  3=down */
57 	INTBIG oper;					/* 0 >=    1 ==     2 <=  */
58 	INTBIG value;					/* the constraining distance (in WHOLE units) */
59 } LINCON;
60 
61 #define LINCONSIZE ((sizeof (LINCON)) / SIZEOFINTBIG)
62 
63 /***************** FOR THE TEXT-TO-GRAPHICS SYSTEM *************/
64 
65 extern NODEPROTO *cli_curcell;		/* the current cell being equated to text */
66 extern BOOLEAN    cli_ownchanges;	/* true if changes are internally generated */
67 extern INTBIG     cli_textlines;	/* number of declaration/connection lines */
68 extern BOOLEAN    cli_texton;		/* true if text/graphics system is on */
69 
70 /* the different types of lines of text (returned by "cli_lintype") */
71 #define LINEUNKN   0				/* line is unknown statement (an error) */
72 #define LINECOMM   1				/* line is a comment or empty */
73 #define LINEDECL   2				/* line is a "declare" statement */
74 #define LINECONN   3				/* line is a "connect" statement */
75 #define LINEEXPORT 4				/* line is an "export" statement */
76 #define LINEBEGIN  5				/* line is a "begincell" statement */
77 #define LINEEND    6				/* line is a "endcell" statement */
78 
79 /***************** ADDITIONAL ATTRIBUTES *************/
80 
81 #define NOATTR ((ATTR *)-1)
82 
83 typedef struct Iattr
84 {
85 	CHAR         *name;				/* name of attribute */
86 	INTBIG        type;				/* type of attribute */
87 	struct Iattr *equiv;			/* for associating lists */
88 	INTBIG        value;			/* value of attribute */
89 	struct Iattr *nextattr;			/* next in linked list */
90 } ATTR;
91 
92 /***************** PARSING OF "DECLARE" STATEMENTS *************/
93 
94 #define NOCOMPONENT ((COMPONENT *)-1)
95 
96 /* the meaning of COMPONENT->flag */
97 #define COMPSIZE    1				/* bit set if size was given */
98 #define COMPLOC     2				/* bit set if location was given */
99 #define COMPROT     4				/* bit set if rotation/transpose was given */
100 #define COMPATTR    8				/* bit set if attributes given */
101 
102 typedef struct Icomponent
103 {
104 	INTBIG sizex, sizey;			/* object size (in database units) */
105 	INTBIG locx, locy;				/* object location (in database units) */
106 	INTBIG rot, trans;				/* rotation and transpose */
107 	INTBIG flag;					/* valid information (see above) */
108 	CHAR  *name;
109 	ATTR  *firstattr;				/* list of attributes */
110 	struct Icomponent *assoc;		/* for comparing component lists */
111 	struct Icomponent *nextcomponent;
112 } COMPONENT;
113 
114 #define NOCOMPONENTDEC ((COMPONENTDEC *)-1)
115 
116 typedef struct Icomponentdec
117 {
118 	INTBIG count;
119 	CHAR *protoname;
120 	COMPONENT *firstcomponent;
121 } COMPONENTDEC;
122 
123 /***************** PARSING OF "CONNECT" STATEMENTS *************/
124 
125 #define NOCONS ((CONS *)-1)
126 
127 /* these match the "cli_linconops" in "conlin.c" */
128 #define GEQ     0					/* constraint demands greater than or equality */
129 #define EQUAL   1					/* constraint demands equality */
130 #define LEQ     2					/* constraint demands less than or equality */
131 
132 typedef struct Icons
133 {
134 	CHAR  *direction;				/* the constraint direction */
135 	INTBIG amount;					/* the constraint amount (in WHOLE units) */
136 	INTBIG flag;					/* 0: equal   1: geq   -1: leq */
137 	struct Icons *assoc;			/* associated constraint */
138 	struct Icons *nextcons;			/* next in list */
139 } CONS;
140 
141 #define NOCONNECTION ((CONNECTION *)-1)
142 
143 #define LAYERVALID    1				/* set if connecting arc type specified */
144 #define END1VALID     2				/* set if end 1 specified */
145 #define PORT1VALID    4				/* set if port 1 specified */
146 #define END2VALID     8				/* set if end 2 specified */
147 #define PORT2VALID   16				/* set if port 2 specified */
148 #define OFFSETVALID  32				/* set if arc offset specified */
149 #define WIDTHVALID   64				/* set if arc width specified */
150 #define ATTRVALID   128				/* set if attributes specified */
151 
152 typedef struct Iconnection
153 {
154 	CHAR  *layer;					/* the connecting arc type (optional) */
155 	INTBIG width;					/* the width of the arc (optional) */
156 	ATTR  *firstattr;				/* list of attributes (optional) */
157 	CHAR  *end1;					/* the node at end 1 */
158 	CHAR  *port1;					/* the port on the node at end 1 (optional) */
159 	CONS  *firstcons;				/* the constraints on the arc */
160 	INTBIG xoff, yoff;				/* the actual distance (optional) */
161 	CHAR  *end2;					/* the node at end 2 */
162 	CHAR  *port2;					/* the port on the node at end 2 (optional) */
163 	INTBIG flag;					/* bits saying what is valid in this list */
164 } CONNECTION;
165 
166 /***************** PARSING OF "EXPORT" STATEMENTS *************/
167 
168 #define NOEXPORT ((EXPORT *)-1)
169 
170 #define EXPCHAR      1				/* set if power/ground characteristics valid */
171 #define EXPATTR      2				/* set if attributes valid */
172 
173 typedef struct Iexport
174 {
175 	CHAR  *portname;				/* the exported port name */
176 	CHAR  *component;				/* the component source of the port */
177 	CHAR  *subport;					/* the subport on the exported component */
178 	INTBIG bits;					/* the characteristics/location of the port */
179 	ATTR  *firstattr;				/* list of attributes (optional) */
180 	INTBIG flag;					/* bits saying what is valid in list */
181 	struct Iexport *nextexport;		/* next in list */
182 } EXPORT;
183 
184 /***************** INTERFACE PROTOTYPES *************/
185 
186 void cli_linconinit(CONSTRAINT*);
187 void cli_linconterm(void);
188 void cli_linconsetmode(INTBIG, CHAR*[]);
189 INTBIG cli_linconrequest(CHAR*, INTBIG);
190 void cli_linconsolve(NODEPROTO*);
191 void cli_linconnewobject(INTBIG, INTBIG);
192 void cli_linconkillobject(INTBIG, INTBIG);
193 BOOLEAN cli_linconsetobject(INTBIG, INTBIG, INTBIG, INTBIG);
194 void cli_linconmodifynodeinst(NODEINST*, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);
195 void cli_linconmodifynodeinsts(INTBIG,NODEINST**, INTBIG*, INTBIG*, INTBIG*, INTBIG*, INTBIG*, INTBIG*);
196 void cli_linconmodifyarcinst(ARCINST*, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);
197 void cli_linconmodifyportproto(PORTPROTO*, NODEINST*, PORTPROTO*);
198 void cli_linconmodifynodeproto(NODEPROTO*);
199 void cli_linconmodifydescript(INTBIG, INTBIG, INTBIG, UINTBIG*);
200 void cli_linconnewlib(LIBRARY*);
201 void cli_linconkilllib(LIBRARY*);
202 void cli_linconnewvariable(INTBIG, INTBIG, INTBIG, INTBIG);
203 void cli_linconkillvariable(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, UINTBIG*);
204 void cli_linconmodifyvariable(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);
205 void cli_linconinsertvariable(INTBIG, INTBIG, INTBIG, INTBIG);
206 void cli_lincondeletevariable(INTBIG, INTBIG, INTBIG, INTBIG, INTBIG);
207 void cli_linconsetvariable(void);
208 extern COMCOMP cli_linconp;
209 
210 /***************** PROTOTYPES FOR INTERMODULE ROUTINES *************/
211 
212 void cli_maketextcell(NODEPROTO*);
213 void cli_highlightequivalent(GEOM*);
214 void cli_eq_solve(void);
215 void cli_eq_newnode(NODEINST*);
216 void cli_eq_newport(PORTPROTO*);
217 void cli_eq_newarc(ARCINST*);
218 void cli_eq_killarc(ARCINST*);
219 void cli_eq_killnode(NODEINST*);
220 void cli_eq_killport(PORTPROTO*);
221 void cli_eq_modarc(ARCINST*);
222 void cli_eq_modnode(NODEINST*);
223 void cli_eq_modport(PORTPROTO*);
224 void cli_eq_newvar(INTBIG, INTBIG, INTBIG);
225 void cli_eq_killvar(INTBIG, INTBIG, INTBIG);
226 INTBIG cli_linetype(CHAR*);
227 COMPONENTDEC *cli_parsecomp(CHAR*, BOOLEAN);
228 void cli_deletecomponentdec(COMPONENTDEC*);
229 WINDOWPART *cli_makeeditorwindow(CHAR*, INTBIG*, INTBIG*);
230 void cli_replaceendcell(CHAR*, WINDOWPART*);
231 EXPORT *cli_parseexport(CHAR*, BOOLEAN);
232 void cli_deleteexport(EXPORT*);
233 CONNECTION *cli_parseconn(CHAR*, BOOLEAN);
234 void cli_deleteconnection(CONNECTION*);
235 ARCINST *cli_findarcname(CHAR*);
236 NODEINST *cli_findnodename(CHAR*);
237 CHAR *cli_parsebegincell(CHAR*, BOOLEAN);
238 void cli_replacename(CHAR*, CHAR*);
239 BOOLEAN cli_pickwire(CONNECTION*, NODEINST**, PORTPROTO**, NODEINST**, PORTPROTO**, ARCPROTO**, INTBIG*, ARCINST*, NODEINST*, NODEINST*);
240 void cli_deletearcconstraint(ARCINST*, INTBIG, INTBIG, INTBIG);
241 BOOLEAN cli_addarcconstraint(ARCINST*, INTBIG, INTBIG, INTBIG, INTBIG);
242 void cli_solvecell(NODEPROTO*, BOOLEAN, BOOLEAN);
243 BOOLEAN cli_uniqueport(NODEINST*, PORTPROTO*);
244 void cli_deleteequivcon(ARCINST*);
245 void cli_changeequivcomp(NODEINST*);
246 
247 #if defined(__cplusplus) && !defined(ALLCPLUSPLUS)
248 }
249 #endif
250