FreeCalypso > hg > ueda-linux
diff ueda/sverp-bind/outcomp.c @ 12:51893347bc42
unet-bind implementation started
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 01 Aug 2015 23:33:05 +0000 |
parents | |
children | 068ea2458c5d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ueda/sverp-bind/outcomp.c Sat Aug 01 23:33:05 2015 +0000 @@ -0,0 +1,94 @@ +#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(); + +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; + + 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; +} + +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); + } +}