# HG changeset patch # User Space Falcon # Date 1438893451 0 # Node ID b2b60ec8d9cace16f5cab85c301a76ecfb27ad88 # Parent ace4f60773caf55dbd9491b897b148cbc919770c unet-destar: output implemented diff -r ace4f60773ca -r b2b60ec8d9ca ueda/unet-utils/unet-destar.c --- a/ueda/unet-utils/unet-destar.c Thu Aug 06 20:22:24 2015 +0000 +++ b/ueda/unet-utils/unet-destar.c Thu Aug 06 20:37:31 2015 +0000 @@ -8,13 +8,15 @@ extern struct net *enter_net_object(); extern struct net *find_net_by_name(); +extern struct net *net_list_head; static char *input_filename, *output_filename; static struct unetrd_state rdstate; static struct unetrd_out rdout; -static int total_input_nets; +static int total_input_nets, total_output_nets; static struct net *starpoint_head; static FILE *tempFILE, *outFILE; +static int net_comment_column; struct netextra { struct net *squashed_to; @@ -258,6 +260,74 @@ } } +static void +find_net_comment_column() +{ + register struct net *n; + register struct netextra *nx; + register int len, maxlen; + + maxlen = 0; + for (n = net_list_head; n; n = n->nextinlist) { + nx = (struct netextra *)(n + 1); + if (nx->squashed_to) + continue; + total_output_nets++; + len = strlen(n->name); + if (len > maxlen) + maxlen = len; + } + maxlen += 4; + do + maxlen++; + while (maxlen % 8); + net_comment_column = maxlen; +} + +static void +output_nets() +{ + register struct net *n; + register struct netextra *nx; + register int col; + + fprintf(outFILE, "\n# %d input nets reduced to %d joined nets:\n#\n", + total_input_nets, total_output_nets); + for (n = net_list_head; n; n = n->nextinlist) { + nx = (struct netextra *)(n + 1); + if (nx->squashed_to) + continue; + fprintf(outFILE, "NET %s", n->name); + col = 4 + strlen(n->name); + do { + fputc('\t', outFILE); + col += 8; + col &= ~7; + } while (col < net_comment_column); + fprintf(outFILE, "# %d points\n", nx->npoints); + } +} + +static void +generate_output() +{ + if (output_filename) { + outFILE = fopen(output_filename, "w"); + if (!outFILE) { + perror(output_filename); + exit(1); + } + } else + outFILE = stdout; + fprintf(outFILE, + "# This netlist has been generated by unet-destar from %s\n", + input_filename); + output_nets(); + dump_tempfile(); + if (outFILE != stdout) + fclose(outFILE); +} + main(argc, argv) char **argv; { @@ -269,6 +339,6 @@ input_filename = argv[1]; output_filename = argv[2]; process_input_unet(); - /* output remains to be implemented */ + generate_output(); exit(0); }