FreeCalypso > hg > ueda-linux
changeset 134:ab7b9f01ac6a
netdiff: pads2donl converter added
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 07 Sep 2020 00:40:55 +0000 |
parents | 603d8da32fd0 |
children | 25634b3977a9 |
files | .hgignore netdiff/convert/Makefile netdiff/convert/pads2donl.c |
diffstat | 3 files changed, 107 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Sep 06 23:14:14 2020 +0000 +++ b/.hgignore Mon Sep 07 00:40:55 2020 +0000 @@ -15,6 +15,7 @@ ^ueda/utils/cutelements$ ^ueda/utils/instfileelem$ +^netdiff/convert/pads2donl$ ^netdiff/convert/protel2donl$ ^pads2gpcb/pads2gpcb$
--- a/netdiff/convert/Makefile Sun Sep 06 23:14:14 2020 +0000 +++ b/netdiff/convert/Makefile Mon Sep 07 00:40:55 2020 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -PROGS= protel2donl +PROGS= pads2donl protel2donl BINDIR= /usr/local/bin all: ${PROGS} @@ -14,4 +14,5 @@ clean: rm -f *.[ao] a.out core errs ${PROGS} -protel2donl: protel2donl.c +pads2donl: pads2donl.c +protel2donl: protel2donl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/netdiff/convert/pads2donl.c Mon Sep 07 00:40:55 2020 +0000 @@ -0,0 +1,103 @@ +/* + * This program converts a PADS ASCII netlist into our + * Diff-Oriented Netlist (DONL) format. + */ + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> + +#define MAX_NETNAME 127 + +static char *infname; +static FILE *inf; +static char linebuf[512], netname[MAX_NETNAME+1]; +static int lineno; + +static void +process_signal_line() +{ + char *cp, *np; + + cp = linebuf + 1; + while (*cp != '*') + cp++; + cp++; + if (!isspace(*cp)) { +badsig: fprintf(stderr, "%s line %d: malformed SIGNAL line\n", + infname, lineno); + exit(1); + } + while (isspace(*cp)) + cp++; + if (!*cp) + goto badsig; + for (np = cp; *cp && !isspace(*cp); cp++) + ; + if (*cp) + *cp = '\0'; + if (strlen(np) > MAX_NETNAME) { + fprintf(stderr, "%s line %d: signal name too long\n", + infname, lineno); + exit(1); + } + strcpy(netname, np); +} + +static void +process_data_line() +{ + char *cp, *np; + + for (cp = linebuf; ; ) { + while (isspace(*cp)) + cp++; + if (!*cp) + break; + for (np = cp; *cp && !isspace(*cp); cp++) + ; + if (*cp) + *cp++ = '\0'; + printf("%s\t%s\n", netname, np); + } +} + +main(argc, argv) + char **argv; +{ + if (argc != 2) { + fprintf(stderr, "usage: %s pads-netlist-file\n", argv[0]); + exit(1); + } + infname = argv[1]; + inf = fopen(infname, "r"); + if (!inf) { + perror(infname); + exit(1); + } + for (;;) { + if (!fgets(linebuf, sizeof linebuf, inf)) + break; + lineno++; + if (!index(linebuf, '\n')) { + fprintf(stderr, "%s line %d: missing newline\n", + infname, lineno); + exit(1); + } + if (linebuf[0] == '*') { + if (!strncmp(linebuf, "*END*", 5)) + break; + if (!strncmp(linebuf, "*SIG*", 5) || + !strncmp(linebuf, "*SIGNAL*", 8)) + process_signal_line(); + else + netname[0] = '\0'; + continue; + } + if (netname[0]) + process_data_line(); + } + exit(0); +}