comparison ueda/uschem-netlist/pinconn.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 /*
2 * Recording of pin connections
3 */
4
5 #include <stdio.h>
6 #include <strings.h>
7 #include "../libueda/mcl.h"
8 #include "netlist.h"
9
10 extern char *malloc();
11
12 int total_pin_connections;
13 int total_expl_noconnects;
14
15 extern struct net noconnect_pseudo_net;
16
17 struct pinconn *
18 alloc_pinconn()
19 {
20 register struct pinconn *pc;
21
22 pc = (struct pinconn *) malloc(sizeof(struct pinconn));
23 if (!pc) {
24 perror("malloc");
25 exit(1);
26 }
27 bzero(pc, sizeof(struct pinconn));
28 return(pc);
29 }
30
31 static
32 report_connection(pc)
33 register struct pinconn *pc;
34 {
35 register struct net *n;
36
37 n = pc->net;
38 if (n->netname)
39 fprintf(stderr, "assigned to net %s by %s line %d\n",
40 n->netname, pc->origin_file, pc->origin_line);
41 else
42 fprintf(stderr, "assigned to an unnamed net by %s line %d\n",
43 pc->origin_file, pc->origin_line);
44 }
45
46 record_pin_connection(pc)
47 register struct pinconn *pc;
48 {
49 register struct nlcomp *nlc;
50 register struct net *n;
51 int stat;
52
53 nlc = pc->comp;
54 if (nlc->npins)
55 stat = record_pin_connection_tab(pc);
56 else
57 stat = record_pin_connection_chain(pc);
58 if (stat)
59 return(stat);
60 n = pc->net;
61 pc->next_in_net = n->pins;
62 n->pins = pc;
63 n->npoints++;
64 if (n != &noconnect_pseudo_net) {
65 nlc->nconnects++;
66 total_pin_connections++;
67 } else
68 total_expl_noconnects++;
69 return(0);
70 }
71
72 static
73 record_pin_connection_tab(pc)
74 register struct pinconn *pc;
75 {
76 register struct nlcomp *nlc;
77 register int n;
78
79 nlc = pc->comp;
80 n = atoi(pc->pinnum);
81 if (n < 1 || n > nlc->npins) {
82 fprintf(stderr, "%s: line %d: %s pin number %s is invalid\n",
83 pc->origin_file, pc->origin_line, nlc->mclcomp->name,
84 pc->pinnum);
85 exit(1);
86 }
87 n--;
88 if (nlc->pintab[n]) {
89 if (nlc->pintab[n]->net == pc->net) /* same pin to same net? */
90 return(1); /* redundant but harmless */
91 fprintf(stderr,
92 "%s pin %s is connected to more than one net:\n",
93 nlc->mclcomp->name, pc->pinnum);
94 report_connection(nlc->pintab[n]);
95 report_connection(pc);
96 exit(1);
97 }
98 nlc->pintab[n] = pc;
99 return(0);
100 }
101
102 static
103 record_pin_connection_chain(pc)
104 register struct pinconn *pc;
105 {
106 struct nlcomp *nlc;
107 struct component *comp;
108 register struct pinconn *s, **sp;
109
110 nlc = pc->comp;
111 comp = nlc->mclcomp;
112 for (sp = &nlc->pinchain; s = *sp; sp = &s->next_in_comp)
113 if (!strcmp(s->pinnum, pc->pinnum)) {
114 if (s->net == pc->net) /* same pin to same net? */
115 return(1); /* redundant but harmless */
116 fprintf(stderr,
117 "%s pin %s is connected to more than one net:\n",
118 comp->name, pc->pinnum);
119 report_connection(s);
120 report_connection(pc);
121 exit(1);
122 }
123 *sp = pc;
124 return(0);
125 }