comparison ueda/unet-bind/main.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/main.c@61272ee5aadc
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 <unistd.h>
6 #include "struct.h"
7
8 extern char *MCLfile;
9
10 char *input_filename, *output_filename;
11 char *starpoints_file;
12 int check_completeness, unbound_instances;
13
14 struct wantattr *want_attr_list;
15 static struct wantattr **wantattr_tailp = &want_attr_list;
16
17 static void
18 add_wanted_attr(attr)
19 char *attr;
20 {
21 struct wantattr *wa;
22
23 wa = (struct wantattr *) malloc(sizeof(struct wantattr) +
24 strlen(attr) + 1);
25 if (!wa) {
26 perror("malloc");
27 exit(1);
28 }
29 wa->name = (char *)(wa + 1);
30 strcpy(wa->name, attr);
31 wa->next = 0;
32 *wantattr_tailp = wa;
33 wantattr_tailp = &wa->next;
34 }
35
36 static void
37 usage()
38 {
39 fprintf(stderr,
40 "usage: unet-bind [options] input.unet [output.unet]\n");
41 exit(1);
42 }
43
44 static void
45 process_options(argc, argv)
46 char **argv;
47 {
48 extern char *optarg;
49 register int c;
50
51 while ((c = getopt(argc, argv, "a:cI:M:s:")) != EOF) {
52 switch (c) {
53 case 'a':
54 add_wanted_attr(optarg);
55 continue;
56 case 'c':
57 check_completeness++;
58 continue;
59 case 'I':
60 add_symfile_dir(optarg);
61 continue;
62 case 'M':
63 MCLfile = optarg;
64 continue;
65 case 's':
66 starpoints_file = optarg;
67 continue;
68 default:
69 usage();
70 }
71 }
72 }
73
74 main(argc, argv)
75 char **argv;
76 {
77 extern int optind;
78
79 process_options(argc, argv);
80 if (argc < optind + 1 || argc > optind + 2)
81 usage();
82 input_filename = argv[optind];
83 output_filename = argv[optind+1];
84
85 /* process all inputs from the MCL */
86 read_MCL();
87 set_default_sympath();
88 read_pinouts();
89 init_outcomp_from_MCL();
90 /* do we have any star points? */
91 if (starpoints_file)
92 process_starpoints_file();
93 /* read the netlist from sverp */
94 process_input_unet();
95 if (unbound_instances) {
96 fprintf(stderr,
97 "error: %s input contains unbound instances, aborting\n",
98 input_filename);
99 exit(1);
100 }
101 check_unclaimed_instances();
102 generate_output();
103 exit(0);
104 }