1 /************************************************************
3 ** COPYRIGHT (C) 1993 UNIVERSITY OF PITTSBURGH
4 ** COPYRIGHT (C) 1996, 2004 GANNON UNIVERSITY
7 ** This software is distributed on an as-is basis
8 ** with no warranty implied or intended. No author
9 ** or distributor takes responsibility to anyone
10 ** regarding its use of or suitability.
12 ** The software may be distributed and modified
13 ** freely for academic and other non-commercial
14 ** use but may NOT be utilized or included in whole
15 ** or part within any commercial product.
17 ** This copyright notice must remain on all copies
18 ** and modified versions of this software.
20 ************************************************************/
24 /* ------------------------------------------------------------------------
25 * Common definitions for place and route spl 6/89
27 * ------------------------------------------------------------------------
30 #ifndef _ASG_NETWORK_H_
31 #define _ASG_NETWORK_H_
37 #include <sys/malloc.h>
45 #include <sys/types.h>
50 #include <unistd.h> /* for unlink() */
52 #include <X11/Intrinsic.h>
53 #include <X11/StringDefs.h>
54 #include <X11/Shell.h>
55 #include <X11/Xutil.h>
56 #include <X11/cursorfont.h>
57 #include <X11/Xproto.h>
58 #include <X11/Xatom.h>
65 #include "Xw/WorkSpace.h"
66 #include "Xw/PButton.h"
68 #include "Xw/Cascade.h"
69 #include "Xw/PopupMgr.h"
70 #include "Xw/MenuBtn.h"
71 #include "Xw/BBoard.h"
72 #include "Xw/TextEdit.h"
73 #include "Xw/Toggle.h"
77 #define P_tmpdir TMPDIR
81 #define malloc Tcl_Alloc
82 #define calloc(a,b) my_calloc(a, b) /* see utility.c */
83 #define free(a) Tcl_Free((char *)(a))
84 #define realloc(a,b) Tcl_Realloc((char *)(a), b)
86 #define fprintf tcl_printf /* defined by xcircuit */
87 #define fflush tcl_stdflush
90 /*----------------------------------------------------------------------*/
92 /*----------------------------------------------------------------------*/
95 /* #include "cursors.h" */
96 /* #include "colordefs.h" */
97 /* #include "menudep.h" */
99 /*----------------------------------------------------------------------*/
100 /* Function prototype declarations */
101 /*----------------------------------------------------------------------*/
102 #include "prototypes.h"
108 * Definition of the Design
109 * M is the set of all modules
110 * N is the set of all nets
111 * ST the set of system terminals
112 * T the set of sub-system terminals
113 * terms(module) : returns the subset of T for that module
114 * type(terminal(tUst)): returns its type (in, out, inout)
115 * postion-terminal(terminal(t)) : returns its (x,y) position
116 * net(terminal(tUst)) : returns the Net for this terminal
117 * size(module) : returns its x,y size
118 * side(terminal(t)) : returns (left, right, up, down)
123 (((x) == FALSE) ? "FALSE" : "TRUE")
125 /* only extract_tree in place.c uses these two: */
131 /* used in most files, but also defined in net.h */
133 #define MAX(a,b) (((a)>(b))?(a):(b))
134 #define MIN(a,b) (((a)<(b))?(a):(b))
137 /* I think the only hack that counts on these values is in
138 * utility.c rot_side(). Everyone else cases them out.
141 /* mod->flag values, used in placement */
147 /* the type of connection matrix built may be */
153 /* sides of module, clockwise order */
162 (((x) == LEFT) ? "LEFT":\
163 ((x) == RIGHT) ? "RIGHT":\
164 ((x) == UP) ? "UP" : "DOWN")
166 /* clockwise rotation amounts */
170 #define TWO_SEVENTY 3
173 (((x) == ZERO) ? "ZERO":\
174 ((x) == NINETY) ? "NINETY":\
175 ((x) == ONE_EIGHTY) ? "ONE_EIGHTY" : "TWO_SEVENTY")
178 #define NONE 0 /* used with those below for system net types */
180 /* directions of terminals */
181 #define IN 1 /* Left side of icon */
182 #define OUT 2 /* Right side of icon */
183 #define INOUT 3 /* Bottom of icon */
184 #define OUTIN 7 /* Top of icon */
190 (((x) == IN) ? "IN":\
191 ((x) == OUT) ? "OUT":\
192 ((x) == INOUT) ? "INOUT" :\
193 ((x) == OUTIN) ? "OUTIN" :"NONE")
195 #define ICON_SIZE 8 /* default object icon sizes are 8 x 8 for sced */
196 #define TERM_NAME_SIZE 32 /* size of strings for terminal names */
197 #define GATE_NAME_SIZE 10 /* Aesthetic limit on icon name sizes */
198 #define NET_NAME_SIZE 14 /* limit on net name sizes (fits _DUMMY_SIGNAL_) */
200 #define XCANVAS_SCALE_FACTOR 6 /* Used to scale XCanvas bitmaps (see -b flag) */
202 #define MAX_MOD 256 /* maximum number of modules */
204 #define CHANNEL_HEIGHT 48
205 #define CHANNEL_LENGTH 48
206 #define MAX_DEPTH 12 /* maximum length of module box string */
207 #define WHITE_SPACE 36 /* multiplier * # terms on a side for routing space */
208 #define CC_SPACE 48 /* min routing space between cross-coupled modules*/
211 * Rents rule: SIZE = A |Connections| ** B with .5 < A < 5 and .4 < B < .8
212 * I have no idea for good values.
213 * Try A = 1 B = .5 and Size =5 Conn = 25 (note values below are -1)
216 /* these are now just the default maxes, see the command line */
217 #define MAX_PARTITION_SIZE 4 /* 4 should we follow rent's rule? */
218 #define MAX_PARTITION_CONN 24 /* 24 connections from inside to outside */
219 #define DEF_PARTITION_RULE 3 /* enable the -c and -s flags for partitioning */
220 #define DEF_PARTITION_RATIO 3.0 /* sets the ratio used by rule number 2 */
221 #define CC_SEARCH_LEVEL 2 /* only look for modules that are cross
222 coupled to two levels of removal */
223 #define DEF_TURN_MODE 0 /* .5 Turns */
227 /* offsets around things for routing */
229 #define OUTSIDE_BORDER 100
231 /* default sizes for the virtual space tiles used for each partition: */
232 #define TILE_SPACE_X_LEN 15000
233 #define TILE_SPACE_Y_LEN 15000
234 #define TILE_SPACE_X_POS -5000
235 #define TILE_SPACE_Y_POS -5000
238 /* for routing and tile space support */
242 /*- begin psfigs support ------------------------------------------------------*/
243 #define XNOR_GATE "XNOR" /* Used to identify the Type of the module */
244 #define BUFFER_GATE "BUFFER"
245 #define INPUT_TERM "IN"
246 #define OUTPUT_TERM "OUT"
247 #define INOUT_TERM "INOUT"
248 #define OUTIN_TERM "OUTIN"
249 #define GENERIC_BLOCK "BLOCK"
252 /* Used within the placement algorithm; clip_null_gates() also uses this
253 when maintaining the integrity of the global "module_info[]" structure.
254 The integers typically note which partition numbers are referenced by
255 a particular module, there being one such structure for each module.
257 typedef struct info_struct
259 int in
, out
, used
, order
;
263 /*---------------------------------------------------------------
264 * Templates for major linked list data structures.
265 * We use a general paradigm of a linked list of "things"
266 * the list has a "this" field and a "next" field
267 * the "this" field is coerced into a pointer to a type "thing"
268 * the "next" field is coerced into a pointer to a list of "things"
269 * We then use generic list routines (in utility.c) to manipulate
271 *---------------------------------------------------------------
274 typedef struct term_struct term
; /* the terminals */
275 typedef struct mod_struct module
; /* the modules */
276 typedef struct net_struct net
; /* the nets */
277 typedef struct rng_struct rng
; /* the ranges of segments */
278 typedef struct clu_struct cluster
; /* the clusters of modules */
280 /* typedef struct list_struct list; Moved to 'list.h' */
281 typedef struct tnode_struct tnode
; /* for binary trees */
282 typedef struct term_list tlist
;
283 typedef struct mod_list mlist
;
284 typedef struct net_list nlist
;
285 typedef struct rng_list rlist
;
286 typedef struct cl_list clist
;
287 typedef struct cluster_tree ctree
;
289 typedef struct link_list llist
; /* for 2d linked lists */
290 /* typedef struct indexed_list ilist; Moved to 'list.h' */
294 /* terminals are where nets attach to modules */
297 int x_pos
; /* we will eventually have to look this up */
300 int side
; /* side of the module on which it apears */
301 int type
; /* direction in, out, inout, outin for this module */
302 net
*nt
; /* the net that this terminal belongs to */
306 /* modules are the "gates" both simple and complex, rectangles are assumed */
308 int index
; /* unique number */
309 char *name
; /* unique instance name */
310 char *type
; /* gate types will be our key for icons */
311 /* int dly_type; /* inertial or transport -- for simulation */
312 /* int delay; /* the delay time -- for simulation */
313 int x_pos
; /* we will determine this in "place" */
314 int y_pos
; /* we will determine this in "place" */
315 int x_size
; /* we will have to look this up */
316 int y_size
; /* we will have to look this up */
317 int flag
; /* flag for recursive marking */
318 int placed
; /* marks that the critter has been placed within a partition */
319 int rot
; /* rotation */
320 tile
*htile
; /* Tile in the horizontal routing space to which this module is assigned */
321 tile
*vtile
; /* Tile in the vertical routing space to which this module is assigned */
322 term
*primary_in
; /* the primary input terminal */
323 term
*primary_out
; /* the primary output terminal */
324 tlist
*terms
; /* the terminals on this module */
325 var
*fx
, *fy
; /* Fuzzy X and Fuzzy Y positions for this module */
330 /* clusters are collections of gates */
332 int index
; /* unique number */
333 int size
; /* number of elements in branch */
334 int connects
; /* number of connections external to the cluster */
335 module
*contents
; /* the module within this cluster (leaf nodes) */
339 /* a net is a list of terminals, one electrical node */
343 int type
; /* identify system terminal nets */
344 int rflag
; /* Routing status flag */
345 list
*expns
; /* Used in both local & global routing; */
346 list
*done
; /* Records expansions that are completed */
347 list
*route
; /* used in local routing */
351 /* a range of a segment is a 3-tuple */
353 int x
; /* "" : lower index in the other direction */
354 int y
; /* "" : upper index */
355 int c
; /* number of crossed wires */
358 /*-----------------------------------------------------*/
360 /* these are coerced to be binary trees of the sort below */
373 /*-----------------------------------------------------*/
388 /* Used to maintain clusters as they are built into and taken from a tree. */
411 /* this is different for 2 - d lists */
413 int index
; /* index */
414 list
*values
; /* list */
415 llist
*next
; /* next link */
420 /*---------------------------------------------------------------
422 *---------------------------------------------------------------