FreeCalypso > hg > ueda-linux
view ueda/unet-bind/output.c @ 110:b4b67773d766
TSSOP14_MNF.fp created
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 01 Jun 2020 17:17:48 +0000 |
parents | ffab0a4424ad |
children |
line wrap: on
line source
#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 *get_comp_attr(); 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; extern struct wantattr *want_attr_list; 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, "\n%s %s {\n", comp_type_kw, oc->name); if (oc->altname) fprintf(outF, " ALTNAME %s\n", oc->altname); if (want_attr_list && oc->mclcomp) emit_component_attributes(oc->mclcomp); 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); } emit_component_attributes(comp) struct component *comp; { register struct wantattr *wa; register char *value; for (wa = want_attr_list; wa; wa = wa->next) { value = get_comp_attr(comp, wa->name); if (!value) continue; fprintf(outF, " ATTR %s=%s\n", wa->name, value); } }