# HG changeset patch # User Mychaela Falconia # Date 1599454657 0 # Node ID d3eb3790386d0ab8d9a60a518dac7a2de9fd777c # Parent bf188727e606f494a457877abb38acd923f050fb netdiff: donl-netmatch put together diff -r bf188727e606 -r d3eb3790386d .hgignore --- a/.hgignore Mon Sep 07 04:25:11 2020 +0000 +++ b/.hgignore Mon Sep 07 04:57:37 2020 +0000 @@ -19,6 +19,7 @@ ^netdiff/convert/pads2donl$ ^netdiff/convert/protel2donl$ ^netdiff/convert/tedax2donl$ +^netdiff/match/donl-netmatch$ ^netdiff/renpart/donl-rename-parts$ ^pads2gpcb/pads2gpcb$ diff -r bf188727e606 -r d3eb3790386d netdiff/match/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/netdiff/match/Makefile Mon Sep 07 04:57:37 2020 +0000 @@ -0,0 +1,16 @@ +CC= gcc +CFLAGS= -O2 +PROG= donl-netmatch +OBJS= main.o rdpass.o +BINDIR= /usr/local/bin + +all: ${PROG} + +${PROG}: ${OBJS} + ${CC} ${CFLAGS} -o $@ ${OBJS} + +install: + install -c -o bin -g bin -m 755 ${PROG} ${BINDIR} + +clean: + rm -f *.[ao] a.out core errs ${PROG} diff -r bf188727e606 -r d3eb3790386d netdiff/match/main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/netdiff/match/main.c Mon Sep 07 04:57:37 2020 +0000 @@ -0,0 +1,67 @@ +#include +#include +#include "struct.h" + +char *infnames[2]; +struct pin_info *database; + +write_diffs_report(outfile) + char *outfile; +{ + FILE *outf; + struct pin_info *p; + + outf = fopen(outfile, "w"); + if (!outf) { + perror(outfile); + exit(1); + } + for (p = database; p; p = p->next) { + if (p->netnames[0] && !p->netnames[1]) + fprintf(outf, "Pin %s only in %s: net %s\n", + p->pin_name, infnames[0], p->netnames[0]); + if (!p->netnames[0] && p->netnames[1]) + fprintf(outf, "Pin %s only in %s: net %s\n", + p->pin_name, infnames[1], p->netnames[1]); + } + fclose(outf); +} + +write_matching_nets(outfile) + char *outfile; +{ + FILE *outf; + struct pin_info *p; + + outf = fopen(outfile, "w"); + if (!outf) { + perror(outfile); + exit(1); + } + for (p = database; p; p = p->next) { + if (!p->netnames[0] || !p->netnames[1]) + continue; + fprintf(outf, "%s\t%s\n", p->netnames[0], p->netnames[1]); + } + fclose(outf); +} + +main(argc, argv) + char **argv; +{ + int i; + + if (argc != 5) { + fprintf(stderr, + "usage: %s net1 net2 diffs-report matching-nets\n", + argv[0]); + exit(1); + } + infnames[0] = argv[1]; + infnames[1] = argv[2]; + for (i = 0; i < 2; i++) + read_pass(i); + write_diffs_report(argv[3]); + write_matching_nets(argv[4]); + exit(0); +} diff -r bf188727e606 -r d3eb3790386d netdiff/match/rdpass.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/netdiff/match/rdpass.c Mon Sep 07 04:57:37 2020 +0000 @@ -0,0 +1,123 @@ +#include +#include +#include +#include +#include +#include "struct.h" + +extern char *infnames[2]; +extern struct pin_info *database; + +#define MAX_FIELDS 2 + +static int pass; +static FILE *inf; +static char linebuf[512]; +static int lineno; +static char *fields[MAX_FIELDS]; +static unsigned nfields; + +static void +parse_into_fields() +{ + char *cp; + + nfields = 0; + for (cp = linebuf; ; ) { + while (isspace(*cp)) + cp++; + if (*cp == '\0' || *cp == '#') + break; + if (nfields >= MAX_FIELDS) { + fprintf(stderr, "%s line %d: too many fields\n", + infnames[pass], lineno); + exit(1); + } + fields[nfields++] = cp; + while (*cp && !isspace(*cp)) + cp++; + if (*cp) + *cp++ = '\0'; + } +} + +static void +existing_pin(p, netname) + struct pin_info *p; + char *netname; +{ + char *dp; + + if (p->netnames[pass]) { + fprintf(stderr, "%s line %d: multiple nets to pin %s\n", + infnames[pass], lineno, p->pin_name); + exit(1); + } + dp = malloc(strlen(netname) + 1); + if (!dp) { + perror("malloc"); + exit(1); + } + strcpy(dp, netname); + p->netnames[pass] = dp; +} + +static void +process_connect(netname, pinname) + char *netname, *pinname; +{ + struct pin_info *p, **pp; + char *dp; + + for (pp = &database; p = *pp; pp = &p->next) { + if (!strcmp(p->pin_name, pinname)) { + existing_pin(p, netname); + return; + } + } + p = malloc(sizeof(struct pin_info) + strlen(netname) + strlen(pinname) + + 2); + if (!p) { + perror("malloc"); + exit(1); + } + bzero(p, sizeof(struct pin_info)); + dp = (char *)(p + 1); + p->pin_name = dp; + strcpy(dp, pinname); + dp += strlen(pinname) + 1; + p->netnames[pass] = dp; + strcpy(dp, netname); + *pp = p; +} + +static void +process_line() +{ + parse_into_fields(); + if (!nfields) + return; + if (nfields != 2) { + fprintf(stderr, "%s line %d: expected 2 fields\n", + infnames[pass], lineno); + exit(1); + } + process_connect(fields[0], fields[1]); +} + +read_pass(pass_no) +{ + pass = pass_no; + inf = fopen(infnames[pass], "r"); + if (!inf) { + perror(infnames[pass]); + exit(1); + } + lineno = 0; + while (fgets(linebuf, sizeof linebuf, inf)) { + lineno++; + process_line(); + } + fclose(inf); + return 0; +} diff -r bf188727e606 -r d3eb3790386d netdiff/match/struct.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/netdiff/match/struct.h Mon Sep 07 04:57:37 2020 +0000 @@ -0,0 +1,5 @@ +struct pin_info { + char *pin_name; + char *netnames[2]; + struct pin_info *next; +};