Modified the UGetCursor() routine to return a valid response if the
[xcircuit.git] / asg / network1.h
blobdeba82dcfca202551fb0694fcada095f3a329987
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
6 #include "list.h"
7 #include "var.h"
8 #include "cstitch.h"
10 /*
11 * Definition of the Design
12 * M is the set of all modules
13 * N is the set of all nets
14 * ST the set of system terminals
15 * T the set of sub-system terminals
16 * terms(module) : returns the subset of T for that module
17 * type(terminal(tUst)): returns its type (in, out, inout)
18 * postion-terminal(terminal(t)) : returns its (x,y) position
19 * net(terminal(tUst)) : returns the Net for this terminal
20 * size(module) : returns its x,y size
21 * side(terminal(t)) : returns (left, right, up, down)
25 #define STF(x) \
26 (((x) == FALSE) ? "FALSE" : "TRUE")
28 /* only extract_tree in place.c uses these two: */
29 #define CHILDOK 2
30 #define CHILDNOTOK 3
31 #define LEAF 2
32 #define CLIPPED 4
34 /* used in most files, but also defined in net.h */
35 #ifndef MAX
36 #define MAX(a,b) (((a)>(b))?(a):(b))
37 #define MIN(a,b) (((a)<(b))?(a):(b))
38 #endif
40 /* I think the only hack that counts on these values is in
41 * utility.c rot_side(). Everyone else cases them out.
44 /* mod->flag values, used in placement */
45 #define SEEN 1
46 #define UNSEEN 0
47 #define UNPLACED -1
48 #define PLACED 1
50 /* the type of connection matrix built may be */
51 #define FORWARD 1
52 #define REVERSE -1
53 #define UNSIGNED 0
56 /* sides of module, clockwise order */
57 #define LEFT 0
58 #define UP 1
59 #define RIGHT 2
60 #define DOWN 3
62 #define SSIDE(x) \
63 (((x) == LEFT) ? "LEFT":\
64 ((x) == RIGHT) ? "RIGHT":\
65 ((x) == UP) ? "UP" : "DOWN")
67 /* clockwise rotation amounts */
68 #define ZERO 0
69 #define NINETY 1
70 #define ONE_EIGHTY 2
71 #define TWO_SEVENTY 3
73 #define SROT(x) \
74 (((x) == ZERO) ? "ZERO":\
75 ((x) == NINETY) ? "NINETY":\
76 ((x) == ONE_EIGHTY) ? "ONE_EIGHTY" : "TWO_SEVENTY")
79 #define NONE 0 /* used with those below for system net types */
81 /* directions of terminals */
82 #define IN 1 /* Left side of icon */
83 #define OUT 2 /* Right side of icon */
84 #define INOUT 3 /* Bottom of icon */
85 #define OUTIN 7 /* Top of icon */
86 #define GND 4
87 #define VDD 5
88 #define DUMMY 6
90 #define SNTYPE(x) \
91 (((x) == IN) ? "IN":\
92 ((x) == OUT) ? "OUT":\
93 ((x) == INOUT) ? "INOUT" :\
94 ((x) == OUTIN) ? "OUTIN" :"NONE")
96 #define ICON_SIZE 8 /* default object icon sizes are 8 x 8 for sced */
97 #define TERM_NAME_SIZE 32 /* size of strings for terminal names */
98 #define GATE_NAME_SIZE 10 /* Aesthetic limit on icon name sizes */
99 #define NET_NAME_SIZE 14 /* limit on net name sizes (fits _DUMMY_SIGNAL_) */
101 #define XCANVAS_SCALE_FACTOR 6 /* Used to scale XCanvas bitmaps (see -b flag) */
103 #define MAX_MOD 256 /* maximum number of modules */
105 #define CHANNEL_HEIGHT 48
106 #define CHANNEL_LENGTH 48
107 #define MAX_DEPTH 12 /* maximum length of module box string */
108 #define WHITE_SPACE 36 /* multiplier * # terms on a side for routing space */
109 #define CC_SPACE 48 /* min routing space between cross-coupled modules*/
112 * Rents rule: SIZE = A |Connections| ** B with .5 < A < 5 and .4 < B < .8
113 * I have no idea for good values.
114 * Try A = 1 B = .5 and Size =5 Conn = 25 (note values below are -1)
117 /* these are now just the default maxes, see the command line */
118 #define MAX_PARTITION_SIZE 4 /* 4 should we follow rent's rule? */
119 #define MAX_PARTITION_CONN 24 /* 24 connections from inside to outside */
120 #define DEF_PARTITION_RULE 3 /* enable the -c and -s flags for partitioning */
121 #define DEF_PARTITION_RATIO 3.0 /* sets the ratio used by rule number 2 */
122 #define CC_SEARCH_LEVEL 2 /* only look for modules that are cross
123 coupled to two levels of removal */
124 #define DEF_TURN_MODE 0 /* .5 Turns */
125 #define TIGHT 1
128 /* offsets around things for routing */
129 #define TERM_SIZE 2
130 #define OUTSIDE_BORDER 100
132 /* default sizes for the virtual space tiles used for each partition: */
133 #define TILE_SPACE_X_LEN 15000
134 #define TILE_SPACE_Y_LEN 15000
135 #define TILE_SPACE_X_POS -5000
136 #define TILE_SPACE_Y_POS -5000
139 /* types of obstacles */
140 #define MODULE 0
141 #define NET 1
142 #define ACTIVE_A 2
143 #define ACTIVE_B 3
145 #define STYPE(x) \
146 (((x) == ACTIVE_A) ? "ACTIVE_A" :\
147 ((x) == ACTIVE_B) ? "ACTIVE_B" :\
148 ((x) == MODULE) ? "MODULE" : "NET")
150 /* for add_obst */
151 #define HORZ 0
152 #define VERT 1
154 #define SDIR(x) \
155 (((x) == HORZ) ? "HORZ" : "VERT")
157 /* for init_actives */
158 /* signed sixteen bit max value */
159 #define INF 32767
160 /* perhaps 0x7FFFFFFF (32 bit max value) would be better ?*/
163 /* for end segment types */
164 #define LEFT_C 0
165 #define RIGHT_C 1
166 #define SEG 2
168 #define SSTYPE(x) \
169 (((x) == LEFT_C) ? "LEFT_C" :\
170 ((x) == RIGHT_C) ? "RIGHT_C" : "SEG")
172 /*- begin psfigs support ------------------------------------------------------*/
173 #define XNOR_GATE "XNOR" /* Used to identify the Type of the module */
174 #define BUFFER_GATE "BUFFER"
175 #define INPUT_TERM "IN"
176 #define OUTPUT_TERM "OUT"
177 #define INOUT_TERM "INOUT"
178 #define OUTIN_TERM "OUTIN"
179 #define GENERIC_BLOCK "BLOCK"
181 /* The following icons are directly supported:
182 (See "validate" in "psfigs.c") */
183 #define NOT_ 1
184 #define AND 2
185 #define NAND 3
186 #define OR 4
187 #define NOR 5
188 #define XOR 6
189 #define XNOR 7
190 #define BUFFER 8
191 #define INPUT_SYM 9
192 #define OUTPUT_SYM 10
193 #define INOUT_SYM 11
194 #define BLOCK 12
195 #define INVNOT_ 13
197 #define DONT_KNOW 20
199 #define CONTACT_WIDTH .350
200 #define ICON_LEN 4
201 #define ICON_HEIGHT 6
202 #define CIRCLE_SIZE .75
203 #define ANDARC_RAD 3.0625
204 #define ANDARC_THETA 69.09
205 #define ANDARC_CENTER_X_OFFSET 3.854 - 4.0
207 #define ORARC_RAD 3.75
208 #define ORARC_THETA 53.13
209 #define ORARC_CENTER_X_OFFSET 2.75 - 8.0
211 #define XOR_OFFSET .5
213 #define BUFFER_SIZE 6.0
214 #define GATE_LENGTH 8
215 #define GATE_HEIGHT 6
216 #define SYSTERM_SIZE 6
217 #define BLOCK_SPACES_PER_PIN 3
218 #define SPACES_PER_PIN 2
220 /*- end psfigs support ------------------------------------------------------*/
223 typedef struct info_struct
225 int in, out, used, order;
226 } info_type;
229 /*---------------------------------------------------------------
230 * Templates for major linked list data structures.
231 * We use a general paradigm of a linked list of "things"
232 * the list has a "this" field and a "next" field
233 * the "this" field is coerced into a pointer to a type "thing"
234 * the "next" field is coerced into a pointer to a list of "things"
235 * We then use generic list routines (in utility.c) to manipulate
236 * these.
237 *---------------------------------------------------------------
240 typedef struct term_struct term; /* the terminals */
241 typedef struct mod_struct module; /* the modules */
242 typedef struct net_struct net; /* the nets */
243 typedef struct obst_struct obst; /* the obstacles */
244 typedef struct act_struct act; /* the active segments */
245 typedef struct end_struct end; /* the endpoints of segments */
246 typedef struct rng_struct rng; /* the ranges of segments */
247 typedef struct clu_struct cluster; /* the clusters of modules */
249 /* typedef struct list_struct list; Moved to 'list.h' */
250 typedef struct tnode_struct tnode; /* for binary trees */
251 typedef struct term_list tlist;
252 typedef struct mod_list mlist;
253 typedef struct net_list nlist;
254 typedef struct obst_list olist;
255 typedef struct act_list alist;
256 typedef struct end_list elist;
257 typedef struct rng_list rlist;
258 typedef struct cl_list clist;
259 typedef struct cluster_tree ctree;
261 typedef struct link_list llist; /* for 2d linked lists */
262 /* typedef struct indexed_list ilist; Moved to 'list.h' */
265 struct term_struct
266 /* terminals are where nets attach to modules */
268 char *name;
269 int x_pos; /* we will eventually have to look this up */
270 int y_pos;
271 module *mod;
272 int side; /* side of the module on which it apears */
273 int type; /* direction in, out, inout, outin for this module */
274 net *nt; /* the net that this terminal belongs to */
277 struct mod_struct
278 /* modules are the "gates" both simple and complex, rectangles are assumed */
280 int index; /* unique number */
281 char *name; /* unique instance name */
282 char *type; /* gate types will be our key for icons */
283 int dly_type; /* inertial or transport -- for simulation */
284 int delay; /* the delay time -- for simulation */
285 int x_pos; /* we will determine this in "place" */
286 int y_pos; /* we will determine this in "place" */
287 int x_size; /* we will have to look this up */
288 int y_size; /* we will have to look this up */
289 int flag; /* flag for recursive marking */
290 int placed; /* marks that the critter has been placed within a partition */
291 int rot; /* rotation */
292 tile *htile; /* Tile in the horizontal routing space to which this module is assigned */
293 tile *vtile; /* Tile in the vertical routing space to which this module is assigned */
294 term *primary_in; /* the primary input terminal */
295 term *primary_out; /* the primary output terminal */
296 tlist *terms; /* the terminals on this module */
297 var *fx, *fy; /* Fuzzy X and Fuzzy Y positions for this module */
301 struct clu_struct
302 /* clusters are collections of gates */
304 int index; /* unique number */
305 int size; /* number of elements in branch */
306 int connects; /* number of connections external to the cluster */
307 module *contents; /* the module within this cluster (leaf nodes) */
310 struct net_struct
311 /* a net is a list of terminals, one electrical node */
313 char *name;
314 tlist *terms;
315 int type; /* identify system terminal nets */
316 int rflag; /* Routing status flag */
317 list *expns; /* Used in both local & global routing; */
318 list *done; /* Records expansions that are completed */
319 list *route; /* used in local routing */
322 struct obst_struct
323 /* an obstacle is a 5-tuple representing a line segment */
325 int i; /* index along the coordinate axis (vert or horz) */
326 int x; /* lower index in the other direction */
327 int y; /* upper index */
328 int type; /* one of MODULE, NET, ACTIVE_A or ACTIVE_B */
329 char *name; /* only used if it is a net */
332 struct act_struct
333 /* an active segment is a 10-tuple */
335 int b; /* wave number, number of bends in the path */
336 int c; /* number of crossed nets */
337 act* prev; /* pointer to previous/origninator of segment */
338 int i; /* description of this segment: index */
339 int x; /* "" : lower index in other direction */
340 int y; /* "" : upper index */
341 int d; /* one of LEFT RIGHT UP DOWN */
342 int type; /* one of MODULE, NET, ACTIVE_A or ACTIVE_B */
343 int expanded; /* one of TRUE, FALSE */
346 struct end_struct
347 /* an end segment is a 4-tuple */
349 int i; /* description of this segment: index */
350 int x; /* "" : lower index in the other direction */
351 int y; /* "" : upper index */
352 int type; /* one of LEFT_C RIGHT_C SEG */
355 struct rng_struct
356 /* a range of a segment is a 3-tuple */
358 int x; /* "" : lower index in the other direction */
359 int y; /* "" : upper index */
360 int c; /* number of crossed wires */
363 /*-----------------------------------------------------*/
364 struct tnode_struct
365 /* these are coerced to be binary trees of the sort below */
367 int *this;
368 tnode *left, *right;
371 struct cluster_tree
373 cluster *this;
374 ctree *left, *right;
378 /*-----------------------------------------------------*/
379 struct term_list
380 /* */
382 term *this;
383 tlist *next;
385 struct mod_list
386 /* */
388 module *this;
389 mlist *next;
392 struct cl_list
393 /* Used to maintain clusters as they are built into and taken from a tree. */
395 int index;
396 ctree *this;
397 clist *next;
400 struct net_list
401 /* */
403 net *this;
404 nlist *next;
407 struct obst_list
408 /* */
410 obst *this;
411 olist *next;
414 struct act_list
415 /* */
417 act *this;
418 alist *next;
421 struct end_list
422 /* */
424 end *this;
425 elist *next;
428 struct rng_list
429 /* */
431 rng *this;
432 rlist *next;
435 struct link_list
436 /* this is different for 2 - d lists */
438 int index; /* index */
439 list *values; /* list */
440 llist *next; /* next link */
443 /*---------------------------------------------------------------
444 * END OF FILE
445 *---------------------------------------------------------------