1 /************************************************************
3 ** COPYRIGHT (C) 2004 GANNON UNIVERSITY
6 ** This software is distributed on an as-is basis
7 ** with no warranty implied or intended. No author
8 ** or distributor takes responsibility to anyone
9 ** regarding its use of or suitability.
11 ** The software may be distributed and modified
12 ** freely for academic and other non-commercial
13 ** use but may NOT be utilized or included in whole
14 ** or part within any commercial product.
16 ** This copyright notice must remain on all copies
17 ** and modified versions of this software.
19 ************************************************************/
22 /* file netlist_structs.h */
26 #include <sys/malloc.h>
35 #include <sys/types.h>
40 #include <unistd.h> /* for unlink() */
42 #include <X11/Intrinsic.h>
43 #include <X11/StringDefs.h>
44 #include <X11/Shell.h>
45 #include <X11/Xutil.h>
46 #include <X11/cursorfont.h>
47 #include <X11/Xproto.h>
48 #include <X11/Xatom.h>
55 #include "Xw/WorkSpace.h"
56 #include "Xw/PButton.h"
58 #include "Xw/Cascade.h"
59 #include "Xw/PopupMgr.h"
60 #include "Xw/MenuBtn.h"
61 #include "Xw/BBoard.h"
62 #include "Xw/TextEdit.h"
63 #include "Xw/Toggle.h"
67 #define P_tmpdir TMPDIR
71 #define malloc Tcl_Alloc
72 #define calloc(a,b) my_calloc(a, b) /* see utility.c */
73 #define free(a) Tcl_Free((char *)(a))
74 #define realloc(a,b) Tcl_Realloc((char *)(a), b)
76 #define fprintf tcl_printf /* defined by xcircuit */
77 #define fflush tcl_stdflush
81 /*----------------------------------------------------------------------*/
83 /*----------------------------------------------------------------------*/
87 /*----------------------------------------------------------------------*/
88 /* Function prototype declarations */
89 /*----------------------------------------------------------------------*/
90 #include "prototypes.h"
97 * Definition of the Design
98 * M is the set of all modules
99 * N is the set of all nets
100 * SEE "netlistptr globallist" declared in "netlist.c"
101 * ST the set of system ports (terminals)
102 * T the set of sub-system terminals
103 * terms(module) : returns the subset of T for that module
104 * type(terminal(tUst)): returns its type (in, out, inout)
105 * postion-terminal(terminal(t)) : returns its (x,y) position
106 * net(terminal(tUst)) : returns the Net for this terminal
107 * size(module) : returns its x,y size
108 * side(terminal(t)) : returns (left, right, up, down)
113 (((x) == FALSE) ? "FALSE" : "TRUE")
115 /* only extract_tree in place.c uses these two: */
121 /* used in most files, but also defined in net.h */
123 #define MAX(a,b) (((a)>(b))?(a):(b))
124 #define MIN(a,b) (((a)<(b))?(a):(b))
127 /* I think the only hack that counts on these values is in
128 * utility.c rot_side(). Everyone else cases them out.
131 /* mod->flag values, used in placement */
137 /* the type of connection matrix built may be */
143 /* sides of module, clockwise order */
151 (((x) == LEFT) ? "LEFT":\
152 ((x) == RIGHT) ? "RIGHT":\
153 ((x) == UP) ? "UP" : "DOWN")
155 /* clockwise rotation amounts */
159 #define TWO_SEVENTY 3
162 (((x) == ZERO) ? "ZERO":\
163 ((x) == NINETY) ? "NINETY":\
164 ((x) == ONE_EIGHTY) ? "ONE_EIGHTY" : "TWO_SEVENTY")
167 #define NONE 0 /* used with those below for system net types */
169 /* directions of terminals */
170 #define IN 1 /* Left side of icon */
171 #define OUT 2 /* Right side of icon */
172 #define INOUT 3 /* Bottom of icon */
173 #define OUTIN 7 /* Top of icon */
179 (((x) == IN) ? "IN":\
180 ((x) == OUT) ? "OUT":\
181 ((x) == INOUT) ? "INOUT" :\
182 ((x) == OUTIN) ? "OUTIN" :"NONE")
184 #define ICON_SIZE 8 /* default object icon sizes are 8 x 8 for sced */
185 #define TERM_NAME_SIZE 32 /* size of strings for terminal names */
186 #define GATE_NAME_SIZE 10 /* Aesthetic limit on icon name sizes */
187 #define NET_NAME_SIZE 14 /* limit on net name sizes (fits _DUMMY_SIGNAL_) */
189 #define XCANVAS_SCALE_FACTOR 6 /* Used to scale XCanvas bitmaps (see -b flag) */
191 #define MAX_MOD 256 /* maximum number of modules */
193 #define CHANNEL_HEIGHT 48
194 #define CHANNEL_LENGTH 48
195 #define MAX_DEPTH 12 /* maximum length of module box string */
196 #define WHITE_SPACE 36 /* multiplier * # terms on a side for routing space */
197 #define CC_SPACE 48 /* min routing space between cross-coupled modules*/
200 * Rents rule: SIZE = A |Connections| ** B with .5 < A < 5 and .4 < B < .8
201 * I have no idea for good values.
202 * Try A = 1 B = .5 and Size =5 Conn = 25 (note values below are -1)
205 /* these are now just the default maxes, see the command line */
206 #define MAX_PARTITION_SIZE 4 /* 4 should we follow rent's rule? */
207 #define MAX_PARTITION_CONN 24 /* 24 connections from inside to outside */
208 #define DEF_PARTITION_RULE 3 /* enable the -c and -s flags for partitioning */
209 #define DEF_PARTITION_RATIO 3.0 /* sets the ratio used by rule number 2 */
210 #define CC_SEARCH_LEVEL 2 /* only look for modules that are cross
211 coupled to two levels of removal */
212 #define DEF_TURN_MODE 0 /* .5 Turns */
216 /* offsets around things for routing */
218 #define OUTSIDE_BORDER 100
220 /* default sizes for the virtual space tiles used for each partition: */
221 #define TILE_SPACE_X_LEN 15000
222 #define TILE_SPACE_Y_LEN 15000
223 #define TILE_SPACE_X_POS -5000
224 #define TILE_SPACE_Y_POS -5000
226 /* Used in routing, tile definitions */
230 /*- begin psfigs support ------------------------------------------------------*/
231 #define XNOR_GATE "XNOR" /* Used to identify the Type of the module */
232 #define BUFFER_GATE "BUFFER"
233 #define INPUT_TERM "IN"
234 #define OUTPUT_TERM "OUT"
235 #define INOUT_TERM "INOUT"
236 #define OUTIN_TERM "OUTIN"
237 #define GENERIC_BLOCK "BLOCK"
240 typedef struct info_struct
242 int in
, out
, used
, order
;
246 /*---------------------------------------------------------------
247 * Templates for major linked list data structures.
248 * We use a general paradigm of a linked list of "things"
249 * the list has a "this" field and a "next" field
250 * the "this" field is coerced into a pointer to a type "thing"
251 * the "next" field is coerced into a pointer to a list of "things"
252 * We then use generic list routines (in utility.c) to manipulate
254 *---------------------------------------------------------------
257 typedef struct mod_struct module
; /* the modules */
258 typedef struct net_struct net
; /* the nets */
259 typedef struct rng_struct rng
; /* the ranges of segments */
260 typedef struct clu_struct cluster
; /* the clusters of modules */
262 /* typedef struct list_struct list; Moved to 'list.h' */
263 typedef struct tnode_struct tnode
; /* for binary trees */
264 typedef struct mod_list mlist
;
265 typedef struct net_list nlist
;
266 typedef struct rng_list rlist
;
267 typedef struct cl_list clist
;
268 typedef struct cluster_tree ctree
;
270 typedef struct link_list llist
; /* for 2d linked lists */
271 /* typedef struct indexed_list ilist; Moved to 'list.h' */
273 /* PORTS AND TERMINALS
274 /* Structures for managing the placement and management of ports
275 /* ports AKA terminals */
277 /* List of object's I/O ports included from xcircuit.h:
278 /* typedef struct _Portlist *PortlistPtr;
279 /* typedef struct _Portlist
287 typedef struct term_struct term
; /* the terminals */
288 typedef struct term_list tlist
;
290 /* terminals are where nets attach to modules */
292 char *name
; /* Label associated with this terminal */
293 int x_pos
; /* we will eventually have to look this up */
295 module
*mod
; /* Module to which this terminal is connected */
296 int side
; /* side of the module on which the terminal apears */
297 /* int type; /* direction in, out, inout, outin for this module */
298 NetlistPtr nt
; /* the XC net that this terminal belongs to */
299 PortlistPtr pl
; /* the XC port that this terminal corresponds 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 */
326 CalllistPtr XCcl
; /* The XCircuit call list object that corresponds to this module. Note that the XCcl->callinst gets the object instance that corresponds to the module. */
331 /* clusters are collections of gates */
333 int index
; /* unique number */
334 int size
; /* number of elements in branch */
335 int connects
; /* number of connections external to the cluster */
336 module
*contents
; /* the module within this cluster (leaf nodes) */
340 /* a net is a list of terminals, one electrical or inductive node */
344 int type
; /* identify system terminal nets */
345 int rflag
; /* Routing status flag */
346 list
*expns
; /* Used in both local & global routing; */
347 list
*done
; /* Records expansions that are completed */
348 list
*route
; /* used in local routing */
352 /* a range of a segment is a 3-tuple */
354 int x
; /* "" : lower index in the other direction */
355 int y
; /* "" : upper index */
356 int c
; /* number of crossed wires */
359 /*-----------------------------------------------------*/
361 /* these are coerced to be binary trees of the sort below */
374 /*-----------------------------------------------------*/
389 /* 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 */
418 /*---------------------------------------------------------------
420 *---------------------------------------------------------------