FreeCalypso > hg > ueda-linux
changeset 22:c7ebd6179f5d
ueda-bind: output implemented
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 02 Aug 2015 07:21:06 +0000 |
parents | f7b09a54c2ce |
children | 558269596a5c |
files | ueda/sverp-bind/Makefile ueda/sverp-bind/main.c ueda/sverp-bind/output.c |
diffstat | 3 files changed, 124 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ueda/sverp-bind/Makefile Sun Aug 02 06:34:09 2015 +0000 +++ b/ueda/sverp-bind/Makefile Sun Aug 02 07:21:06 2015 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -OBJS= enterinst.o insthash.o main.o outcomp.o readunet.o starpoints.o +OBJS= enterinst.o insthash.o main.o outcomp.o output.o readunet.o starpoints.o LIBS= ../libunet/libunet.a ../libueda/libueda.a PROG= unet-bind BINDIR= /usr/local/bin
--- a/ueda/sverp-bind/main.c Sun Aug 02 06:34:09 2015 +0000 +++ b/ueda/sverp-bind/main.c Sun Aug 02 07:21:06 2015 +0000 @@ -73,7 +73,6 @@ exit(1); } check_unclaimed_instances(); - - /* output remains to be implemented */ + generate_output(); exit(0); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ueda/sverp-bind/output.c Sun Aug 02 07:21:06 2015 +0000 @@ -0,0 +1,122 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "../libueda/xga.h" +#include "../libunet/nethash.h" +#include "struct.h" + +extern char *MCLfile; +extern char *input_filename; +extern char *output_filename; + +extern struct net *net_list_head; +extern int ncomponents; +extern struct outcomp *netlist_comps; +extern struct outcomp *starpoint_list_head; + +static FILE *outF; + +generate_output() +{ + if (output_filename) { + outF = fopen(output_filename, "w"); + if (!outF) { + perror(output_filename); + exit(1); + } + } else + outF = stdout; + fprintf(outF, "# This netlist has been generated by unet-bind\n"); + fprintf(outF, "# from %s and %s\n", MCLfile, input_filename); + if (net_list_head) + emit_output_nets(); + if (starpoint_list_head) + emit_output_starpoints(); + if (ncomponents) + emit_output_components(); + if (outF != stdout) + fclose(outF); +} + +emit_output_nets() +{ + register struct net *n; + + fprintf(outF, "\n# Nets unchanged from %s:\n#\n", input_filename); + for (n = net_list_head; n; n = n->nextinlist) + fprintf(outF, "NET %s\n", n->name); +} + +emit_output_components() +{ + register int n; + + fprintf(outF, "\n# %d components from MCL:\n", ncomponents); + for (n = 0; n < ncomponents; n++) + emit_component_block(netlist_comps + n, "COMPONENT"); +} + +emit_output_starpoints() +{ + register struct outcomp *oc; + + fprintf(outF, "\n# Star connection points:\n"); + for (oc = starpoint_list_head; oc; oc = oc->next) + emit_component_block(oc, "STARPOINT"); +} + +static void +emit_output_pin_number(oc, pinidx) + register struct outcomp *oc; + register int pinidx; +{ + register struct grid_pkg_desc *xga = oc->grid_pkg; + int r, c; + + if (!xga) { + fprintf(outF, "%d", pinidx + 1); + return; + } + r = pinidx / xga->ncolumns; + c = pinidx % xga->ncolumns; + fprintf(outF, "%c%d", xga->row_letters[r], c + 1); +} + +static void +emit_output_pin_line(oc, pinidx) + register struct outcomp *oc; + int pinidx; +{ + register struct pinconn *conn; + + fputs(" PIN ", outF); + emit_output_pin_number(oc, pinidx); + fputs(" = ", outF); + conn = oc->conn_array[pinidx]; + if (!conn) { + fprintf(outF, "NC (unet-bind found no connection)\n"); + return; + } + if (conn->net) + fprintf(outF, "NET %s\n", conn->net->name); + else + fprintf(outF, "NC (%s)\n", conn->nc_comment); +} + +emit_component_block(oc, comp_type_kw) + register struct outcomp *oc; + char *comp_type_kw; +{ + register int pinidx; + + fprintf(outF, "%s %s {\n", comp_type_kw, oc->name); + if (oc->altname) + fprintf(outF, " ALTNAME %s\n", oc->altname); + for (pinidx = 0; pinidx < oc->npins; pinidx++) { + if (oc->grid_pkg && oc->grid_pkg->holes_array[pinidx]) + continue; + emit_output_pin_line(oc, pinidx); + } + fputs("}\n", outF); +}