FreeCalypso > hg > ueda-linux
comparison netdiff/convert/pads2donl.c @ 134:ab7b9f01ac6a
netdiff: pads2donl converter added
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 07 Sep 2020 00:40:55 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
133:603d8da32fd0 | 134:ab7b9f01ac6a |
---|---|
1 /* | |
2 * This program converts a PADS ASCII netlist into our | |
3 * Diff-Oriented Netlist (DONL) format. | |
4 */ | |
5 | |
6 #include <ctype.h> | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <strings.h> | |
11 | |
12 #define MAX_NETNAME 127 | |
13 | |
14 static char *infname; | |
15 static FILE *inf; | |
16 static char linebuf[512], netname[MAX_NETNAME+1]; | |
17 static int lineno; | |
18 | |
19 static void | |
20 process_signal_line() | |
21 { | |
22 char *cp, *np; | |
23 | |
24 cp = linebuf + 1; | |
25 while (*cp != '*') | |
26 cp++; | |
27 cp++; | |
28 if (!isspace(*cp)) { | |
29 badsig: fprintf(stderr, "%s line %d: malformed SIGNAL line\n", | |
30 infname, lineno); | |
31 exit(1); | |
32 } | |
33 while (isspace(*cp)) | |
34 cp++; | |
35 if (!*cp) | |
36 goto badsig; | |
37 for (np = cp; *cp && !isspace(*cp); cp++) | |
38 ; | |
39 if (*cp) | |
40 *cp = '\0'; | |
41 if (strlen(np) > MAX_NETNAME) { | |
42 fprintf(stderr, "%s line %d: signal name too long\n", | |
43 infname, lineno); | |
44 exit(1); | |
45 } | |
46 strcpy(netname, np); | |
47 } | |
48 | |
49 static void | |
50 process_data_line() | |
51 { | |
52 char *cp, *np; | |
53 | |
54 for (cp = linebuf; ; ) { | |
55 while (isspace(*cp)) | |
56 cp++; | |
57 if (!*cp) | |
58 break; | |
59 for (np = cp; *cp && !isspace(*cp); cp++) | |
60 ; | |
61 if (*cp) | |
62 *cp++ = '\0'; | |
63 printf("%s\t%s\n", netname, np); | |
64 } | |
65 } | |
66 | |
67 main(argc, argv) | |
68 char **argv; | |
69 { | |
70 if (argc != 2) { | |
71 fprintf(stderr, "usage: %s pads-netlist-file\n", argv[0]); | |
72 exit(1); | |
73 } | |
74 infname = argv[1]; | |
75 inf = fopen(infname, "r"); | |
76 if (!inf) { | |
77 perror(infname); | |
78 exit(1); | |
79 } | |
80 for (;;) { | |
81 if (!fgets(linebuf, sizeof linebuf, inf)) | |
82 break; | |
83 lineno++; | |
84 if (!index(linebuf, '\n')) { | |
85 fprintf(stderr, "%s line %d: missing newline\n", | |
86 infname, lineno); | |
87 exit(1); | |
88 } | |
89 if (linebuf[0] == '*') { | |
90 if (!strncmp(linebuf, "*END*", 5)) | |
91 break; | |
92 if (!strncmp(linebuf, "*SIG*", 5) || | |
93 !strncmp(linebuf, "*SIGNAL*", 8)) | |
94 process_signal_line(); | |
95 else | |
96 netname[0] = '\0'; | |
97 continue; | |
98 } | |
99 if (netname[0]) | |
100 process_data_line(); | |
101 } | |
102 exit(0); | |
103 } |