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