annotate ueda/unet-utils/unet-excise.c @ 154:2328205328a9 default tip

m4-fp: WR-FPC 1mm pitch FFC/FPC connectors
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 25 Oct 2022 07:36:09 +0000
parents 7bdce91da1a5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
142
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <stdio.h>
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <stdlib.h>
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <string.h>
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <strings.h>
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include "../libunet/unetrd.h"
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 static char *input_filename;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 static char **excise_nets;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 static struct unetrd_state rdstate;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 static struct unetrd_out rdout;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 static void
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 process_net()
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char **ap;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 for (ap = excise_nets; *ap; ap++) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (!strcmp(*ap, rdout.objname)) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 printf("# net %s excised\n", *ap);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 return;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 printf("NET %s\n", rdout.objname);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 static void
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 process_component_pin()
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 char **ap;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (!rdout.connect_to_net) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 printf(" %s %s = NC (%s)\n", rdout.keyword, rdout.objname,
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 rdout.nc_comment);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 for (ap = excise_nets; *ap; ap++) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 if (!strcmp(*ap, rdout.connect_to_net)) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 printf(" %s %s = NC (net %s excised)\n",
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 rdout.keyword, rdout.objname, *ap);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 return;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 printf(" %s %s = NET %s\n", rdout.keyword, rdout.objname,
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 rdout.connect_to_net);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 static void
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 process_component()
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 printf("\nCOMPONENT %s {\n", rdout.objname);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 for (;;) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 if (!read_unet_line(&rdstate, &rdout)) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 fprintf(stderr, "%s error: EOF in COMPONENT block\n",
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 input_filename);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 exit(1);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 if (rdout.typecode == UNETOBJ_CLOSINGBRACE)
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 break;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 switch(rdout.typecode) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 case UNETOBJ_PRIMITIVE:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 case UNETOBJ_ALTNAME:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 printf(" %s %s\n", rdout.keyword, rdout.objname);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 continue;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 case UNETOBJ_ATTR:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 printf(" ATTR %s=%s\n", rdout.objname,
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 rdout.attr_value);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 continue;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 case UNETOBJ_PIN:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 case UNETOBJ_PINMAP:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 process_component_pin();
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 continue;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 default:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 fprintf(stderr,
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 "%s line %d: object type %s unexpected in COMPONENT block\n",
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 input_filename, rdstate.lineno, rdout.keyword);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 exit(1);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 puts("}");
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 static void
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 process_input_unet()
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 open_unet_input_file(input_filename, &rdstate);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 while (read_unet_line(&rdstate, &rdout)) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 switch(rdout.typecode) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 case UNETOBJ_CLOSINGBRACE:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 fprintf(stderr,
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 "%s line %d: unexpected '}' outside of component block\n",
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 input_filename, rdstate.lineno);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 exit(1);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 case UNETOBJ_NET:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 process_net();
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 continue;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 case UNETOBJ_COMPONENT:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 process_component();
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 continue;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 case UNETOBJ_STARPOINT:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 fprintf(stderr,
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 "error: STARPOINT objects not expected in unet-excise input (%s line %d)\n",
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 input_filename, rdstate.lineno);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 exit(1);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 default:
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 fprintf(stderr,
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 "%s line %d: unexpected object type %s\n",
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 input_filename, rdstate.lineno, rdout.keyword);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 exit(1);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 main(argc, argv)
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 char **argv;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 if (argc < 3) {
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 fprintf(stderr, "usage: %s input.unet excise-net[s]\n",
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 argv[0]);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 exit(1);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 }
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 input_filename = argv[1];
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 excise_nets = argv + 2;
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 process_input_unet();
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 exit(0);
7bdce91da1a5 unet-excise utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 }