annotate ueda/unet-utils/unet-destar.c @ 100:071b24bca546

SIM_Socket_473882001.fp: silk courtyard captured
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 29 Sep 2019 19:13:09 +0000
parents a93e4b07fdf3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <stdio.h>
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <stdlib.h>
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <string.h>
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 #include <strings.h>
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <unistd.h>
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include "../libunet/unetrd.h"
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include "../libunet/nethash.h"
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 extern struct net *enter_net_object();
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 extern struct net *find_net_by_name();
26
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
11 extern struct net *net_list_head;
24
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 static char *input_filename, *output_filename;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14 static struct unetrd_state rdstate;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 static struct unetrd_out rdout;
26
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
16 static int total_input_nets, total_output_nets;
24
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17 static struct net *starpoint_head;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 static FILE *tempFILE, *outFILE;
26
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
19 static int net_comment_column;
24
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 struct netextra {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 struct net *squashed_to;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 int npoints;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 };
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 static FILE *
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 tempfile()
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 char template[16];
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 register int fd;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 register FILE *f;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 strcpy(template, "/tmp/uedaXXXXXX");
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 fd = mkstemp(template);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 if (fd < 0) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 perror("mkstemp");
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 unlink(template);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 f = fdopen(fd, "r+w");
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 if (!f) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 perror("fdopen");
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 return(f);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 static void
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 dump_tempfile()
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 register FILE *inf = tempFILE;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 register FILE *outf = outFILE;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 register int c;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 rewind(inf);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 while ((c = getc(inf)) != EOF)
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 putc(c, outf);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 fclose(inf);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 static void
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 process_starpoint_head()
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 register struct net *n;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 register struct netextra *nx;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 n = find_net_by_name(rdout.connect_to_net);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 for (;;) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 nx = (struct netextra *)(n + 1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 if (!nx->squashed_to)
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 break;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 n = nx->squashed_to;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 starpoint_head = n;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77 static void
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 process_starpoint_arm()
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
79 {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 register struct net *n;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 register struct netextra *nx;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 n = find_net_by_name(rdout.connect_to_net);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
84 if (n == starpoint_head) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
85 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
86 "%s line %d: starpoint between net %s and itself!\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
87 input_filename, rdstate.lineno, n->name);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
88 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
89 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
90 nx = (struct netextra *)(n + 1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
91 if (nx->squashed_to) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
92 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
93 "%s line %d: net %s has already been squashed\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
94 input_filename, rdstate.lineno, n->name);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
95 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
96 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
97 nx->squashed_to = starpoint_head;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
98 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
99
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
100 static void
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
101 process_starpoint()
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
102 {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
103 starpoint_head = 0;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
104 for (;;) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
105 if (!read_unet_line(&rdstate, &rdout)) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
106 fprintf(stderr, "%s error: EOF in STARPOINT block\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
107 input_filename);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
108 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
109 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
110 if (rdout.typecode == UNETOBJ_CLOSINGBRACE)
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
111 break;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
112 switch(rdout.typecode) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
113 case UNETOBJ_PRIMITIVE:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
114 case UNETOBJ_ALTNAME:
30
a93e4b07fdf3 unet-destar: pass attributes through
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 27
diff changeset
115 case UNETOBJ_ATTR:
24
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
116 continue;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
117 case UNETOBJ_PIN:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
118 if (!rdout.connect_to_net) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
119 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
120 "%s line %d: no-connect is meaningless for a starpoint arm\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
121 input_filename, rdstate.lineno);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
122 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
123 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
124 if (!starpoint_head)
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
125 process_starpoint_head();
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
126 else
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
127 process_starpoint_arm();
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
128 continue;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
129 case UNETOBJ_PINMAP:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
130 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
131 "%s line %d: PINMAP meaningless in a STARPOINT block\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
132 input_filename, rdstate.lineno);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
133 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
134 default:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
135 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
136 "%s line %d: object type %s unexpected in STARPOINT block\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
137 input_filename, rdstate.lineno, rdout.keyword);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
138 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
139 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
140 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
141 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
142
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
143 static void
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
144 process_component_pin()
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
145 {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
146 register struct net *n;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
147 register struct netextra *nx;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
148
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
149 if (!rdout.connect_to_net) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
150 fprintf(tempFILE, " %s %s = NC (%s)\n", rdout.keyword,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
151 rdout.objname, rdout.nc_comment);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
152 return;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
153 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
154 n = find_net_by_name(rdout.connect_to_net);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
155 for (;;) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
156 nx = (struct netextra *)(n + 1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
157 if (!nx->squashed_to)
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
158 break;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
159 n = nx->squashed_to;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
160 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
161 fprintf(tempFILE, " %s %s = NET %s\n", rdout.keyword, rdout.objname,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
162 n->name);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
163 nx->npoints++;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
164 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
165
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
166 static void
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
167 process_component()
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
168 {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
169 fprintf(tempFILE, "\nCOMPONENT %s {\n", rdout.objname);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
170 for (;;) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
171 if (!read_unet_line(&rdstate, &rdout)) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
172 fprintf(stderr, "%s error: EOF in COMPONENT block\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
173 input_filename);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
174 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
175 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
176 if (rdout.typecode == UNETOBJ_CLOSINGBRACE)
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
177 break;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
178 switch(rdout.typecode) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
179 case UNETOBJ_PRIMITIVE:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
180 case UNETOBJ_ALTNAME:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
181 fprintf(tempFILE, " %s %s\n", rdout.keyword,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
182 rdout.objname);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
183 continue;
30
a93e4b07fdf3 unet-destar: pass attributes through
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 27
diff changeset
184 case UNETOBJ_ATTR:
a93e4b07fdf3 unet-destar: pass attributes through
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 27
diff changeset
185 fprintf(tempFILE, " ATTR %s=%s\n", rdout.objname,
a93e4b07fdf3 unet-destar: pass attributes through
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 27
diff changeset
186 rdout.attr_value);
a93e4b07fdf3 unet-destar: pass attributes through
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 27
diff changeset
187 continue;
24
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
188 case UNETOBJ_PIN:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
189 case UNETOBJ_PINMAP:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
190 process_component_pin();
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
191 continue;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
192 default:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
193 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
194 "%s line %d: object type %s unexpected in COMPONENT block\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
195 input_filename, rdstate.lineno, rdout.keyword);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
196 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
197 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
198 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
199 fputs("}\n", tempFILE);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
200 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
201
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
202 static void
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
203 process_input_unet()
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
204 {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
205 struct net *n;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
206 int state = 0;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
207
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
208 open_unet_input_file(input_filename, &rdstate);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
209 while (read_unet_line(&rdstate, &rdout)) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
210 switch(rdout.typecode) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
211 case UNETOBJ_CLOSINGBRACE:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
212 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
213 "%s line %d: unexpected '}' outside of component block\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
214 input_filename, rdstate.lineno);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
215 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
216 case UNETOBJ_NET:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
217 if (state == 0)
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
218 state = 1;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
219 else if (state > 1) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
220 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
221 "error: all input nets must precede all starpoints and components (%s line %d)\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
222 input_filename, rdstate.lineno);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
223 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
224 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
225 n = enter_net_object(rdout.objname,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
226 sizeof(struct netextra));
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
227 bzero(n + 1, sizeof(struct netextra));
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
228 total_input_nets++;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
229 continue;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
230 case UNETOBJ_STARPOINT:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
231 if (state < 1) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
232 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
233 "error (%s line %d): STARPOINT without any preceding NETs\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
234 input_filename, rdstate.lineno);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
235 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
236 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
237 if (state > 2) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
238 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
239 "error: all STARPOINTs must precede all COMPONENTs (%s line %d)\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
240 input_filename, rdstate.lineno);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
241 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
242 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
243 state = 2;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
244 process_starpoint();
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
245 continue;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
246 case UNETOBJ_COMPONENT:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
247 if (state < 1) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
248 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
249 "error (%s line %d): COMPONENT without any preceding NETs\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
250 input_filename, rdstate.lineno);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
251 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
252 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
253 if (state < 3) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
254 tempFILE = tempfile();
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
255 state = 3;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
256 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
257 process_component();
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
258 continue;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
259 default:
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
260 fprintf(stderr,
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
261 "%s line %d: unexpected object type %s\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
262 input_filename, rdstate.lineno, rdout.keyword);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
263 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
264 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
265 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
266 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
267
26
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
268 static void
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
269 find_net_comment_column()
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
270 {
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
271 register struct net *n;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
272 register struct netextra *nx;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
273 register int len, maxlen;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
274
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
275 maxlen = 0;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
276 for (n = net_list_head; n; n = n->nextinlist) {
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
277 nx = (struct netextra *)(n + 1);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
278 if (nx->squashed_to)
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
279 continue;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
280 total_output_nets++;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
281 len = strlen(n->name);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
282 if (len > maxlen)
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
283 maxlen = len;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
284 }
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
285 maxlen += 4;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
286 do
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
287 maxlen++;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
288 while (maxlen % 8);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
289 net_comment_column = maxlen;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
290 }
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
291
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
292 static void
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
293 output_nets()
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
294 {
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
295 register struct net *n;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
296 register struct netextra *nx;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
297 register int col;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
298
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
299 fprintf(outFILE, "\n# %d input nets reduced to %d joined nets:\n#\n",
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
300 total_input_nets, total_output_nets);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
301 for (n = net_list_head; n; n = n->nextinlist) {
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
302 nx = (struct netextra *)(n + 1);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
303 if (nx->squashed_to)
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
304 continue;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
305 fprintf(outFILE, "NET %s", n->name);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
306 col = 4 + strlen(n->name);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
307 do {
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
308 fputc('\t', outFILE);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
309 col += 8;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
310 col &= ~7;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
311 } while (col < net_comment_column);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
312 fprintf(outFILE, "# %d points\n", nx->npoints);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
313 }
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
314 }
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
315
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
316 static void
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
317 generate_output()
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
318 {
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
319 if (output_filename) {
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
320 outFILE = fopen(output_filename, "w");
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
321 if (!outFILE) {
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
322 perror(output_filename);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
323 exit(1);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
324 }
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
325 } else
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
326 outFILE = stdout;
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
327 fprintf(outFILE,
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
328 "# This netlist has been generated by unet-destar from %s\n",
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
329 input_filename);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
330 output_nets();
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
331 dump_tempfile();
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
332 if (outFILE != stdout)
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
333 fclose(outFILE);
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
334 }
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
335
24
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
336 main(argc, argv)
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
337 char **argv;
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
338 {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
339 if (argc < 2 || argc > 3) {
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
340 fprintf(stderr, "usage: %s input.unet [output.unet]\n",
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
341 argv[0]);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
342 exit(1);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
343 }
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
344 input_filename = argv[1];
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
345 output_filename = argv[2];
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
346 process_input_unet();
27
d14bf25b5e26 unet-destar: forgot to call find_net_comment_column()
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 26
diff changeset
347 find_net_comment_column();
26
b2b60ec8d9ca unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 24
diff changeset
348 generate_output();
24
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
349 exit(0);
7e8a2cb54b6b started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
350 }