summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in4
-rw-r--r--def.c125
-rw-r--r--def.h13
-rw-r--r--graphics.c138
-rw-r--r--graphics.h31
-rw-r--r--lef.c13
-rw-r--r--lef.h5
-rw-r--r--main.c10
-rw-r--r--maze.c40
-rw-r--r--node.c69
-rw-r--r--node.h24
-rw-r--r--qconfig.c8
-rw-r--r--qconfig.h2
-rw-r--r--qrouter.c225
-rw-r--r--qrouter.h67
-rw-r--r--tclqrouter.c480
-rw-r--r--tkSimple.c11
-rw-r--r--tkSimple.h13
18 files changed, 847 insertions, 431 deletions
diff --git a/configure.in b/configure.in
index 88b8cba..7c28681 100644
--- a/configure.in
+++ b/configure.in
@@ -168,6 +168,10 @@ AC_ARG_WITH(libdir,
QROUTER_LIB_DIR=$withval
], [])
+if test "$GCC" = "yes" ; then
+ CFLAGS="${CFLAGS} -Wall -Werror"
+fi
+
# Interpreter Options
# =========================================
diff --git a/def.c b/def.c
index 8a60947..8ad2201 100644
--- a/def.c
+++ b/def.c
@@ -31,7 +31,7 @@
#include "qconfig.h"
#include "maze.h"
#include "lef.h"
-
+#include "def.h"
#ifndef TCL_QROUTER
@@ -40,7 +40,7 @@
/* found in tclqrouter.c and uses hash tables, greatly */
/* speeding up the read-in of large DEF files. */
-GATE
+static GATE
DefFindInstance(char *name)
{
GATE ginst;
@@ -52,11 +52,66 @@ DefFindInstance(char *name)
return NULL;
}
-/* For the non-Tcl version, this is an empty placeholder */
+/* For the non-Tcl version, these are empty placeholders */
+
+static void
+DefHashInit(void)
+{
+}
+
+static void
+DefHashInstance(GATE gateginfo)
+{
+}
+
+#else /* The versions using TCL hash tables */
+
+#include <tk.h>
+
+/* This hash table speeds up DEF file reading */
+
+static Tcl_HashTable InstanceTable;
+
+/*--------------------------------------------------------------*/
+/* Cell macro lookup based on the hash table */
+/*--------------------------------------------------------------*/
+
+static void
+DefHashInit(void)
+{
+ /* Initialize the macro hash table */
+
+ Tcl_InitHashTable(&InstanceTable, TCL_STRING_KEYS);
+}
+
+static GATE
+DefFindInstance(char *name)
+{
+ GATE ginst;
+ Tcl_HashEntry *entry;
+
+ entry = Tcl_FindHashEntry(&InstanceTable, name);
+ ginst = (entry) ? (GATE)Tcl_GetHashValue(entry) : NULL;
+ return ginst;
+}
+
+/*--------------------------------------------------------------*/
+/* Cell macro hash table generation */
+/* Given an instance record, create an entry in the hash table */
+/* for the instance name, with the record entry pointing to the */
+/* instance record. */
+/*--------------------------------------------------------------*/
-void
+static void
DefHashInstance(GATE gateginfo)
{
+ int new;
+ Tcl_HashEntry *entry;
+
+ entry = Tcl_CreateHashEntry(&InstanceTable,
+ gateginfo->gatename, &new);
+ if (entry != NULL)
+ Tcl_SetHashValue(entry, (ClientData)gateginfo);
}
#endif /* TCL_QROUTER */
@@ -81,7 +136,7 @@ DefHashInstance(GATE gateginfo)
*------------------------------------------------------------
*/
-char *
+static char *
DefAddRoutes(FILE *f, float oscale, NET net, char special)
{
char *token;
@@ -92,12 +147,12 @@ DefAddRoutes(FILE *f, float oscale, NET net, char special)
char initial = TRUE;
struct dseg_ locarea;
double x, y, lx, ly, w;
- int routeLayer, paintLayer;
+ int routeLayer = -1, paintLayer;
LefList lefl;
- NODE node;
ROUTE routednet = NULL;
- node = net->netnodes;
+ refp.x1 = 0;
+ refp.y1 = 0;
/* Set pitches and allocate memory for Obs[] if we haven't yet. */
set_num_channels();
@@ -385,11 +440,10 @@ endCoord:
*------------------------------------------------------------
*/
-void
+static void
DefReadGatePin(NET net, NODE node, char *instname, char *pinname, double *home)
{
- NODE node2;
- int i, j;
+ int i;
GATE gateginfo;
DSEG drect;
GATE g;
@@ -504,7 +558,7 @@ enum def_netprop_keys {
DEF_NETPROP_COVER, DEF_NETPROP_SHAPE, DEF_NETPROP_SOURCE,
DEF_NETPROP_WEIGHT, DEF_NETPROP_PROPERTY};
-void
+static void
DefReadNets(FILE *f, char *sname, float oscale, char special, int total)
{
char *token;
@@ -515,13 +569,7 @@ DefReadNets(FILE *f, char *sname, float oscale, char special, int total)
NET net;
int netidx;
- NODE node, node2;
- GATE gateginfo;
- DSEG drect;
- GATE g;
- double dx, dy;
- int gridx, gridy;
- DPOINT dp;
+ NODE node;
double home[MAX_LAYERS];
static char *net_keys[] = {
@@ -736,14 +784,12 @@ enum def_orient {DEF_NORTH, DEF_SOUTH, DEF_EAST, DEF_WEST,
DEF_FLIPPED_NORTH, DEF_FLIPPED_SOUTH, DEF_FLIPPED_EAST,
DEF_FLIPPED_WEST};
-int
+static int
DefReadLocation(gate, f, oscale)
GATE gate;
FILE *f;
float oscale;
{
- DSEG r;
- struct dseg_ tr;
int keyword;
char *token;
float x, y;
@@ -831,14 +877,13 @@ enum def_pins_prop_keys {
DEF_PINS_PROP_USE, DEF_PINS_PROP_FIXED,
DEF_PINS_PROP_COVER};
-void
+static void
DefReadPins(FILE *f, char *sname, float oscale, int total)
{
char *token;
char pinname[MAX_NAME_LEN];
- int keyword, subkey, values;
+ int keyword, subkey;
int processed = 0;
- int pinDir = PORT_CLASS_DEFAULT;
DSEG currect, drect;
GATE gate;
int curlayer;
@@ -871,15 +916,6 @@ DefReadPins(FILE *f, char *sname, float oscale, int total)
NULL
};
- static int lef_class_to_bitmask[] = {
- PORT_CLASS_DEFAULT,
- PORT_CLASS_INPUT,
- PORT_CLASS_TRISTATE,
- PORT_CLASS_OUTPUT,
- PORT_CLASS_BIDIRECTIONAL,
- PORT_CLASS_FEEDTHROUGH
- };
-
while ((token = LefNextToken(f, TRUE)) != NULL)
{
keyword = Lookup(token, pin_keys);
@@ -946,8 +982,6 @@ DefReadPins(FILE *f, char *sname, float oscale, int total)
subkey = Lookup(token, pin_classes);
if (subkey < 0)
LefError("Unknown pin class\n");
- else
- pinDir = lef_class_to_bitmask[subkey];
break;
case DEF_PINS_PROP_LAYER:
curlayer = LefReadLayer(f, FALSE);
@@ -1044,7 +1078,7 @@ enum def_vias_keys {DEF_VIAS_START = 0, DEF_VIAS_END};
enum def_vias_prop_keys {
DEF_VIAS_PROP_RECT = 0};
-void
+static void
DefReadVias(f, sname, oscale, total)
FILE *f;
char *sname;
@@ -1053,10 +1087,9 @@ DefReadVias(f, sname, oscale, total)
{
char *token;
char vianame[LEF_LINE_MAX];
- int keyword, subkey, values;
+ int keyword, subkey;
int processed = 0;
int curlayer;
- DSEG currect;
LefList lefl;
static char *via_keys[] = {
@@ -1188,11 +1221,11 @@ DefReadVias(f, sname, oscale, total)
enum def_block_keys {DEF_BLOCK_START = 0, DEF_BLOCK_END};
-void
+static void
DefReadBlockages(FILE *f, char *sname, float oscale, int total)
{
char *token;
- int keyword, subkey, values, i;
+ int keyword;
int processed = 0;
DSEG drect, rsrch;
LefList lefl;
@@ -1289,14 +1322,14 @@ enum def_prop_keys {
DEF_PROP_REGION, DEF_PROP_GENERATE, DEF_PROP_PROPERTY,
DEF_PROP_EEQMASTER};
-void
+static void
DefReadComponents(FILE *f, char *sname, float oscale, int total)
{
GATE gateginfo;
- GATE gate;
+ GATE gate = NULL;
char *token;
char usename[512];
- int keyword, subkey, values, i;
+ int keyword, subkey, i;
int processed = 0;
char OK;
DSEG drect, newrect;
@@ -1607,7 +1640,7 @@ DefRead(char *inName)
char filename[256];
char *token;
int keyword, dscale, total;
- int curlayer, channels;
+ int curlayer = -1, channels;
int v, h, i;
float oscale;
double start, step;
@@ -1672,6 +1705,8 @@ DefRead(char *inName)
lefCurrentLine = 0;
v = h = -1;
+ DefHashInit();
+
/* Read file contents */
while ((token = LefNextToken(f, TRUE)) != NULL)
diff --git a/def.h b/def.h
new file mode 100644
index 0000000..ef20aed
--- /dev/null
+++ b/def.h
@@ -0,0 +1,13 @@
+/*
+ * def.h --
+ *
+ * This file include the DEF I/O functions
+ *
+ */
+
+#ifndef _DEFINT_H
+#define _DEFINT_H
+
+float DefRead(char *inName);
+
+#endif /* _DEFINT_H */
diff --git a/graphics.c b/graphics.c
index 06c8624..f3dfbf2 100644
--- a/graphics.c
+++ b/graphics.c
@@ -23,8 +23,8 @@
/* Type declarations */
/*------------------------------*/
-void load_font(XFontStruct **);
-void createGC(Window, GC *, XFontStruct *);
+static void load_font(XFontStruct **);
+static void createGC(Window, GC *, XFontStruct *);
/*----------------------------------*/
/* Global variables for X11 drawing */
@@ -175,11 +175,10 @@ void highlight_starts(POINT glist) {
/* Highlight mask (in tan) */
/*--------------------------------------*/
-void highlight_mask() {
+void highlight_mask(void) {
int xspc, yspc, hspc;
int x, y;
- u_char value;
if (RMask == NULL) return;
@@ -204,13 +203,11 @@ void highlight_mask() {
/* Draw a map of obstructions and pins */
/*----------------------------------------------*/
-void
+static void
map_obstruction()
{
int xspc, yspc, hspc;
- int i, x, y, n, norm;
- u_char *Congestion;
- u_char value, maxval;
+ int i, x, y;
hspc = spacing >> 1;
@@ -249,7 +246,7 @@ map_obstruction()
/* Draw a map of actual route congestion */
/*----------------------------------------------*/
-void
+static void
map_congestion()
{
int xspc, yspc, hspc;
@@ -304,7 +301,7 @@ map_congestion()
/* Draw a map of route congestion estimated from net bounding boxes */
/*----------------------------------------------------------------------*/
-void
+static void
map_estimate()
{
NET net;
@@ -367,7 +364,6 @@ map_estimate()
void draw_net(NET net, u_char single, int *lastlayer) {
- int i, xspc, yspc;
int layer;
SEG seg;
ROUTE rt;
@@ -423,15 +419,104 @@ void draw_net(NET net, u_char single, int *lastlayer) {
}
/*--------------------------------------*/
+/* Draw one unrouted net on the display */
+/*--------------------------------------*/
+
+static void
+draw_net_nodes(NET net) {
+
+ NODE node;
+ SEG bboxlist = NULL; /* bbox list of all the nodes in the net */
+ SEG lastbbox, bboxit;
+ DPOINT tap;
+ int first, w, h, n;
+
+ /* Compute bbox for each node and draw it */
+ for (node = net->netnodes, n = 0; node != NULL; node = node->next, n++) {
+ if (bboxlist == NULL) {
+ lastbbox = bboxlist = (SEG)malloc(sizeof(struct seg_));
+ }
+ else {
+ lastbbox->next = (SEG)malloc(sizeof(struct seg_));
+ lastbbox = lastbbox->next;
+ }
+ lastbbox->next = NULL;
+ for (tap = node->taps, first = TRUE;
+ tap != NULL;
+ tap = tap->next, first = FALSE) {
+ if (first) {
+ lastbbox->x1 = lastbbox->x2 = tap->gridx;
+ lastbbox->y1 = lastbbox->y2 = tap->gridy;
+ }
+ else {
+ lastbbox->x1 = MIN(lastbbox->x1, tap->gridx);
+ lastbbox->x2 = MAX(lastbbox->x2, tap->gridx);
+ lastbbox->y1 = MIN(lastbbox->y1, tap->gridy);
+ lastbbox->y2 = MAX(lastbbox->y2, tap->gridy);
+ }
+ }
+
+ /* Convert to X coordinates */
+ lastbbox->x1 = spacing * (lastbbox->x1 + 1);
+ lastbbox->y1 = height - spacing * (lastbbox->y1 + 1);
+ lastbbox->x2 = spacing * (lastbbox->x2 + 1);
+ lastbbox->y2 = height - spacing * (lastbbox->y2 + 1);
+
+ /* Draw the bbox */
+ w = lastbbox->x2 - lastbbox->x1;
+ h = lastbbox->y1 - lastbbox->y2;
+ XDrawRectangle(dpy, buffer, gc,
+ lastbbox->x1, lastbbox->y1, w, h
+ );
+ }
+
+ /* if net->numnodes == 1 don't draw a wire */
+ if (n == 2) {
+ XDrawLine(
+ dpy, buffer, gc,
+ (bboxlist->x1 + bboxlist->x2)/2, (bboxlist->y1 + bboxlist->y2)/2,
+ (lastbbox->x1 + lastbbox->x2)/2, (lastbbox->y1 + lastbbox->y2)/2
+ );
+ }
+ else if (n > 2) {
+ /* Compute center point */
+ POINT midpoint = (POINT)malloc(sizeof(struct point_));
+ midpoint->x1 = midpoint->y1 = 0;
+
+ for (bboxit = bboxlist; bboxit != NULL; bboxit = bboxit->next) {
+ midpoint->x1 += (bboxit->x1 + bboxit->x2)/2;
+ midpoint->y1 += (bboxit->y1 + bboxit->y2)/2;
+ }
+ midpoint->x1 /= n;
+ midpoint->y1 /= n;
+
+ for (bboxit = bboxlist; bboxit != NULL; bboxit = bboxit->next) {
+ XDrawLine(
+ dpy, buffer, gc,
+ midpoint->x1, midpoint->y1,
+ (bboxit->x1 + bboxit->x2)/2, (bboxit->y1 + bboxit->y2)/2
+ );
+ }
+
+ free(midpoint);
+ }
+
+ for (bboxit = bboxlist; bboxit != NULL; bboxit = lastbbox) {
+ lastbbox = bboxit->next;
+ free(bboxit);
+ }
+}
+
+
+/*--------------------------------------*/
/* Graphical display of the layout */
/*--------------------------------------*/
void draw_layout() {
- int lastlayer, xspc, yspc, hspc;
- int i, x, y;
+ int lastlayer;
+ int i;
NET net;
- NETLIST nlist;
if (dpy == NULL) return;
else if (buffer == (Pixmap)NULL) return;
@@ -460,7 +545,7 @@ void draw_layout() {
// Draw all nets, much like "emit_routes" does when writing
// routes to the DEF file.
- if ((mapType & DRAW_MASK) == DRAW_ROUTES) {
+ if ((mapType & DRAW_ROUTES) != 0) {
lastlayer = -1;
for (i = 0; i < Numnets; i++) {
net = Nlnets[i];
@@ -468,6 +553,20 @@ void draw_layout() {
}
}
+ // Draw unrouted nets
+
+ if ((mapType & DRAW_UNROUTED) != 0) {
+ XSetForeground(dpy, gc, blackpix);
+ for (i = 0; i < Numnets; i++) {
+ net = Nlnets[i];
+ if (strcmp(net->netname, gndnet) != 0
+ && strcmp(net->netname, vddnet) != 0
+ &&net->routes == NULL) {
+ draw_net_nodes(net);
+ }
+ }
+ }
+
/* Copy double-buffer onto display window */
XCopyArea(dpy, buffer, win, gc, 0, 0, width, height, 0, 0);
}
@@ -488,7 +587,7 @@ int GUI_init(Tcl_Interp *interp)
tktop = Tk_MainWindow(interp);
if (tktop == NULL) {
tcl_printf(stderr, "No Top-level Tk window available. . .\n");
- return;
+ return TCL_ERROR;
}
qrouterdrawwin = (char *)Tcl_GetVar(interp, "drawwindow", TCL_GLOBAL_ONLY);
@@ -581,7 +680,8 @@ int QuitCallback(ClientData clientData, Tcl_Interp *interp,
/*----------------------------------------------------------------*/
-void load_font(XFontStruct **font_info)
+static void
+load_font(XFontStruct **font_info)
{
char *fontname = "9x15";
@@ -595,7 +695,8 @@ void load_font(XFontStruct **font_info)
/*----------------------------------------------------------------*/
-void createGC(Window win, GC *gc, XFontStruct *font_info)
+static void
+createGC(Window win, GC *gc, XFontStruct *font_info)
{
unsigned long valuemask = 0; /* ignore XGCvalues and use defaults */
XGCValues values;
@@ -668,7 +769,6 @@ int recalc_spacing()
void resize(Tk_Window tkwind, int locwidth, int locheight)
{
- Window window;
if ((locwidth == 0) || (locheight == 0)) return;
diff --git a/graphics.h b/graphics.h
new file mode 100644
index 0000000..d56921c
--- /dev/null
+++ b/graphics.h
@@ -0,0 +1,31 @@
+/*--------------------------------------------------------------*/
+/* graphics.h -- graphics routines */
+/*--------------------------------------------------------------*/
+
+#ifndef GRAPHICS_H
+
+#include <tk.h>
+
+/* TODO: Can we make this include independent from qrouter.h ? */
+#include "qrouter.h"
+
+void highlight(int, int);
+void highlight_source(void);
+void highlight_dest(void);
+void highlight_starts(POINT glist);
+void highlight_mask(void);
+
+void draw_net(NET net, u_char single, int *lastlayer);
+void draw_layout(void);
+
+int GUI_init(Tcl_Interp *interp);
+int QuitCallback(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+void expose(Tk_Window tkwind);
+int redraw(ClientData clientData, Tcl_Interp *interp, int objc,
+ Tcl_Obj *CONST objv[]);
+int recalc_spacing(void);
+void resize(Tk_Window tkwind, int locwidth, int locheight);
+
+#define GRAPHICS_H
+#endif
diff --git a/lef.c b/lef.c
index 0a66117..cdb6c1c 100644
--- a/lef.c
+++ b/lef.c
@@ -337,7 +337,7 @@ u_char
LefParseEndStatement(FILE *f, char *match)
{
char *token;
- int keyword, words;
+ int keyword;
char *match_name[2];
match_name[0] = match;
@@ -613,7 +613,7 @@ LefFindLayerNum(char *token)
*/
int
-LefGetMaxLayer()
+LefGetMaxLayer(void)
{
int maxlayer = -1;
LefList lefl;
@@ -646,7 +646,6 @@ double
LefGetRouteKeepout(int layer)
{
LefList lefl;
- double dist;
lefl = LefFindLayerByNum(layer);
if (lefl) {
@@ -1742,8 +1741,8 @@ LefReadMacro(f, mname, oscale)
/* Initial values */
pinNum = 0;
has_size = FALSE;
- lefBBox.x1 = 0.0;
- lefBBox.y1 = 0.0;
+ lefBBox.x2 = lefBBox.x1 = 0.0;
+ lefBBox.y2 = lefBBox.y1 = 0.0;
while ((token = LefNextToken(f, TRUE)) != NULL)
{
@@ -1956,11 +1955,11 @@ LefReadLayerSection(f, lname, mode, lefl)
LefList lefl; /* pointer to layer info */
{
char *token, *tp;
- int keyword, typekey, entries, i;
+ int keyword, typekey = -1, entries, i;
struct seg_ viaArea;
int curlayer = -1;
double dvalue, oscale;
- lefSpacingRule *newrule, *testrule;
+ lefSpacingRule *newrule = NULL, *testrule;
/* These are defined in the order of CLASS_* in lefInt.h */
static char *layer_type_keys[] = {
diff --git a/lef.h b/lef.h
index 6faf5f7..e65f372 100644
--- a/lef.h
+++ b/lef.h
@@ -107,6 +107,8 @@ extern LefList LefInfo;
/* Forward declarations */
+int Lookup(char *str, char*(table[]));
+
u_char LefParseEndStatement(FILE *f, char *match);
void LefSkipSection(FILE *f, char *match);
void LefEndStatement(FILE *f);
@@ -130,13 +132,12 @@ double LefGetRoutePitch(int layer);
double LefGetRouteOffset(int layer);
char *LefGetRouteName(int layer);
int LefGetRouteOrientation(int layer);
-int LefGetMaxLayer();
+int LefGetMaxLayer(void);
GATE LefFindInstance(char *name);
void LefHashCell(GATE gateginfo);
void LefRead(char *inName);
-float DefRead(char *inName);
void LefError(char *fmt, ...); /* Variable argument procedure requires */
/* parameter list. */
diff --git a/main.c b/main.c
index 3c37f90..f6fb6fd 100644
--- a/main.c
+++ b/main.c
@@ -40,11 +40,11 @@ main(int argc, char *argv[])
/*--------------------------------------------------------------*/
void
-highlight_source() {
+highlight_source(void) {
}
void
-highlight_dest() {
+highlight_dest(void) {
}
void
@@ -52,7 +52,7 @@ highlight_starts(POINT glist) {
}
void
-highlight_mask() {
+highlight_mask(void) {
}
void
@@ -64,10 +64,10 @@ draw_net(NET net, u_char single, int *lastlayer) {
}
void
-draw_layout() {
+draw_layout(void) {
}
int
-recalc_spacing() {
+recalc_spacing(void) {
return 0;
}
diff --git a/maze.c b/maze.c
index adb03df..d4b3616 100644
--- a/maze.c
+++ b/maze.c
@@ -233,7 +233,7 @@ void clear_non_source_targets(NET net, POINT *pushlist)
/* Remove PR_TARGET flags from all points belonging to a node */
/*--------------------------------------------------------------*/
-int clear_target_node(NODE node)
+void clear_target_node(NODE node)
{
int x, y, lay;
DPOINT ntap;
@@ -257,8 +257,9 @@ int clear_target_node(NODE node)
x = ntap->gridx;
y = ntap->gridy;
- if ((lay < Pinlayers) && Nodesav[lay][OGRID(x, y, lay)] ==
- (NODE)NULL || Nodesav[lay][OGRID(x, y, lay)] != node)
+ if (( (lay < Pinlayers)
+ && Nodesav[lay][OGRID(x, y, lay)] == (NODE)NULL
+ ) || Nodesav[lay][OGRID(x, y, lay)] != node)
continue;
Pr = &Obs2[lay][OGRID(x, y, lay)];
@@ -348,7 +349,7 @@ count_targets(NET net)
int set_node_to_net(NODE node, int newflags, POINT *pushlist, SEG bbox, u_char stage)
{
- int x, y, lay, k, obsnet = 0;
+ int x, y, lay, obsnet = 0;
int result = 0;
u_char found_one = (u_char)0;
POINT gpoint;
@@ -549,7 +550,7 @@ int disable_node_nets(NODE node)
int set_route_to_net(NET net, ROUTE rt, int newflags, POINT *pushlist,
SEG bbox, u_char stage)
{
- int x, y, lay, k;
+ int x, y, lay;
int result = 0;
POINT gpoint;
SEG seg;
@@ -625,7 +626,7 @@ int set_routes_to_net(NET net, int newflags, POINT *pushlist, SEG bbox,
u_char stage)
{
ROUTE rt;
- int result;
+ int result = 0;
for (rt = net->routes; rt; rt = rt->next)
result = set_route_to_net(net, rt, newflags, pushlist, bbox, stage);
@@ -639,7 +640,7 @@ int set_routes_to_net(NET net, int newflags, POINT *pushlist, SEG bbox,
/* list. Return 1 if the list got longer, 0 otherwise. */
/*--------------------------------------------------------------*/
-int
+static int
addcollidingnet(NETLIST *nlptr, int netnum)
{
NETLIST cnl;
@@ -673,7 +674,7 @@ NETLIST find_colliding(NET net, int *ripnum)
NETLIST nl = (NETLIST)NULL, cnl;
ROUTE rt;
SEG seg;
- int lay, i, x, y, orignet, rnum;
+ int lay, x, y, orignet, rnum;
/* Scan the routed points for recorded collisions. */
@@ -777,7 +778,6 @@ NETLIST find_colliding(NET net, int *ripnum)
u_char ripup_net(NET net, u_char restore)
{
int thisnet, oldnet, x, y, lay, dir;
- double sreq;
NODE node;
ROUTE rt;
SEG seg;
@@ -1148,7 +1148,6 @@ void writeback_segment(SEG seg, int netnum)
double dist;
int i, layer;
u_int sobs;
- NODE node;
if (seg->segtype == ST_VIA) {
Obs[seg->layer + 1][OGRID(seg->x1, seg->y1, seg->layer + 1)] = netnum;
@@ -1331,16 +1330,14 @@ void writeback_segment(SEG seg, int netnum)
int commit_proute(ROUTE rt, GRIDP *ept, u_char stage)
{
SEG seg, lseg;
- int i, j, k, lay, lay2, rval;
- int x, y;
- int dx, dy, dl;
+ int lay2, rval;
+ int dx = -1, dy = -1, dl;
u_int netnum, netobs1, netobs2, dir1, dir2;
u_char first = (u_char)1;
u_char dmask;
u_char pflags, p2flags;
PROUTE *Pr;
POINT newlr, newlr2, lrtop, lrend, lrnext, lrcur, lrprev;
- double sreq;
if (Verbose > 1) {
Flush(stdout);
@@ -1412,7 +1409,7 @@ int commit_proute(ROUTE rt, GRIDP *ept, u_char stage)
PROUTE *pri, *pri2;
int stacks = 1, stackheight;
int cx, cy, cl;
- int mincost, minx, miny, ci, ci2, collide, cost;
+ int mincost, minx = -1, miny = -1, collide, cost;
while (stacks != 0) { // Keep doing until all illegal stacks are gone
stacks = 0;
@@ -1554,7 +1551,7 @@ int commit_proute(ROUTE rt, GRIDP *ept, u_char stage)
}
if (pflags & PR_COST) {
pflags &= ~PR_COST;
- if (pflags & PR_PRED_DMASK != PR_PRED_NONE && cost < mincost) {
+ if ((pflags & PR_PRED_DMASK) != PR_PRED_NONE && cost < mincost) {
pri2 = &Obs2[dl][OGRID(cx, dy, dl)];
p2flags = pri2->flags;
if (p2flags & PR_COST) {
@@ -1601,7 +1598,7 @@ int commit_proute(ROUTE rt, GRIDP *ept, u_char stage)
// Check if point at pri2 is equal to position of
// lrppre->next. If so, bypass lrppre.
- if (lrnext = lrppre->next) {
+ if ((lrnext = lrppre->next) != NULL) {
if (lrnext->x1 == minx && lrnext->y1 == miny &&
lrnext->layer == dl) {
newlr->next = lrnext;
@@ -1731,9 +1728,10 @@ int commit_proute(ROUTE rt, GRIDP *ept, u_char stage)
pri = &Obs2[cl][OGRID(minx, miny, cl)];
pri2 = &Obs2[lrcur->layer][OGRID(lrcur->x1,
lrcur->y1, lrcur->layer)];
- if (((pri->flags & PR_SOURCE) && (pri2->flags & PR_SOURCE)) ||
- ((pri->flags & PR_TARGET) &&
- (pri2->flags & PR_TARGET)) && (lrcur == lrtop)) {
+ if ((((pri->flags & PR_SOURCE) && (pri2->flags & PR_SOURCE)) ||
+ ((pri->flags & PR_TARGET) && (pri2->flags & PR_TARGET)))
+ && (lrcur == lrtop)
+ ) {
lrtop = newlr;
lrend = newlr;
free(lrcur);
@@ -1996,7 +1994,7 @@ cleanup:
int writeback_route(ROUTE rt)
{
SEG seg;
- int i, lay2;
+ int lay2;
u_int netnum, dir1, dir2;
u_char first = (u_char)1;
diff --git a/node.c b/node.c
index b339617..7029c85 100644
--- a/node.c
+++ b/node.c
@@ -122,7 +122,7 @@ int altCompNets(NET *a, NET *b)
void create_netorder(u_char method)
{
- int i, j, max;
+ int i, j;
NET net;
STRING cn;
@@ -337,7 +337,7 @@ AUTHOR and DATE: steve beccue Tue Aug 04 2003
void print_nodes(char *filename)
{
FILE *o;
- int i, j;
+ int i;
NET net;
NODE node;
DPOINT dp;
@@ -599,7 +599,7 @@ void check_variable_pitch(int l, int *hptr, int *vptr)
/* to be revisited. */
/*--------------------------------------------------------------*/
-void create_obstructions_from_variable_pitch()
+void create_obstructions_from_variable_pitch(void)
{
int l, vnum, hnum, x, y;
@@ -656,7 +656,7 @@ void create_obstructions_from_variable_pitch()
/* the Nodeloc and Nodesav records. */
/*--------------------------------------------------------------*/
-void
+static void
disable_gridpos(int x, int y, int lay)
{
int apos = OGRID(x, y, lay);
@@ -676,7 +676,7 @@ disable_gridpos(int x, int y, int lay)
/*--------------------------------------------------------------*/
void
-count_pinlayers()
+count_pinlayers(void)
{
int j, l;
@@ -710,10 +710,10 @@ count_pinlayers()
/* the grid position. */
/*--------------------------------------------------------------*/
-void
+static void
check_obstruct(int gridx, int gridy, DSEG ds, double dx, double dy)
{
- int *obsptr;
+ u_int *obsptr;
float dist;
obsptr = &(Obs[ds->layer][OGRID(gridx, gridy, ds->layer)]);
@@ -773,7 +773,7 @@ check_obstruct(int gridx, int gridy, DSEG ds, double dx, double dy)
/* via placed at the position is or is not symmetric in X and Y */
/*--------------------------------------------------------------*/
-double get_via_clear(int lay, int horiz, DSEG rect) {
+static double get_via_clear(int lay, int horiz, DSEG rect) {
double vdelta, v2delta, mdelta, mwidth;
vdelta = LefGetViaWidth(lay, lay, 1 - horiz);
@@ -799,7 +799,7 @@ double get_via_clear(int lay, int horiz, DSEG rect) {
/* not vias. */
/*--------------------------------------------------------------*/
-double get_route_clear(int lay, DSEG rect) {
+static double get_route_clear(int lay, DSEG rect) {
double rdelta, mdelta, mwidth;
rdelta = LefGetRouteWidth(lay);
@@ -828,14 +828,13 @@ double get_route_clear(int lay, DSEG rect) {
/* this netlist. */
/*--------------------------------------------------------------*/
-void create_obstructions_from_gates()
+void create_obstructions_from_gates(void)
{
GATE g;
DSEG ds;
- int i, gridx, gridy, *obsptr;
+ int i, gridx, gridy;
double deltax, deltay, delta[MAX_LAYERS];
double dx, dy, deltaxy;
- float dist;
// Give a single net number to all obstructions, over the range of the
// number of known nets, so these positions cannot be routed through.
@@ -950,7 +949,7 @@ void create_obstructions_from_gates()
|| gridy >= NumChannelsY[ds->layer]) break;
if ((dy - EPS) >= (ds->y1 - deltay) && gridy >= 0) {
- double s, edist, xp, yp;
+ double s, edist = 0.0, xp, yp;
// Check Euclidean distance measure
s = LefGetRouteSpacing(ds->layer);
@@ -1052,7 +1051,7 @@ void create_obstructions_from_gates()
/* value, and so forth. */
/*--------------------------------------------------------------*/
-void expand_tap_geometry()
+void expand_tap_geometry(void)
{
DSEG ds, ds2;
GATE g;
@@ -1133,15 +1132,14 @@ void expand_tap_geometry()
/* Beccue. */
/*--------------------------------------------------------------*/
-void create_obstructions_inside_nodes()
+void create_obstructions_inside_nodes(void)
{
- NODE node, n2;
+ NODE node;
GATE g;
- DPOINT dp;
DSEG ds;
u_int dir, k;
- int i, gx, gy, gridx, gridy, net;
- double dx, dy, deltax, deltay;
+ int i, gridx, gridy;
+ double dx, dy;
float dist, xdist;
double offmaxx[MAX_LAYERS], offmaxy[MAX_LAYERS];
@@ -1367,14 +1365,13 @@ void create_obstructions_inside_nodes()
/*--------------------------------------------------------------*/
-void create_obstructions_outside_nodes()
+void create_obstructions_outside_nodes(void)
{
NODE node, n2;
GATE g;
- DPOINT dp;
DSEG ds;
u_int dir, k;
- int i, gx, gy, gridx, gridy, net;
+ int i, gridx, gridy;
double dx, dy, deltax, deltay;
float dist, xdist;
double offmaxx[MAX_LAYERS], offmaxy[MAX_LAYERS];
@@ -2164,9 +2161,8 @@ void create_obstructions_outside_nodes()
/* grid point. */
/*--------------------------------------------------------------*/
-void tap_to_tap_interactions()
+void tap_to_tap_interactions(void)
{
- NODE node;
GATE g;
DSEG ds;
struct dseg_ de;
@@ -2174,7 +2170,6 @@ void tap_to_tap_interactions()
int i, gridx, gridy, net, orignet, offset;
double dx, dy;
float dist;
- u_char errbox;
double deltax[MAX_LAYERS];
double deltay[MAX_LAYERS];
@@ -2189,9 +2184,6 @@ void tap_to_tap_interactions()
net = g->netnum[i];
if (net != 0) {
- // Get the node record associated with this pin.
- node = g->noderec[i];
-
for (ds = g->taps[i]; ds; ds = ds->next) {
mingridx = (int)((ds->x1 - Xlowerbound) / PitchX[ds->layer]) - 1;
@@ -2280,7 +2272,7 @@ make_routable(NODE node)
{
GATE g;
DSEG ds;
- int i, gridx, gridy, net;
+ int i, gridx, gridy;
double dx, dy;
/* The database is not organized to find tap points */
@@ -2342,16 +2334,14 @@ make_routable(NODE node)
/* AUTHOR: Tim Edwards, April 2013 */
/*--------------------------------------------------------------*/
-void adjust_stub_lengths()
+void adjust_stub_lengths(void)
{
- NODE node, n2;
+ NODE node;
GATE g;
- DPOINT dp;
DSEG ds, ds2;
struct dseg_ dt, de;
- u_int dir, k;
- int i, gx, gy, gridx, gridy, net, orignet;
- double dx, dy, wx, wy, s, dd;
+ int i, gridx, gridy, orignet;
+ double dx, dy, wx, wy, s;
float dist;
u_char errbox;
@@ -2817,23 +2807,18 @@ block_route(int x, int y, int lay, u_char dir)
void
find_route_blocks()
{
- NODE node;
GATE g;
// DPOINT dp;
- DSEG ds, ds2;
- struct dseg_ dt, de;
+ DSEG ds;
+ struct dseg_ dt;
int i, gridx, gridy;
double dx, dy, w, v, s, u;
float dist;
- u_char errbox;
for (g = Nlgates; g; g = g->next) {
for (i = 0; i < g->nodes; i++) {
if (g->netnum[i] != 0) {
- // Get the node record associated with this pin.
- node = g->noderec[i];
-
// Work through each rectangle in the tap geometry
for (ds = g->taps[i]; ds; ds = ds->next) {
diff --git a/node.h b/node.h
index 43ee94a..6f45fc6 100644
--- a/node.h
+++ b/node.h
@@ -12,18 +12,22 @@
void create_netorder(u_char method);
void find_bounding_box(NET net);
-void create_obstructions_inside_nodes();
-void create_obstructions_outside_nodes();
-void create_obstructions_from_gates();
-void create_obstructions_from_variable_pitch();
-void tap_to_tap_interactions();
-void make_routable(NODE node);
-void adjust_stub_lengths();
-void expand_tap_geometry();
-void block_route(int x, int y, int lay, u_char dir);
-
+void defineRouteTree(NET);
void print_nodes(char *filename);
void print_nlnets(char *filename);
+void count_reachable_taps();
+void check_variable_pitch(int, int *, int *);
+void create_obstructions_from_variable_pitch(void);
+void count_pinlayers(void);
+void create_obstructions_from_gates(void);
+void expand_tap_geometry(void);
+void create_obstructions_inside_nodes(void);
+void create_obstructions_outside_nodes(void);
+void tap_to_tap_interactions(void);
+void make_routable(NODE node);
+void adjust_stub_lengths(void);
+void block_route(int x, int y, int lay, u_char dir);
+void find_route_blocks();
#define NODE_H
#endif
diff --git a/qconfig.c b/qconfig.c
index 383927e..a743e20 100644
--- a/qconfig.c
+++ b/qconfig.c
@@ -13,6 +13,7 @@
#define _GNU_SOURCE // for strcasestr(), see man page
+#include <ctype.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
@@ -70,7 +71,7 @@ char *ViaY[MAX_LAYERS];
/*--------------------------------------------------------------*/
void
-post_config()
+post_config(void)
{
int i, h, v;
@@ -132,14 +133,13 @@ int read_config(FILE *fconfig, int is_info)
char carg;
double darg, darg2, darg3, darg4;
char sarg[MAX_LINE_LEN];
- size_t len = 0;
char line[MAX_LINE_LEN];
char *lineptr;
STRING dnr; // Do Not Route nets
STRING cn; // critical nets
STRING strl;
- GATE gateinfo; // gate information, pin location, etc
- DSEG grect, drect;
+ GATE gateinfo = NULL; // gate information, pin location, etc
+ DSEG drect;
if (Firstcall) {
for (i = 0; i < MAX_LAYERS; i++) {
diff --git a/qconfig.h b/qconfig.h
index 59fb9fb..8d73c55 100644
--- a/qconfig.h
+++ b/qconfig.h
@@ -41,7 +41,7 @@ extern char *ViaX[MAX_LAYERS];
extern char *ViaY[MAX_LAYERS];
int read_config(FILE *configfileptr, int is_info);
-void post_config();
+void post_config(void);
#define QCONFIG_H
#endif
diff --git a/qrouter.c b/qrouter.c
index f3706ed..ac53f4f 100644
--- a/qrouter.c
+++ b/qrouter.c
@@ -7,6 +7,7 @@
/* Beccue, 2003 */
/*--------------------------------------------------------------*/
+#include <ctype.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
@@ -18,6 +19,8 @@
#include "node.h"
#include "maze.h"
#include "lef.h"
+#include "def.h"
+#include "graphics.h"
int Pathon = -1;
int TotalRoutes = 0;
@@ -59,16 +62,27 @@ char DEFfilename[256];
ScaleRec Scales; // record of input and output scales
+/* Prototypes for some local functions */
+static void initMask(void);
+static void fillMask(u_char value);
+static int next_route_setup(struct routeinfo_ *iroute, u_char stage);
+static int route_setup(struct routeinfo_ *iroute, u_char stage);
+static int route_segs(struct routeinfo_ *iroute, u_char stage, u_char graphdebug);
+static ROUTE createemptyroute(void);
+static void emit_routes(char *filename, double oscale, int iscale);
+static void helpmessage(void);
+
+
/*--------------------------------------------------------------*/
/* Check track pitch and set the number of channels (may be */
/* called from DefRead) */
/*--------------------------------------------------------------*/
-int set_num_channels()
+int set_num_channels(void)
{
int i;
- if (NumChannelsX[0] != 0) return; /* Already been called */
+ if (NumChannelsX[0] != 0) return 0; /* Already been called */
for (i = 0; i < Num_layers; i++) {
if (PitchX[i] == 0.0 || PitchY[i] == 0.0) {
@@ -104,11 +118,11 @@ int set_num_channels()
/* Allocate the Obs[] array (may be called from DefRead) */
/*--------------------------------------------------------------*/
-int allocate_obs_array()
+int allocate_obs_array(void)
{
int i;
- if (Obs[0] != NULL) return; /* Already been called */
+ if (Obs[0] != NULL) return 0; /* Already been called */
for (i = 0; i < Num_layers; i++) {
Obs[i] = (u_int *)calloc(NumChannelsX[i] * NumChannelsY[i],
@@ -150,17 +164,13 @@ countlist(NETLIST net)
int
runqrouter(int argc, char *argv[])
{
- int i, j, result;
- int length, width;
- FILE *l, *configFILEptr, *fptr, *infoFILEptr;
- u_int u;
+ int i;
+ FILE *configFILEptr, *infoFILEptr;
static char configdefault[] = CONFIGFILENAME;
char *configfile = configdefault;
char *infofile = NULL;
- char *dotptr, *sptr;
+ char *dotptr;
char Filename[256];
- double sreq;
- NET net;
u_char readconfig = FALSE;
Scales.iscale = 1;
@@ -319,7 +329,7 @@ runqrouter(int argc, char *argv[])
/* Free up memory in preparation for reading another DEF file */
/*--------------------------------------------------------------*/
-void reinitialize()
+static void reinitialize()
{
int i;
NETLIST nl;
@@ -439,7 +449,7 @@ void reinitialize()
/* of the layout, components, and nets are known. */
/*--------------------------------------------------------------*/
-int post_def_setup()
+static int post_def_setup()
{
NET net;
int i;
@@ -737,8 +747,9 @@ int write_def(char *filename)
/* a width. */
/*--------------------------------------------------------------*/
-void pathstart(FILE *cmd, int layer, int x, int y, u_char special, double oscale,
- double invscale, u_char horizontal)
+static void
+pathstart(FILE *cmd, int layer, int x, int y, u_char special, double oscale,
+ double invscale, u_char horizontal)
{
if (Pathon == 1) {
Fprintf( stderr, "pathstart(): Major error. Started a new "
@@ -780,8 +791,9 @@ void pathstart(FILE *cmd, int layer, int x, int y, u_char special, double oscale
/* SIDE EFFECTS: */
/*--------------------------------------------------------------*/
-void pathto(FILE *cmd, int x, int y, int horizontal, int lastx, int lasty,
- double invscale)
+static void
+pathto(FILE *cmd, int x, int y, int horizontal, int lastx, int lasty,
+ double invscale)
{
if (Pathon <= 0) {
Fprintf(stderr, "pathto(): Major error. Added to a "
@@ -824,8 +836,9 @@ void pathto(FILE *cmd, int x, int y, int horizontal, int lastx, int lasty,
/* SIDE EFFECTS: */
/*--------------------------------------------------------------*/
-void pathvia(FILE *cmd, int layer, int x, int y, int lastx, int lasty,
- int gridx, int gridy, double invscale)
+static void
+pathvia(FILE *cmd, int layer, int x, int y, int lastx, int lasty,
+ int gridx, int gridy, double invscale)
{
char *s;
char checkersign = (gridx + gridy + layer) & 0x01;
@@ -1002,6 +1015,113 @@ void print_nlgates( char *filename )
}
} /* print_nlgates() */
+
+/*--------------------------------------------------------------*/
+/* print_net - print info about the net to stdout */
+/* */
+/* ARGS: net to print info about */
+/* RETURNS: nothing */
+/* SIDE EFFECTS: */
+/*--------------------------------------------------------------*/
+
+void print_net(NET net) {
+ NODE node;
+ DPOINT tap;
+ int i, first;
+
+ Fprintf(stdout, "Net %d: %s", net->netnum, net->netname);
+ for (node = net->netnodes; node != NULL; node = node->next) {
+ Fprintf(stdout, "\n Node %d: \n Taps: ", node->nodenum);
+ for (tap = node->taps, i = 0, first = TRUE;
+ tap != NULL;
+ tap = tap->next, i = (i + 1) % 4, first = FALSE) {
+ Fprintf(stdout, "%sL%d:(%.2lf,%.2lf)",
+ (i == 0 ? (first ? "" : "\n ") : " "),
+ tap->layer, tap->x, tap->y
+ );
+ }
+ Fprintf(stdout, "\n Tap extends: ");
+ for (tap = node->extend, i = 0, first = TRUE;
+ tap != NULL;
+ tap = tap->next, i = (i + 1) % 4, first = FALSE) {
+ Fprintf(stdout, "%sL%d:(%.2lf,%.2lf)",
+ (i == 0 ? (first ? "" : "\n ") : " "),
+ tap->layer, tap->x, tap->y
+ );
+ }
+ }
+ Fprintf(stdout, "\n bbox: (%d,%d)-(%d,%d)\n",
+ net->xmin, net->ymin, net->xmax, net->ymax
+ );
+}
+
+
+/*--------------------------------------------------------------*/
+/* print_gate - print info about the net to stdout */
+/* */
+/* ARGS: gate to print info about */
+/* RETURNS: nothing */
+/* SIDE EFFECTS: */
+/*--------------------------------------------------------------*/
+
+void print_gate(GATE gate) {
+ int i, j, first;
+ DSEG seg;
+ NODE node;
+ DPOINT tap;
+
+ Fprintf(stdout, "Gate %s\n", gate->gatename);
+ Fprintf(stdout, " Loc: (%.2lf, %.2lf), WxH: %.2lfx%.2lf\n",
+ gate->placedX, gate->placedY, gate->width, gate->height
+ );
+ Fprintf(stdout, " Pins");
+ for (i = 0; i < gate->nodes; i++) {
+ Fprintf(stdout, "\n Pin %s, net %d\n",
+ gate->node[i], gate->netnum[i]
+ );
+ Fprintf(stdout, " Segs: ");
+ for (seg = gate->taps[i], j = 0, first = TRUE;
+ seg != NULL;
+ seg = seg->next, j = (j + 1) % 3, first = FALSE) {
+ Fprintf(stdout, "%sL%d:(%.2lf,%.2lf)-(%.2lf,%.2lf)",
+ (j == 0 ? (first ? "" : "\n ") : " "),
+ seg->layer, seg->x1, seg->y1, seg->x2, seg->y2
+ );
+ }
+ if ((node = gate->noderec[i]) != NULL) {
+ Fprintf(stdout, "\n Taps: ");
+ for (tap = node->taps, j = 0, first = TRUE;
+ tap != NULL;
+ tap = tap->next, j = (j + 1) % 4, first = FALSE) {
+ Fprintf(stdout, "%sL%d:(%.2lf,%.2lf)",
+ (j == 0 ? (first ? "" : "\n ") : " "),
+ tap->layer, tap->x, tap->y
+ );
+ }
+ Fprintf(stdout, "\n Tap extends: ");
+ for (tap = node->extend, j = 0, first = TRUE;
+ tap != NULL;
+ tap = tap->next, j = (j + 1) % 4, first = FALSE) {
+ Fprintf(stdout, "%sL%d:(%.2lf,%.2lf)",
+ (j == 0 ? (first ? "" : "\n ") : " "),
+ tap->layer, tap->x, tap->y
+ );
+ }
+ }
+ }
+ Fprintf(stdout, "\n Obstructions: ");
+ for (seg = gate->obs, j = 0, first = TRUE;
+ seg != NULL;
+ seg = seg->next, j = (j + 1) % 3, first = FALSE) {
+ Fprintf(stdout, "%sL%d:(%.2lf,%.2lf)-(%.2lf,%.2lf)",
+ (j == 0 ? (first ? "" : "\n ") : " "),
+ seg->layer, seg->x1, seg->y1, seg->x2, seg->y2
+ );
+ }
+ Fprintf(stdout, "\n");
+}
+
+
/*--------------------------------------------------------------*/
/* getnettoroute - get a net to route */
/* */
@@ -1046,7 +1166,7 @@ NET getnettoroute(int order)
/* Return the number of nets ripped up */
/*--------------------------------------------------------------*/
-int ripup_colliding(NET net)
+static int ripup_colliding(NET net)
{
NETLIST nl, nl2, fn;
int ripped;
@@ -1170,9 +1290,9 @@ int route_net_ripup(NET net, u_char graphdebug)
int
dosecondstage(u_char graphdebug, u_char singlestep)
{
- int failcount, origcount, result, maxtries, lasttries;
+ int failcount, origcount, result, maxtries;
NET net;
- NETLIST nl, nl2, fn;
+ NETLIST nl, nl2;
NETLIST Abandoned; // Abandoned routes---not even trying any more.
ROUTE rt, rt2;
SEG seg;
@@ -1372,7 +1492,7 @@ dosecondstage(u_char graphdebug, u_char singlestep)
/* initMask() --- */
/*--------------------------------------------------------------*/
-void initMask()
+static void initMask(void)
{
RMask = (u_char *)calloc(NumChannelsX[0] * NumChannelsY[0],
sizeof(u_char));
@@ -1386,7 +1506,7 @@ void initMask()
/* Fill mask around the area of a vertical line */
/*--------------------------------------------------------------*/
-void
+static void
create_vbranch_mask(int x, int y1, int y2, u_char slack, u_char halo)
{
int gx1, gx2, gy1, gy2;
@@ -1435,7 +1555,7 @@ create_vbranch_mask(int x, int y1, int y2, u_char slack, u_char halo)
/* Fill mask around the area of a horizontal line */
/*--------------------------------------------------------------*/
-void
+static void
create_hbranch_mask(int y, int x1, int x2, u_char slack, u_char halo)
{
int gx1, gx2, gy1, gy2;
@@ -1491,7 +1611,7 @@ create_hbranch_mask(int y, int x1, int x2, u_char slack, u_char halo)
/* route track for each pass, up to "halo". */
/*--------------------------------------------------------------*/
-void createBboxMask(NET net, u_char halo)
+static void createBboxMask(NET net, u_char halo)
{
int xmin, ymin, xmax, ymax;
int i, j, gx1, gy1, gx2, gy2;
@@ -1543,9 +1663,9 @@ void createBboxMask(NET net, u_char halo)
/* best location for the trunk route. */
/*--------------------------------------------------------------*/
-int analyzeCongestion(int ycent, int ymin, int ymax, int xmin, int xmax)
+static int analyzeCongestion(int ycent, int ymin, int ymax, int xmin, int xmax)
{
- int x, y, i, minidx, sidx, n, o;
+ int x, y, i, minidx = -1, sidx, n;
int *score, minscore;
score = (int *)malloc((ymax - ymin + 1) * sizeof(int));
@@ -1601,14 +1721,13 @@ int analyzeCongestion(int ycent, int ymin, int ymax, int xmin, int xmax)
/* congestion analysis. */
/*--------------------------------------------------------------*/
-void createMask(NET net, u_char slack, u_char halo)
+static void createMask(NET net, u_char slack, u_char halo)
{
NODE n1, n2;
- DPOINT d1tap, d2tap, dtap;
- int i, j, orient, l, v;
+ DPOINT dtap;
+ int i, j, orient;
int dx, dy, gx1, gx2, gy1, gy2;
int xcent, ycent, xmin, ymin, xmax, ymax;
- int branchx, branchy;
fillMask((u_char)halo);
@@ -1787,7 +1906,7 @@ void createMask(NET net, u_char slack, u_char halo)
/* bad guess about the optimal route positions. */
/*--------------------------------------------------------------*/
-void fillMask(u_char value) {
+static void fillMask(u_char value) {
memset((void *)RMask, (int)value,
(size_t)(NumChannelsX[0] * NumChannelsY[0]
* sizeof(u_char)));
@@ -1926,7 +2045,7 @@ int doroute(NET net, u_char stage, u_char graphdebug)
/* to a single subroutine. */
/*--------------------------------------------------------------*/
-void unable_to_route(char *netname, NODE node, unsigned char forced)
+static void unable_to_route(char *netname, NODE node, unsigned char forced)
{
if (node)
Fprintf(stderr, "Node %s of net %s has no tap points---",
@@ -1946,7 +2065,7 @@ void unable_to_route(char *netname, NODE node, unsigned char forced)
/* */
/*--------------------------------------------------------------*/
-int next_route_setup(struct routeinfo_ *iroute, u_char stage)
+static int next_route_setup(struct routeinfo_ *iroute, u_char stage)
{
ROUTE rt;
NODE node;
@@ -2055,7 +2174,7 @@ int next_route_setup(struct routeinfo_ *iroute, u_char stage)
/* */
/*--------------------------------------------------------------*/
-int route_setup(struct routeinfo_ *iroute, u_char stage)
+static int route_setup(struct routeinfo_ *iroute, u_char stage)
{
POINT gpoint;
int i, j;
@@ -2274,12 +2393,10 @@ int route_setup(struct routeinfo_ *iroute, u_char stage)
/* AUTHOR and DATE: steve beccue Fri Aug 8 */
/*--------------------------------------------------------------*/
-int route_segs(struct routeinfo_ *iroute, u_char stage, u_char graphdebug)
+static int route_segs(struct routeinfo_ *iroute, u_char stage, u_char graphdebug)
{
POINT gpoint, gunproc;
- SEG seg;
- int i, j, k, o;
- int x, y;
+ int i, o;
int pass, maskpass;
u_int forbid;
GRIDP best, curpt;
@@ -2308,7 +2425,7 @@ int route_segs(struct routeinfo_ *iroute, u_char stage, u_char graphdebug)
Fprintf(stdout, " (maxcost is %d)\n", iroute->maxcost);
}
- while (gpoint = iroute->glist) {
+ while ((gpoint = iroute->glist) != NULL) {
iroute->glist = gpoint->next;
@@ -2581,7 +2698,7 @@ done:
/* AUTHOR and DATE: steve beccue Fri Aug 8 */
/*--------------------------------------------------------------*/
-ROUTE createemptyroute()
+static ROUTE createemptyroute(void)
{
ROUTE rt;
@@ -2592,7 +2709,7 @@ ROUTE createemptyroute()
rt->next = (ROUTE)NULL;
return rt;
-} /* createemptyroute() */
+} /* createemptyroute(void) */
/*--------------------------------------------------------------*/
/* cleanup_net -- */
@@ -2607,11 +2724,11 @@ ROUTE createemptyroute()
/* the route to the neighboring via. */
/*--------------------------------------------------------------*/
-void cleanup_net(NET net)
+static void cleanup_net(NET net)
{
SEG segf, segl, seg;
ROUTE rt, rt2;
- int ls, lf, ll, layer, lastrlayer, lastlayer;
+ int ls, lf = 0, ll = 0, layer, lastrlayer, lastlayer;
u_char fcheck, lcheck, fixed;
u_char xcheck, ycheck;
@@ -2798,18 +2915,17 @@ void cleanup_net(NET net)
/* stub connection. */
/*--------------------------------------------------------------*/
-void
+static void
emit_routed_net(FILE *Cmd, NET net, u_char special, double oscale, int iscale)
{
SEG seg, saveseg, lastseg, prevseg;
ROUTE rt;
u_int dir1, dir2, tdir;
- int i, layer;
- int x, y, x2, y2;
+ int layer;
+ int x = 0, y = 0, x2, y2;
double dc;
- int lastx, lasty, lastlay;
+ int lastx = -1, lasty = -1, lastlay;
int horizontal;
- DPOINT dp1, dp2;
float offset1, offset2;
u_char cancel, segtype;
double invscale = (double)(1.0 / (double)iscale);
@@ -3641,13 +3757,13 @@ emit_routed_net(FILE *Cmd, NET net, u_char special, double oscale, int iscale)
/* AUTHOR and DATE: steve beccue Mon Aug 11 2003 */
/*--------------------------------------------------------------*/
-void emit_routes(char *filename, double oscale, int iscale)
+static void emit_routes(char *filename, double oscale, int iscale)
{
FILE *Cmd;
int i, j, numnets, stubroutes;
- char line[MAX_LINE_LEN + 1], *lptr;
+ char line[MAX_LINE_LEN + 1], *lptr = NULL;
char netname[MAX_NAME_LEN];
- NET net;
+ NET net = NULL;
ROUTE rt;
char newDEFfile[256];
FILE *fdef;
@@ -3715,7 +3831,6 @@ void emit_routes(char *filename, double oscale, int iscale)
for (i = 0; i < numnets; i++) {
if (errcond == TRUE) break;
- netname[0] == '\0';
while (fgets(line, MAX_LINE_LEN, fdef) != NULL) {
if ((lptr = strchr(line, ';')) != NULL) {
*lptr = '\n';
@@ -3848,7 +3963,7 @@ void emit_routes(char *filename, double oscale, int iscale)
/* */
/*--------------------------------------------------------------*/
-void helpmessage()
+static void helpmessage(void)
{
if (Verbose > 0) {
Fprintf(stdout, "qrouter - maze router by Tim Edwards\n\n");
diff --git a/qrouter.h b/qrouter.h
index 4ba1d10..56d4876 100644
--- a/qrouter.h
+++ b/qrouter.h
@@ -337,7 +337,8 @@ struct routeinfo_ {
#define DRAW_NONE 0x0 // Draw only the background map
#define DRAW_ROUTES 0x4 // Draw routes on top of background map
-#define DRAW_MASK 0x4
+#define DRAW_UNROUTED 0x8 // Draw unrouted nets on top of background map
+#define DRAW_MASK 0xc
// Mask types (values other than 255 are interpreted as "slack" value)
#define MASK_MINIMUM (u_char)0 // No slack
@@ -412,59 +413,33 @@ extern char *gndnet;
/* Function prototypes */
-extern int set_num_channels();
-extern int allocate_obs_array();
+int set_num_channels(void);
+int allocate_obs_array(void);
+int countlist(NETLIST net);
+int runqrouter(int argc, char *argv[]);
-void check_variable_pitch(int, int *, int *);
-
-NET getnettoroute();
-int dofirststage(u_char graphdebug, int debug_netnum);
-int dosecondstage(u_char graphdebug, u_char singlestep);
-int route_net_ripup(NET net, u_char graphdebug);
-
-void read_lef(char *filename);
void read_def(char *filename);
+int dofirststage(u_char graphdebug, int debug_netnum);
int write_def(char *filename);
-int doroute(NET net, u_char stage, u_char graphdebug);
-int route_setup(struct routeinfo_ *iroute, u_char stage);
-int next_route_setup(struct routeinfo_ *iroute, u_char stage);
-int route_segs(struct routeinfo_ *iroute, u_char stage, u_char graphdebug);
-
-ROUTE createemptyroute();
-void emit_routes(char *filename, double oscale, int iscale);
-int set_routes_to_net(NET net, int newflags, POINT *pushlist, SEG bbox,
- u_char stage);
-int set_route_to_net(NET net, ROUTE rt, int newflags, POINT *pushlist,
- SEG bbox, u_char stage);
-
-void initMask();
-void createMask(NET net, u_char slack, u_char halo);
-void fillMask(u_char value);
-
-void pathstart(FILE *cmd, int layer, int x, int y, u_char special, double oscale,
- double invscale, u_char horizontal);
-void pathto(FILE *cmd, int x, int y, int horizontal, int lastx, int lasty,
- double invscale);
-void pathvia(FILE *cmd, int layer, int x, int y, int lastx, int lasty,
- int gridx, int gridy, double invscale);
-
-void highlight_starts(POINT glist);
-void highlight_source();
-void highlight_dest();
-void highlight(int, int);
-int recalc_spacing();
-void draw_layout();
-
-void helpmessage();
-
+char *print_node_name(NODE node);
void print_nets(char *filename);
void print_routes(char *filename);
void print_nlgates(char *filename);
-char *print_node_name(NODE node);
+void print_net(NET net);
+void print_gate(GATE gate);
+
+NET getnettoroute(int order);
+int route_net_ripup(NET net, u_char graphdebug);
+int dosecondstage(u_char graphdebug, u_char singlestep);
+int doroute(NET net, u_char stage, u_char graphdebug);
+
-GATE DefFindInstance(char *name);
-void DefHashInstance(GATE gateginfo);
+#ifdef TCL_QROUTER
+void tcl_printf(FILE *, const char *, ...);
+void tcl_stdflush(FILE *);
+void tcl_vprintf(FILE *, const char *, va_list);
+#endif
#define QROUTER_H
#endif
diff --git a/tclqrouter.c b/tclqrouter.c
index f141b02..299b853 100644
--- a/tclqrouter.c
+++ b/tclqrouter.c
@@ -21,6 +21,9 @@
#include "maze.h"
#include "qconfig.h"
#include "lef.h"
+#include "graphics.h"
+#include "node.h"
+#include "tkSimple.h"
/* Global variables */
@@ -30,75 +33,121 @@ Tcl_Interp *consoleinterp;
int stepnet = -1;
-/* This hash table speeds up DEF file reading */
-
-Tcl_HashTable InstanceTable;
-
/* Command structure */
typedef struct {
const char *cmdstr;
- void (*func)();
+ int (*func)(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
} cmdstruct;
/* Forward declarations of commands */
-extern int Tk_SimpleObjCmd();
-extern int redraw();
-extern int qrouter_map();
-extern int qrouter_start();
-extern int qrouter_stage1();
-extern int qrouter_stage2();
-extern int qrouter_writedef();
-extern int qrouter_readdef();
-extern int qrouter_readlef();
-extern int qrouter_readconfig();
-extern int qrouter_failing();
-extern int qrouter_cost();
-extern int qrouter_tag();
-extern int qrouter_remove();
-extern int qrouter_obs();
-extern int qrouter_layerinfo();
-extern int qrouter_priority();
-extern int qrouter_ignore();
-extern int qrouter_via();
-extern int qrouter_resolution();
-extern int qrouter_congested();
-extern int qrouter_layers();
-extern int qrouter_passes();
-extern int qrouter_vdd();
-extern int qrouter_gnd();
-extern int qrouter_verbose();
-extern int QuitCallback();
+static int qrouter_map(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_start(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_stage1(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_stage2(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_writedef(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_readdef(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_readlef(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_readconfig(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_failing(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_cost(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_tag(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_remove(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_obs(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_layerinfo(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_priority(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_ignore(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_via(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_resolution(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_congested(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_layers(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_passes(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_vdd(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_gnd(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_verbose(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
+static int qrouter_print(
+ ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[]);
static cmdstruct qrouter_commands[] =
{
- {"tag", (void *)qrouter_tag},
- {"start", (void *)qrouter_start},
- {"stage1", (void *)qrouter_stage1},
- {"stage2", (void *)qrouter_stage2},
- {"write_def", (void *)qrouter_writedef},
- {"read_def", (void *)qrouter_readdef},
- {"read_lef", (void *)qrouter_readlef},
- {"read_config", (void *)qrouter_readconfig},
- {"layer_info", (void *)qrouter_layerinfo},
- {"obstruction", (void *)qrouter_obs},
- {"ignore", (void *)qrouter_ignore},
- {"priority", (void *)qrouter_priority},
- {"via", (void *)qrouter_via},
- {"resolution", (void *)qrouter_resolution},
- {"congested", (void *)qrouter_congested},
- {"layers", (void *)qrouter_layers},
- {"passes", (void *)qrouter_passes},
- {"vdd", (void *)qrouter_vdd},
- {"gnd", (void *)qrouter_gnd},
- {"failing", (void *)qrouter_failing},
- {"remove", (void *)qrouter_remove},
- {"cost", (void *)qrouter_cost},
- {"map", (void *)qrouter_map},
- {"verbose", (void *)qrouter_verbose},
- {"redraw", (void *)redraw},
- {"quit", (void *)QuitCallback},
+ {"tag", qrouter_tag},
+ {"start", qrouter_start},
+ {"stage1", qrouter_stage1},
+ {"stage2", qrouter_stage2},
+ {"write_def", qrouter_writedef},
+ {"read_def", qrouter_readdef},
+ {"read_lef", qrouter_readlef},
+ {"read_config", qrouter_readconfig},
+ {"layer_info", qrouter_layerinfo},
+ {"obstruction", qrouter_obs},
+ {"ignore", qrouter_ignore},
+ {"priority", qrouter_priority},
+ {"via", qrouter_via},
+ {"resolution", qrouter_resolution},
+ {"congested", qrouter_congested},
+ {"layers", qrouter_layers},
+ {"passes", qrouter_passes},
+ {"vdd", qrouter_vdd},
+ {"gnd", qrouter_gnd},
+ {"failing", qrouter_failing},
+ {"remove", qrouter_remove},
+ {"cost", qrouter_cost},
+ {"map", qrouter_map},
+ {"verbose", qrouter_verbose},
+ {"redraw", redraw},
+ {"print", qrouter_print},
+ {"quit", QuitCallback},
{"", NULL} /* sentinel */
};
@@ -156,7 +205,7 @@ void tcl_vprintf(FILE *f, const char *fmt, va_list args_in)
va_list args;
static char outstr[128] = "puts -nonewline std";
char *outptr, *bigstr = NULL, *finalstr = NULL;
- int i, nchars, result, escapes = 0, limit;
+ int i, nchars, escapes = 0;
/* If we are printing an error message, we want to bring attention */
/* to it by mapping the console window and raising it, as necessary. */
@@ -167,8 +216,8 @@ void tcl_vprintf(FILE *f, const char *fmt, va_list args_in)
Tk_Window tkwind;
tkwind = Tk_MainWindow(consoleinterp);
if ((tkwind != NULL) && (!Tk_IsMapped(tkwind)))
- result = Tcl_Eval(consoleinterp, "wm deiconify .\n");
- result = Tcl_Eval(consoleinterp, "raise .\n");
+ Tcl_Eval(consoleinterp, "wm deiconify .\n");
+ Tcl_Eval(consoleinterp, "raise .\n");
}
strcpy (outstr + 19, (f == stderr) ? "err \"" : "out \"");
@@ -218,7 +267,7 @@ void tcl_vprintf(FILE *f, const char *fmt, va_list args_in)
*(outptr + 24 + nchars + escapes) = '\"';
*(outptr + 25 + nchars + escapes) = '\0';
- result = Tcl_Eval(consoleinterp, outptr);
+ Tcl_Eval(consoleinterp, outptr);
if (bigstr != NULL) Tcl_Free(bigstr);
if (finalstr != NULL) Tcl_Free(finalstr);
@@ -267,7 +316,7 @@ int QrouterTagCallback(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
Tcl_HashEntry *entry;
Tcl_SavedResult state;
int reset = FALSE;
- int i, llen, cmdnum;
+ int i, llen;
entry = Tcl_FindHashEntry(&QrouterTagTable, croot);
postcmd = (entry) ? (char *)Tcl_GetHashValue(entry) : NULL;
@@ -410,8 +459,9 @@ int QrouterTagCallback(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
/* Add a command tag callback */
/*--------------------------------------------------------------*/
-int qrouter_tag(ClientData clientData,
- Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_tag(ClientData clientData,
+ Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
Tcl_HashEntry *entry;
char *hstring;
@@ -443,40 +493,6 @@ int qrouter_tag(ClientData clientData,
}
/*--------------------------------------------------------------*/
-/* Cell macro lookup based on the hash table */
-/*--------------------------------------------------------------*/
-
-GATE
-DefFindInstance(char *name)
-{
- GATE ginst;
- Tcl_HashEntry *entry;
-
- entry = Tcl_FindHashEntry(&InstanceTable, name);
- ginst = (entry) ? (GATE)Tcl_GetHashValue(entry) : NULL;
- return ginst;
-}
-
-/*--------------------------------------------------------------*/
-/* Cell macro hash table generation */
-/* Given an instance record, create an entry in the hash table */
-/* for the instance name, with the record entry pointing to the */
-/* instance record. */
-/*--------------------------------------------------------------*/
-
-void
-DefHashInstance(GATE gateginfo)
-{
- int new;
- Tcl_HashEntry *entry;
-
- entry = Tcl_CreateHashEntry(&InstanceTable,
- gateginfo->gatename, &new);
- if (entry != NULL)
- Tcl_SetHashValue(entry, (ClientData)gateginfo);
-}
-
-/*--------------------------------------------------------------*/
/* Initialization procedure for Tcl/Tk */
/*--------------------------------------------------------------*/
@@ -485,7 +501,6 @@ Qrouter_Init(Tcl_Interp *interp)
{
int cmdidx;
Tk_Window tktop;
- char *tmp_s;
char command[256];
char version_string[20];
@@ -531,10 +546,6 @@ Qrouter_Init(Tcl_Interp *interp)
if ((consoleinterp = Tcl_GetMaster(interp)) == NULL)
consoleinterp = interp;
- /* Initialize the macro hash table */
-
- Tcl_InitHashTable(&InstanceTable, TCL_STRING_KEYS);
-
/* Initialize the command tag table */
Tcl_InitHashTable(&QrouterTagTable, TCL_STRING_KEYS);
@@ -546,10 +557,11 @@ Qrouter_Init(Tcl_Interp *interp)
/* Command "start" */
/*------------------------------------------------------*/
-int qrouter_start(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_start(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
- int i, j, result, argc;
+ int i, result, argc;
char *scriptfile = NULL;
char **argv;
@@ -599,19 +611,22 @@ int qrouter_start(ClientData clientData, Tcl_Interp *interp,
/* map none route background is plain */
/* map routes draw routes over map */
/* map noroutes don't draw routes over map */
+/* map unrouted draw unrouted nets over map */
+/* map nounrouted don't draw unrouted nets */
/*------------------------------------------------------*/
-int qrouter_map(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_map(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
- int i, idx, result;
+ int idx, result;
static char *subCmds[] = {
"obstructions", "congestion", "estimate", "none",
- "routes", "noroutes", NULL
+ "routes", "noroutes", "unrouted", "nounrouted", NULL
};
enum SubIdx {
- ObsIdx, CongIdx, EstIdx, NoneIdx, RouteIdx, NoRouteIdx
+ ObsIdx, CongIdx, EstIdx, NoneIdx, RouteIdx, NoRouteIdx, UnroutedIdx, NoUnroutedIdx
};
if (objc != 2) {
@@ -652,19 +667,20 @@ int qrouter_map(ClientData clientData, Tcl_Interp *interp,
}
break;
case RouteIdx:
- if ((mapType & DRAW_MASK) != DRAW_ROUTES) {
- mapType &= ~DRAW_MASK;
- mapType |= DRAW_ROUTES;
- draw_layout();
- }
+ mapType |= DRAW_ROUTES;
+ draw_layout();
break;
case NoRouteIdx:
- if ((mapType & DRAW_MASK) != DRAW_NONE) {
- mapType &= ~DRAW_MASK;
- mapType |= DRAW_NONE;
- draw_layout();
- }
+ mapType &= ~DRAW_ROUTES;
+ draw_layout();
break;
+ case UnroutedIdx:
+ mapType |= DRAW_UNROUTED;
+ draw_layout();
+ break;
+ case NoUnroutedIdx:
+ mapType &= ~DRAW_UNROUTED;
+ draw_layout();
}
return QrouterTagCallback(interp, objc, objv);
}
@@ -690,6 +706,40 @@ NET LookupNet(char *netname)
}
/*------------------------------------------------------*/
+/* Find the net with number "number" in the list of */
+/* nets and return a pointer to it. */
+/*------------------------------------------------------*/
+
+NET LookupNetNr(int number)
+{
+ NET net;
+ int i;
+
+ for (i = 0; i < Numnets; i++) {
+ net = Nlnets[i];
+ if (net->netnum == number)
+ return net;
+ }
+ return NULL;
+}
+
+/*------------------------------------------------------*/
+/* Find the gate instance named gatename and return a */
+/* pointer to it. */
+/*------------------------------------------------------*/
+
+GATE LookupGate(char *gatename)
+{
+ GATE gate;
+
+ for (gate = Nlgates; gate != NULL; gate = gate->next) {
+ if (!strcmp(gate->gatename, gatename))
+ return gate;
+ }
+ return NULL;
+}
+
+/*------------------------------------------------------*/
/* Command "stage1" */
/* */
/* Execute stage1 routing. This works through the */
@@ -717,12 +767,13 @@ NET LookupNet(char *netname)
/* stage1 force Force a terminal to be routable */
/*------------------------------------------------------*/
-int qrouter_stage1(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_stage1(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
u_char dodebug;
u_char dostep;
- int i, idx, idx2, val, result, failcount;
+ int i, idx, idx2, val, result, failcount = 0;
NET net = NULL;
static char *subCmds[] = {
@@ -865,8 +916,9 @@ int qrouter_stage1(ClientData clientData, Tcl_Interp *interp,
/* stage2 tries <n> Keep trying n additional times */
/*------------------------------------------------------*/
-int qrouter_stage2(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_stage2(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
u_char dodebug;
u_char dostep;
@@ -1011,8 +1063,9 @@ int qrouter_stage2(ClientData clientData, Tcl_Interp *interp,
/* the design. */
/*------------------------------------------------------*/
-int qrouter_remove(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_remove(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
int result, idx, i;
NET net;
@@ -1068,8 +1121,9 @@ int qrouter_remove(ClientData clientData, Tcl_Interp *interp,
/* as originally ordered */
/*------------------------------------------------------*/
-int qrouter_failing(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_failing(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *lobj;
NETLIST nl, nlast;
@@ -1149,8 +1203,9 @@ int qrouter_failing(ClientData clientData, Tcl_Interp *interp,
/* Command "read_lef" */
/*------------------------------------------------------*/
-int qrouter_readlef(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_readlef(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
char *LEFfile;
@@ -1170,8 +1225,9 @@ int qrouter_readlef(ClientData clientData, Tcl_Interp *interp,
/* Command "read_def" */
/*------------------------------------------------------*/
-int qrouter_readdef(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_readdef(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
if ((DEFfilename[0] == '\0') && (objc != 2)) {
Tcl_SetResult(interp, "No DEF filename specified!", NULL);
@@ -1192,8 +1248,9 @@ int qrouter_readdef(ClientData clientData, Tcl_Interp *interp,
/* Command "write_def" */
/*------------------------------------------------------*/
-int qrouter_writedef(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_writedef(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
char *DEFoutfile = NULL;
@@ -1212,8 +1269,9 @@ int qrouter_writedef(ClientData clientData, Tcl_Interp *interp,
/* Command "read_config" */
/*------------------------------------------------------*/
-int qrouter_readconfig(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_readconfig(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
FILE *configFILE;
char *configname = NULL;
@@ -1249,8 +1307,9 @@ int qrouter_readconfig(ClientData clientData, Tcl_Interp *interp,
/* obstruction <xmin> <ymin> <xmax> <ymax> <layer> */
/*------------------------------------------------------*/
-int qrouter_obs(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_obs(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *lobj;
Tcl_Obj *oobj;
@@ -1322,8 +1381,9 @@ int qrouter_obs(ClientData clientData, Tcl_Interp *interp,
/* ignore [<net> ...] */
/*------------------------------------------------------*/
-int qrouter_ignore(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_ignore(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
int i;
NET net;
@@ -1365,8 +1425,9 @@ int qrouter_ignore(ClientData clientData, Tcl_Interp *interp,
/* priority [<net> ...] */
/*------------------------------------------------------*/
-int qrouter_priority(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_priority(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
int i;
char *netname;
@@ -1405,7 +1466,7 @@ int qrouter_priority(ClientData clientData, Tcl_Interp *interp,
}
}
}
- create_netorder(0, NULL);
+ create_netorder(0);
}
return QrouterTagCallback(interp, objc, objv);
}
@@ -1444,11 +1505,12 @@ int qrouter_priority(ClientData clientData, Tcl_Interp *interp,
/* No option is the same as option "layer_info all" */
/*------------------------------------------------------*/
-int qrouter_layerinfo(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_layerinfo(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *lobj, *oobj;
- int i, idx, idx2, val, result, layer;
+ int i, idx, idx2, val, result, layer = -1;
char *layername;
static char *subCmds[] = {
@@ -1572,6 +1634,7 @@ int qrouter_layerinfo(ClientData clientData, Tcl_Interp *interp,
Tcl_SetObjResult(interp, lobj);
break;
}
+ return TCL_OK;
}
/*------------------------------------------------------*/
@@ -1596,8 +1659,9 @@ int qrouter_layerinfo(ClientData clientData, Tcl_Interp *interp,
/* via pattern [normal|inverted] */
/*------------------------------------------------------*/
-int qrouter_via(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_via(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
int idx, idx2, result, value;
@@ -1693,8 +1757,9 @@ int qrouter_via(ClientData clientData, Tcl_Interp *interp,
/* resolution [<value>] */
/*------------------------------------------------------*/
-int qrouter_verbose(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_verbose(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
int result, value;
@@ -1735,8 +1800,9 @@ int qrouter_verbose(ClientData clientData, Tcl_Interp *interp,
/* resolution [<value>] */
/*------------------------------------------------------*/
-int qrouter_resolution(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_resolution(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
int result, value;
@@ -1775,8 +1841,9 @@ int qrouter_resolution(ClientData clientData, Tcl_Interp *interp,
/* layers [<number>] */
/*------------------------------------------------------*/
-int qrouter_layers(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_layers(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
int result, value;
@@ -1816,8 +1883,9 @@ int qrouter_layers(ClientData clientData, Tcl_Interp *interp,
/* passes [<number>] */
/*------------------------------------------------------*/
-int qrouter_passes(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_passes(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
int result, value;
@@ -1852,8 +1920,9 @@ int qrouter_passes(ClientData clientData, Tcl_Interp *interp,
/* vdd [<name>] */
/*------------------------------------------------------*/
-int qrouter_vdd(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_vdd(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
if (objc == 1) {
if (vddnet == NULL)
@@ -1884,8 +1953,9 @@ int qrouter_vdd(ClientData clientData, Tcl_Interp *interp,
/* gnd [<name>] */
/*------------------------------------------------------*/
-int qrouter_gnd(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_gnd(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
if (objc == 1) {
if (gndnet == NULL)
@@ -1919,8 +1989,9 @@ int qrouter_gnd(ClientData clientData, Tcl_Interp *interp,
/* cost conflict */
/*------------------------------------------------------*/
-int qrouter_cost(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_cost(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
int idx, result, value;
@@ -2038,12 +2109,13 @@ int compcong(CLIST *a, CLIST *b)
/* gates in the design. */
/*------------------------------------------------------*/
-int qrouter_congested(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[])
+static int
+qrouter_congested(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
{
NET net;
int i, x, y, nwidth, nheight, area, length;
- int value, entries, numgates, result;
+ int entries, numgates, result;
float density, *Congestion;
CLIST *cgates, csrch;
GATE gsrch;
@@ -2055,7 +2127,7 @@ int qrouter_congested(ClientData clientData, Tcl_Interp *interp,
result = Tcl_GetIntFromObj(interp, objv[1], &entries);
if (result != TCL_OK) return result;
- if (value <= 0) {
+ if (entries <= 0) {
Tcl_SetResult(interp, "List size must be > 0", NULL);
return TCL_ERROR;
}
@@ -2160,3 +2232,73 @@ int qrouter_congested(ClientData clientData, Tcl_Interp *interp,
}
/*------------------------------------------------------*/
+/* Command "print" */
+/* */
+/* print an object */
+/* */
+/* Options: */
+/* */
+/* print net <netname> */
+/* print netnr <netnumber> */
+/* print gate <gatename> */
+/*------------------------------------------------------*/
+
+static int
+qrouter_print(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ int idx, result, value;
+ NET net;
+ GATE gate;
+
+ static char *subCmds[] = {
+ "net", "netnr", "gate", NULL
+ };
+ enum SubIdx {
+ NetIdx, NetNrIdx, GateIdx
+ };
+
+ value = 0;
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg?");
+ return TCL_ERROR;
+ }
+
+ if ((result = Tcl_GetIndexFromObj(interp, objv[1],
+ (CONST84 char **)subCmds, "option", 0, &idx)) != TCL_OK)
+ return result;
+
+ switch (idx) {
+ case NetIdx:
+ net = LookupNet(Tcl_GetString(objv[2]));
+ if (net == NULL) {
+ Tcl_SetResult(interp, "Net not found", NULL);
+ return TCL_ERROR;
+ }
+ print_net(net);
+ break;
+
+ case NetNrIdx:
+ result = Tcl_GetIntFromObj(interp, objv[2], &value);
+ if (result != TCL_OK) return result;
+ net = LookupNetNr(value);
+ if (net == NULL) {
+ Tcl_SetResult(interp, "Net not found", NULL);
+ return TCL_ERROR;
+ }
+ print_net(net);
+ break;
+
+ case GateIdx:
+ gate = LookupGate(Tcl_GetString(objv[2]));
+ if (gate == NULL) {
+ Tcl_SetResult(interp, "Gate not found", NULL);
+ return TCL_ERROR;
+ }
+ print_gate(gate);
+ }
+
+ return QrouterTagCallback(interp, objc, objv);
+}
+
+/*------------------------------------------------------*/
diff --git a/tkSimple.c b/tkSimple.c
index f6eb3d8..27ae3ae 100644
--- a/tkSimple.c
+++ b/tkSimple.c
@@ -10,11 +10,13 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <tk.h>
+/* TODO: include proper include for TkpUseWindow */
+int TkpUseWindow();
-void resize();
-void expose();
+#include "graphics.h"
/* Backwards compatibility to tk8.3 and earlier */
#if TK_MAJOR_VERSION == 8
@@ -126,9 +128,9 @@ Tk_SimpleObjCmd(clientData, interp, objc, objv)
{
Tk_Window tkwin = (Tk_Window) clientData;
Simple *simplePtr;
- Tk_Window new;
+ Tk_Window new = NULL;
char *arg, *useOption;
- int i, c, depth;
+ int i, c;
size_t length;
unsigned int mask;
@@ -373,7 +375,6 @@ ConfigureSimple(interp, simplePtr, objc, objv, flags)
Tcl_Obj *CONST objv[]; /* Arguments. */
int flags; /* Flags to pass to Tk_ConfigureWidget. */
{
- char *oldMenuName;
if (Tk_ConfigureWidget(interp, simplePtr->tkwin, configSpecs,
objc, (CONST84 char **) objv, (char *) simplePtr,
diff --git a/tkSimple.h b/tkSimple.h
new file mode 100644
index 0000000..0cbf58e
--- /dev/null
+++ b/tkSimple.h
@@ -0,0 +1,13 @@
+/*
+ * tkSimple.h --
+ */
+
+#ifndef _TKSIMPLEINT_H
+#define _TKSIMPLEINT_H
+
+#include <tk.h>
+
+int Tk_SimpleObjCmd(ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj * CONST objv[]);
+
+#endif /* _TKSIMPLEINT_H */