comparison ueda/uschem-netlist/nlcomp.c @ 0:cd92449fdb51

initial import of ueda and ifctf-part-lib from ifctfvax CVS
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 20 Jul 2015 00:24:37 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cd92449fdb51
1 #include <sys/types.h>
2 #include <stdio.h>
3 #include "../libueda/mcl.h"
4 #include "netlist.h"
5
6 extern char *malloc();
7
8 extern struct component components[];
9 extern int ncomponents;
10
11 extern char *get_comp_attr();
12
13 struct nlcomp *netlist_comps;
14
15 alloc_nlcomp_array()
16 {
17 register int i;
18
19 netlist_comps = (struct nlcomp *)
20 malloc(sizeof(struct nlcomp) * ncomponents);
21 if (!netlist_comps) {
22 perror("malloc");
23 exit(1);
24 }
25 bzero(netlist_comps, sizeof(struct nlcomp) * ncomponents);
26 for (i = 0; i < ncomponents; i++) {
27 netlist_comps[i].mclcomp = components + i;
28 fill_nlcomp(netlist_comps + i);
29 }
30 }
31
32 fill_nlcomp(nlc)
33 register struct nlcomp *nlc;
34 {
35 char *npins_attr;
36 register int n;
37 register struct pinconn **pintab;
38
39 npins_attr = get_comp_attr(nlc->mclcomp, "npins");
40 if (!npins_attr)
41 return;
42 n = atoi(npins_attr);
43 if (n <= 0) {
44 fprintf(stderr, "%s: invalid npins attribute\n",
45 nlc->mclcomp->name);
46 exit(1);
47 }
48 nlc->npins = n;
49 pintab = (struct pinconn **) malloc(sizeof(struct pinconn *) * n);
50 if (!pintab) {
51 perror("malloc");
52 exit(1);
53 }
54 bzero(pintab, sizeof(struct pinconn *) * n);
55 nlc->pintab = pintab;
56 }
57
58 struct nlcomp *
59 mclcomp_to_nlcomp(comp)
60 struct component *comp;
61 {
62 return(netlist_comps + (comp - components));
63 }