# HG changeset patch # User Space Falcon # Date 1438477938 0 # Node ID 65a515c20db8ea6410eb4e43062c4f40c1002c19 # Parent c59f52e4bacf99a68fe84bff660144742aecf2ea unet-bind: starpoint entry implemented diff -r c59f52e4bacf -r 65a515c20db8 ueda/sverp-bind/Makefile --- a/ueda/sverp-bind/Makefile Sun Aug 02 00:39:38 2015 +0000 +++ b/ueda/sverp-bind/Makefile Sun Aug 02 01:12:18 2015 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -OBJS= enterinst.o insthash.o main.o outcomp.o +OBJS= enterinst.o insthash.o main.o outcomp.o starpoints.o LIBS= ../libueda/libueda.a PROG= unet-bind BINDIR= /usr/local/bin diff -r c59f52e4bacf -r 65a515c20db8 ueda/sverp-bind/main.c --- a/ueda/sverp-bind/main.c Sun Aug 02 00:39:38 2015 +0000 +++ b/ueda/sverp-bind/main.c Sun Aug 02 01:12:18 2015 +0000 @@ -7,12 +7,14 @@ extern char *MCLfile; char *input_filename, *output_filename; +char *starpoints_file; int check_completeness; static void usage() { - fprintf(stderr, "usage: unet-bind input.unet [output.unet]\n"); + fprintf(stderr, + "usage: unet-bind [options] input.unet [output.unet]\n"); exit(1); } @@ -23,17 +25,20 @@ extern char *optarg; register int c; - while ((c = getopt(argc, argv, "cI:M:")) != EOF) { + while ((c = getopt(argc, argv, "cI:M:s:")) != EOF) { switch (c) { case 'c': check_completeness++; - break; + continue; case 'I': add_symfile_dir(optarg); continue; case 'M': MCLfile = optarg; - break; + continue; + case 's': + starpoints_file = optarg; + continue; default: usage(); } @@ -57,6 +62,10 @@ read_pinouts(); init_outcomp_from_MCL(); + /* do we have any star points? */ + if (starpoints_file) + process_starpoints_file(); + /* remaining functionality remains to be implemented */ exit(0); } diff -r c59f52e4bacf -r 65a515c20db8 ueda/sverp-bind/starpoints.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ueda/sverp-bind/starpoints.c Sun Aug 02 01:12:18 2015 +0000 @@ -0,0 +1,88 @@ +#include +#include +#include +#include +#include "struct.h" + +extern struct instance *enter_instance(); + +extern char *starpoints_file; + +struct outcomp *starpoint_list_head; +static struct outcomp **global_tailp = &starpoint_list_head; + +process_starpoints_file() +{ + FILE *stream; + char linebuf[256]; + int lineno; + register char *cp; + char *instname, *numstr; + int npins; + register struct instance *inst; + register struct outcomp *oc; + + stream = fopen(starpoints_file, "r"); + if (!stream) { + perror(starpoints_file); + exit(1); + } + for (lineno = 1; fgets(linebuf, sizeof linebuf, stream); lineno++) { + cp = index(linebuf, '\n'); + if (!cp) { + fprintf(stderr, + "error: %s line %d is too long or unterminated\n", + starpoints_file, lineno); + exit(1); + } + *cp = '\0'; + for (cp = linebuf; isspace(*cp); cp++) + ; + if (*cp == '\0' || *cp == '#') + continue; + instname = cp; + while (*cp && !isspace(*cp)) + cp++; + if (*cp) + *cp++ = '\0'; + while (isspace(*cp)) + cp++; + if (*cp == '\0' || *cp == '#') { +npins_error: fprintf(stderr, +"error in %s line %d: expected number of pins after the instance name\n", + starpoints_file, lineno); + exit(1); + } + numstr = cp; + while (*cp && !isspace(*cp)) + cp++; + if (*cp) + *cp++ = '\0'; + if (!string_is_valid_decnum(numstr)) + goto npins_error; + npins = atoi(numstr); + if (npins < 2) { + fprintf(stderr, + "error in %s line %d: a starpoint must have 2 or more pins\n", + starpoints_file, lineno); + exit(1); + } + inst = enter_instance(instname); + oc = (struct outcomp *) + malloc(sizeof(struct outcomp) + + sizeof(struct pinconn *) * npins); + if (!oc) { + perror("malloc"); + exit(1); + } + bzero(oc, sizeof(struct outcomp) + + sizeof(struct pinconn *) * npins); + oc->name = inst->name; + oc->npins = npins; + oc->conn_array = (struct pinconn **)(oc + 1); + inst->outcomp = oc; + *global_tailp = oc; + global_tailp = &oc->next; + } + fclose(stream); +} diff -r c59f52e4bacf -r 65a515c20db8 ueda/sverp-bind/struct.h --- a/ueda/sverp-bind/struct.h Sun Aug 02 00:39:38 2015 +0000 +++ b/ueda/sverp-bind/struct.h Sun Aug 02 01:12:18 2015 +0000 @@ -17,12 +17,7 @@ int npins; struct grid_pkg_desc *grid_pkg; struct pinconn **conn_array; -}; - -struct starpoint { - struct outcomp outcomp; - struct instance instance; - struct starpoint *next; + struct outcomp *next; /* used only for starpoints */ }; struct pinconn {