comparison 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
comparison
equal deleted inserted replaced
11:73abf2c13884 12:51893347bc42
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <strings.h>
5 #include "../libueda/mcl.h"
6 #include "../libueda/xga.h"
7 #include "struct.h"
8
9 extern struct component components[];
10 extern int ncomponents;
11
12 extern char *get_comp_attr();
13 extern struct grid_pkg_desc *read_grid_pkg_file();
14
15 struct outcomp *netlist_comps;
16
17 static int
18 try_numpins(oc)
19 register struct outcomp *oc;
20 {
21 char *npins_attr;
22 register int n;
23
24 npins_attr = get_comp_attr(oc->mclcomp, "npins");
25 if (!npins_attr)
26 return(0);
27 n = atoi(npins_attr);
28 if (n <= 0) {
29 fprintf(stderr, "component %s: invalid npins attribute\n",
30 oc->name);
31 exit(1);
32 }
33 oc->npins = n;
34 return(1);
35 }
36
37 static int
38 try_gridpkg(oc)
39 register struct outcomp *oc;
40 {
41 char *attr;
42 register struct grid_pkg_desc *desc;
43
44 attr = get_comp_attr(oc->mclcomp, "grid_pkg");
45 if (!attr)
46 return(0);
47 desc = read_grid_pkg_file(attr);
48 oc->grid_pkg = desc;
49 oc->npins = desc->nrows * desc->ncolumns;
50 return(1);
51 }
52
53 static void
54 init_one_outcomp(oc)
55 register struct outcomp *oc;
56 {
57 register struct pinconn **conn_array;
58
59 oc->name = oc->mclcomp->name;
60 try_numpins(oc);
61 if (!oc->npins)
62 try_gridpkg(oc);
63 if (!oc->npins) {
64 fprintf(stderr,
65 "error: %s has neither npins nor grid_pkg attribute\n",
66 oc->name);
67 exit(1);
68 }
69 conn_array = (struct pinconn **) malloc(sizeof(struct pinconn *) *
70 oc->npins);
71 if (!conn_array) {
72 perror("malloc");
73 exit(1);
74 }
75 bzero(conn_array, sizeof(struct pinconn *) * oc->npins);
76 oc->conn_array = conn_array;
77 }
78
79 init_outcomp_from_MCL()
80 {
81 register int i;
82
83 netlist_comps = (struct outcomp *)
84 malloc(sizeof(struct outcomp) * ncomponents);
85 if (!netlist_comps) {
86 perror("malloc");
87 exit(1);
88 }
89 bzero(netlist_comps, sizeof(struct outcomp) * ncomponents);
90 for (i = 0; i < ncomponents; i++) {
91 netlist_comps[i].mclcomp = components + i;
92 init_one_outcomp(netlist_comps + i);
93 }
94 }