FreeCalypso > hg > ueda-linux
annotate ueda/unet-utils/unet-destar.c @ 27:d14bf25b5e26
unet-destar: forgot to call find_net_comment_column()
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Thu, 06 Aug 2015 20:40:19 +0000 |
parents | b2b60ec8d9ca |
children | a93e4b07fdf3 |
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: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 continue; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 case UNETOBJ_PIN: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 if (!rdout.connect_to_net) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 "%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
|
120 input_filename, rdstate.lineno); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 if (!starpoint_head) |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 process_starpoint_head(); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 else |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 process_starpoint_arm(); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 continue; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 case UNETOBJ_PINMAP: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 "%s line %d: PINMAP meaningless in a STARPOINT block\n", |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 input_filename, rdstate.lineno); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 default: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 "%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
|
136 input_filename, rdstate.lineno, rdout.keyword); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 } |
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 static void |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 process_component_pin() |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 register struct net *n; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 register struct netextra *nx; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 if (!rdout.connect_to_net) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 fprintf(tempFILE, " %s %s = NC (%s)\n", rdout.keyword, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 rdout.objname, rdout.nc_comment); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 return; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 n = find_net_by_name(rdout.connect_to_net); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 for (;;) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 nx = (struct netextra *)(n + 1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 if (!nx->squashed_to) |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 break; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 n = nx->squashed_to; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 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
|
161 n->name); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 nx->npoints++; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 } |
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 static void |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 process_component() |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 fprintf(tempFILE, "\nCOMPONENT %s {\n", rdout.objname); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 for (;;) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 if (!read_unet_line(&rdstate, &rdout)) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 fprintf(stderr, "%s error: EOF in COMPONENT block\n", |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 input_filename); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 if (rdout.typecode == UNETOBJ_CLOSINGBRACE) |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 break; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 switch(rdout.typecode) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 case UNETOBJ_PRIMITIVE: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 case UNETOBJ_ALTNAME: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 fprintf(tempFILE, " %s %s\n", rdout.keyword, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 rdout.objname); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 continue; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 case UNETOBJ_PIN: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 case UNETOBJ_PINMAP: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 process_component_pin(); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 continue; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 default: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 "%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
|
190 input_filename, rdstate.lineno, rdout.keyword); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
192 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
193 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
194 fputs("}\n", tempFILE); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
195 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
196 |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 static void |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 process_input_unet() |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 struct net *n; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
201 int state = 0; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
202 |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 open_unet_input_file(input_filename, &rdstate); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 while (read_unet_line(&rdstate, &rdout)) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 switch(rdout.typecode) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 case UNETOBJ_CLOSINGBRACE: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
208 "%s line %d: unexpected '}' outside of component block\n", |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
209 input_filename, rdstate.lineno); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
210 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 case UNETOBJ_NET: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
212 if (state == 0) |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
213 state = 1; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
214 else if (state > 1) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
215 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 "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
|
217 input_filename, rdstate.lineno); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
218 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 n = enter_net_object(rdout.objname, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
221 sizeof(struct netextra)); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
222 bzero(n + 1, sizeof(struct netextra)); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
223 total_input_nets++; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
224 continue; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
225 case UNETOBJ_STARPOINT: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
226 if (state < 1) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
227 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
228 "error (%s line %d): STARPOINT without any preceding NETs\n", |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
229 input_filename, rdstate.lineno); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
230 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
231 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
232 if (state > 2) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
233 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
234 "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
|
235 input_filename, rdstate.lineno); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
236 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
237 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
238 state = 2; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 process_starpoint(); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
240 continue; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 case UNETOBJ_COMPONENT: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
242 if (state < 1) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
243 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
244 "error (%s line %d): COMPONENT without any preceding NETs\n", |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 input_filename, rdstate.lineno); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
246 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
247 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
248 if (state < 3) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
249 tempFILE = tempfile(); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
250 state = 3; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
251 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
252 process_component(); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
253 continue; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
254 default: |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
255 fprintf(stderr, |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 "%s line %d: unexpected object type %s\n", |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
257 input_filename, rdstate.lineno, rdout.keyword); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 exit(1); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
259 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
260 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
261 } |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
262 |
26
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
263 static void |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
264 find_net_comment_column() |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
265 { |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
266 register struct net *n; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
267 register struct netextra *nx; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
268 register int len, maxlen; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
269 |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
270 maxlen = 0; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
271 for (n = net_list_head; n; n = n->nextinlist) { |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
272 nx = (struct netextra *)(n + 1); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
273 if (nx->squashed_to) |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
274 continue; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
275 total_output_nets++; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
276 len = strlen(n->name); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
277 if (len > maxlen) |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
278 maxlen = len; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
279 } |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
280 maxlen += 4; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
281 do |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
282 maxlen++; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
283 while (maxlen % 8); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
284 net_comment_column = maxlen; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
285 } |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
286 |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
287 static void |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
288 output_nets() |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
289 { |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
290 register struct net *n; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
291 register struct netextra *nx; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
292 register int col; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
293 |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
294 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
|
295 total_input_nets, total_output_nets); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
296 for (n = net_list_head; n; n = n->nextinlist) { |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
297 nx = (struct netextra *)(n + 1); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
298 if (nx->squashed_to) |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
299 continue; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
300 fprintf(outFILE, "NET %s", n->name); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
301 col = 4 + strlen(n->name); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
302 do { |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
303 fputc('\t', outFILE); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
304 col += 8; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
305 col &= ~7; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
306 } while (col < net_comment_column); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
307 fprintf(outFILE, "# %d points\n", nx->npoints); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
308 } |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
309 } |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
310 |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
311 static void |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
312 generate_output() |
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 if (output_filename) { |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
315 outFILE = fopen(output_filename, "w"); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
316 if (!outFILE) { |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
317 perror(output_filename); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
318 exit(1); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
319 } |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
320 } else |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
321 outFILE = stdout; |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
322 fprintf(outFILE, |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
323 "# 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
|
324 input_filename); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
325 output_nets(); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
326 dump_tempfile(); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
327 if (outFILE != stdout) |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
328 fclose(outFILE); |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
329 } |
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
330 |
24
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
331 main(argc, argv) |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
332 char **argv; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
333 { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
334 if (argc < 2 || argc > 3) { |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
335 fprintf(stderr, "usage: %s input.unet [output.unet]\n", |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
336 argv[0]); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
337 exit(1); |
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 input_filename = argv[1]; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
340 output_filename = argv[2]; |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
341 process_input_unet(); |
27
d14bf25b5e26
unet-destar: forgot to call find_net_comment_column()
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
26
diff
changeset
|
342 find_net_comment_column(); |
26
b2b60ec8d9ca
unet-destar: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
24
diff
changeset
|
343 generate_output(); |
24
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
344 exit(0); |
7e8a2cb54b6b
started implementing unet-destar
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
345 } |