FreeCalypso > hg > ueda-linux
comparison ueda/unet-bind/outcomp.c @ 101:ffab0a4424ad
ueda: unet-bind program moved into sensibly named unet-bind subdir
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 29 Sep 2019 22:42:41 +0000 |
parents | ueda/sverp-bind/outcomp.c@c59f52e4bacf |
children |
comparison
equal
deleted
inserted
replaced
100:071b24bca546 | 101:ffab0a4424ad |
---|---|
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 extern int check_completeness; | |
16 | |
17 struct outcomp *netlist_comps; | |
18 | |
19 static int | |
20 try_numpins(oc) | |
21 register struct outcomp *oc; | |
22 { | |
23 char *npins_attr; | |
24 register int n; | |
25 | |
26 npins_attr = get_comp_attr(oc->mclcomp, "npins"); | |
27 if (!npins_attr) | |
28 return(0); | |
29 n = atoi(npins_attr); | |
30 if (n <= 0) { | |
31 fprintf(stderr, "component %s: invalid npins attribute\n", | |
32 oc->name); | |
33 exit(1); | |
34 } | |
35 oc->npins = n; | |
36 return(1); | |
37 } | |
38 | |
39 static int | |
40 try_gridpkg(oc) | |
41 register struct outcomp *oc; | |
42 { | |
43 char *attr; | |
44 register struct grid_pkg_desc *desc; | |
45 | |
46 attr = get_comp_attr(oc->mclcomp, "grid_pkg"); | |
47 if (!attr) | |
48 return(0); | |
49 desc = read_grid_pkg_file(attr); | |
50 oc->grid_pkg = desc; | |
51 oc->npins = desc->nrows * desc->ncolumns; | |
52 return(1); | |
53 } | |
54 | |
55 static void | |
56 init_one_outcomp(oc) | |
57 register struct outcomp *oc; | |
58 { | |
59 register struct pinconn **conn_array; | |
60 register char *attr; | |
61 | |
62 oc->name = oc->mclcomp->name; | |
63 try_numpins(oc); | |
64 if (!oc->npins) | |
65 try_gridpkg(oc); | |
66 if (!oc->npins) { | |
67 fprintf(stderr, | |
68 "error: %s has neither npins nor grid_pkg attribute\n", | |
69 oc->name); | |
70 exit(1); | |
71 } | |
72 conn_array = (struct pinconn **) malloc(sizeof(struct pinconn *) * | |
73 oc->npins); | |
74 if (!conn_array) { | |
75 perror("malloc"); | |
76 exit(1); | |
77 } | |
78 bzero(conn_array, sizeof(struct pinconn *) * oc->npins); | |
79 oc->conn_array = conn_array; | |
80 if (attr = get_comp_attr(oc->mclcomp, "hier")) | |
81 process_hier_attr(oc, attr); | |
82 else if (attr = get_comp_attr(oc->mclcomp, "slotmap")) | |
83 process_slotmap_attr(oc, attr); | |
84 else if (check_completeness) | |
85 fprintf(stderr, "MCL component %s has no binding\n", oc->name); | |
86 } | |
87 | |
88 init_outcomp_from_MCL() | |
89 { | |
90 register int i; | |
91 | |
92 netlist_comps = (struct outcomp *) | |
93 malloc(sizeof(struct outcomp) * ncomponents); | |
94 if (!netlist_comps) { | |
95 perror("malloc"); | |
96 exit(1); | |
97 } | |
98 bzero(netlist_comps, sizeof(struct outcomp) * ncomponents); | |
99 for (i = 0; i < ncomponents; i++) { | |
100 netlist_comps[i].mclcomp = components + i; | |
101 init_one_outcomp(netlist_comps + i); | |
102 } | |
103 } |