FreeCalypso > hg > ueda-linux
changeset 26:b2b60ec8d9ca
unet-destar: output implemented
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Thu, 06 Aug 2015 20:37:31 +0000 |
parents | ace4f60773ca |
children | d14bf25b5e26 |
files | ueda/unet-utils/unet-destar.c |
diffstat | 1 files changed, 72 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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); }