FreeCalypso > hg > ueda-linux
view ueda/unet-bind/outcomp.c @ 139:bf188727e606
donl-rename-parts reader: no tEDAx-style escapes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 07 Sep 2020 04:25:11 +0000 |
parents | ffab0a4424ad |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "../libueda/mcl.h" #include "../libueda/xga.h" #include "struct.h" extern struct component components[]; extern int ncomponents; extern char *get_comp_attr(); extern struct grid_pkg_desc *read_grid_pkg_file(); extern int check_completeness; struct outcomp *netlist_comps; static int try_numpins(oc) register struct outcomp *oc; { char *npins_attr; register int n; npins_attr = get_comp_attr(oc->mclcomp, "npins"); if (!npins_attr) return(0); n = atoi(npins_attr); if (n <= 0) { fprintf(stderr, "component %s: invalid npins attribute\n", oc->name); exit(1); } oc->npins = n; return(1); } static int try_gridpkg(oc) register struct outcomp *oc; { char *attr; register struct grid_pkg_desc *desc; attr = get_comp_attr(oc->mclcomp, "grid_pkg"); if (!attr) return(0); desc = read_grid_pkg_file(attr); oc->grid_pkg = desc; oc->npins = desc->nrows * desc->ncolumns; return(1); } static void init_one_outcomp(oc) register struct outcomp *oc; { register struct pinconn **conn_array; register char *attr; oc->name = oc->mclcomp->name; try_numpins(oc); if (!oc->npins) try_gridpkg(oc); if (!oc->npins) { fprintf(stderr, "error: %s has neither npins nor grid_pkg attribute\n", oc->name); exit(1); } conn_array = (struct pinconn **) malloc(sizeof(struct pinconn *) * oc->npins); if (!conn_array) { perror("malloc"); exit(1); } bzero(conn_array, sizeof(struct pinconn *) * oc->npins); oc->conn_array = conn_array; if (attr = get_comp_attr(oc->mclcomp, "hier")) process_hier_attr(oc, attr); else if (attr = get_comp_attr(oc->mclcomp, "slotmap")) process_slotmap_attr(oc, attr); else if (check_completeness) fprintf(stderr, "MCL component %s has no binding\n", oc->name); } init_outcomp_from_MCL() { register int i; netlist_comps = (struct outcomp *) malloc(sizeof(struct outcomp) * ncomponents); if (!netlist_comps) { perror("malloc"); exit(1); } bzero(netlist_comps, sizeof(struct outcomp) * ncomponents); for (i = 0; i < ncomponents; i++) { netlist_comps[i].mclcomp = components + i; init_one_outcomp(netlist_comps + i); } }