annotate ueda/unet-bind/output.c @ 123:47873f218c37

SIM_Socket_TI.fp added
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 05 Jul 2020 20:16:04 +0000
parents ffab0a4424ad
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <stdio.h>
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <stdlib.h>
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <string.h>
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 #include <strings.h>
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include "../libueda/xga.h"
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include "../libunet/nethash.h"
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include "struct.h"
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8
32
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
9 extern char *get_comp_attr();
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
10
22
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 extern char *MCLfile;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 extern char *input_filename;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 extern char *output_filename;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 extern struct net *net_list_head;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 extern int ncomponents;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17 extern struct outcomp *netlist_comps;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 extern struct outcomp *starpoint_list_head;
32
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
19 extern struct wantattr *want_attr_list;
22
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 static FILE *outF;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 generate_output()
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 if (output_filename) {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 outF = fopen(output_filename, "w");
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 if (!outF) {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 perror(output_filename);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 exit(1);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 } else
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 outF = stdout;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 fprintf(outF, "# This netlist has been generated by unet-bind\n");
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 fprintf(outF, "# from %s and %s\n", MCLfile, input_filename);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 if (net_list_head)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 emit_output_nets();
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 if (starpoint_list_head)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 emit_output_starpoints();
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 if (ncomponents)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 emit_output_components();
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 if (outF != stdout)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 fclose(outF);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 emit_output_nets()
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 register struct net *n;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 fprintf(outF, "\n# Nets unchanged from %s:\n#\n", input_filename);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 for (n = net_list_head; n; n = n->nextinlist)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 fprintf(outF, "NET %s\n", n->name);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 emit_output_components()
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 register int n;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 fprintf(outF, "\n# %d components from MCL:\n", ncomponents);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 for (n = 0; n < ncomponents; n++)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 emit_component_block(netlist_comps + n, "COMPONENT");
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 emit_output_starpoints()
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 register struct outcomp *oc;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 fprintf(outF, "\n# Star connection points:\n");
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 for (oc = starpoint_list_head; oc; oc = oc->next)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 emit_component_block(oc, "STARPOINT");
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 static void
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 emit_output_pin_number(oc, pinidx)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 register struct outcomp *oc;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 register int pinidx;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77 register struct grid_pkg_desc *xga = oc->grid_pkg;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 int r, c;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
79
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 if (!xga) {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 fprintf(outF, "%d", pinidx + 1);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82 return;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
84 r = pinidx / xga->ncolumns;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
85 c = pinidx % xga->ncolumns;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
86 fprintf(outF, "%c%d", xga->row_letters[r], c + 1);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
87 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
88
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
89 static void
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
90 emit_output_pin_line(oc, pinidx)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
91 register struct outcomp *oc;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
92 int pinidx;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
93 {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
94 register struct pinconn *conn;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
95
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
96 fputs(" PIN ", outF);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
97 emit_output_pin_number(oc, pinidx);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
98 fputs(" = ", outF);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
99 conn = oc->conn_array[pinidx];
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
100 if (!conn) {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
101 fprintf(outF, "NC (unet-bind found no connection)\n");
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
102 return;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
103 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
104 if (conn->net)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
105 fprintf(outF, "NET %s\n", conn->net->name);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
106 else
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
107 fprintf(outF, "NC (%s)\n", conn->nc_comment);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
108 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
109
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
110 emit_component_block(oc, comp_type_kw)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
111 register struct outcomp *oc;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
112 char *comp_type_kw;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
113 {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
114 register int pinidx;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
115
23
558269596a5c unet-bind output spacing fix
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 22
diff changeset
116 fprintf(outF, "\n%s %s {\n", comp_type_kw, oc->name);
22
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
117 if (oc->altname)
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
118 fprintf(outF, " ALTNAME %s\n", oc->altname);
32
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
119 if (want_attr_list && oc->mclcomp)
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
120 emit_component_attributes(oc->mclcomp);
22
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
121 for (pinidx = 0; pinidx < oc->npins; pinidx++) {
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
122 if (oc->grid_pkg && oc->grid_pkg->holes_array[pinidx])
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
123 continue;
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
124 emit_output_pin_line(oc, pinidx);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
125 }
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
126 fputs("}\n", outF);
c7ebd6179f5d ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
127 }
32
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
128
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
129 emit_component_attributes(comp)
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
130 struct component *comp;
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
131 {
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
132 register struct wantattr *wa;
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
133 register char *value;
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
134
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
135 for (wa = want_attr_list; wa; wa = wa->next) {
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
136 value = get_comp_attr(comp, wa->name);
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
137 if (!value)
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
138 continue;
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
139 fprintf(outF, " ATTR %s=%s\n", wa->name, value);
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
140 }
6c7c79d37eff unet-bind: attribute output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 23
diff changeset
141 }