FreeCalypso > hg > ueda-linux
comparison ueda/unet-utils/unet-destar.c @ 26:b2b60ec8d9ca
unet-destar: output implemented
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Thu, 06 Aug 2015 20:37:31 +0000 |
parents | 7e8a2cb54b6b |
children | d14bf25b5e26 |
comparison
equal
deleted
inserted
replaced
25:ace4f60773ca | 26:b2b60ec8d9ca |
---|---|
6 #include "../libunet/unetrd.h" | 6 #include "../libunet/unetrd.h" |
7 #include "../libunet/nethash.h" | 7 #include "../libunet/nethash.h" |
8 | 8 |
9 extern struct net *enter_net_object(); | 9 extern struct net *enter_net_object(); |
10 extern struct net *find_net_by_name(); | 10 extern struct net *find_net_by_name(); |
11 extern struct net *net_list_head; | |
11 | 12 |
12 static char *input_filename, *output_filename; | 13 static char *input_filename, *output_filename; |
13 static struct unetrd_state rdstate; | 14 static struct unetrd_state rdstate; |
14 static struct unetrd_out rdout; | 15 static struct unetrd_out rdout; |
15 static int total_input_nets; | 16 static int total_input_nets, total_output_nets; |
16 static struct net *starpoint_head; | 17 static struct net *starpoint_head; |
17 static FILE *tempFILE, *outFILE; | 18 static FILE *tempFILE, *outFILE; |
19 static int net_comment_column; | |
18 | 20 |
19 struct netextra { | 21 struct netextra { |
20 struct net *squashed_to; | 22 struct net *squashed_to; |
21 int npoints; | 23 int npoints; |
22 }; | 24 }; |
256 exit(1); | 258 exit(1); |
257 } | 259 } |
258 } | 260 } |
259 } | 261 } |
260 | 262 |
263 static void | |
264 find_net_comment_column() | |
265 { | |
266 register struct net *n; | |
267 register struct netextra *nx; | |
268 register int len, maxlen; | |
269 | |
270 maxlen = 0; | |
271 for (n = net_list_head; n; n = n->nextinlist) { | |
272 nx = (struct netextra *)(n + 1); | |
273 if (nx->squashed_to) | |
274 continue; | |
275 total_output_nets++; | |
276 len = strlen(n->name); | |
277 if (len > maxlen) | |
278 maxlen = len; | |
279 } | |
280 maxlen += 4; | |
281 do | |
282 maxlen++; | |
283 while (maxlen % 8); | |
284 net_comment_column = maxlen; | |
285 } | |
286 | |
287 static void | |
288 output_nets() | |
289 { | |
290 register struct net *n; | |
291 register struct netextra *nx; | |
292 register int col; | |
293 | |
294 fprintf(outFILE, "\n# %d input nets reduced to %d joined nets:\n#\n", | |
295 total_input_nets, total_output_nets); | |
296 for (n = net_list_head; n; n = n->nextinlist) { | |
297 nx = (struct netextra *)(n + 1); | |
298 if (nx->squashed_to) | |
299 continue; | |
300 fprintf(outFILE, "NET %s", n->name); | |
301 col = 4 + strlen(n->name); | |
302 do { | |
303 fputc('\t', outFILE); | |
304 col += 8; | |
305 col &= ~7; | |
306 } while (col < net_comment_column); | |
307 fprintf(outFILE, "# %d points\n", nx->npoints); | |
308 } | |
309 } | |
310 | |
311 static void | |
312 generate_output() | |
313 { | |
314 if (output_filename) { | |
315 outFILE = fopen(output_filename, "w"); | |
316 if (!outFILE) { | |
317 perror(output_filename); | |
318 exit(1); | |
319 } | |
320 } else | |
321 outFILE = stdout; | |
322 fprintf(outFILE, | |
323 "# This netlist has been generated by unet-destar from %s\n", | |
324 input_filename); | |
325 output_nets(); | |
326 dump_tempfile(); | |
327 if (outFILE != stdout) | |
328 fclose(outFILE); | |
329 } | |
330 | |
261 main(argc, argv) | 331 main(argc, argv) |
262 char **argv; | 332 char **argv; |
263 { | 333 { |
264 if (argc < 2 || argc > 3) { | 334 if (argc < 2 || argc > 3) { |
265 fprintf(stderr, "usage: %s input.unet [output.unet]\n", | 335 fprintf(stderr, "usage: %s input.unet [output.unet]\n", |
267 exit(1); | 337 exit(1); |
268 } | 338 } |
269 input_filename = argv[1]; | 339 input_filename = argv[1]; |
270 output_filename = argv[2]; | 340 output_filename = argv[2]; |
271 process_input_unet(); | 341 process_input_unet(); |
272 /* output remains to be implemented */ | 342 generate_output(); |
273 exit(0); | 343 exit(0); |
274 } | 344 } |