FreeCalypso > hg > ueda-linux
annotate ueda/unet-bind/main.c @ 116:bb9908f36e23
m4-fp/qfpmnf.inc: basic fixes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 13 Jun 2020 04:14:10 +0000 |
parents | ffab0a4424ad |
children |
rev | line source |
---|---|
12
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 #include <stdio.h> |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 #include <stdlib.h> |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 #include <string.h> |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 #include <strings.h> |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <unistd.h> |
31
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
6 #include "struct.h" |
12
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 extern char *MCLfile; |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 char *input_filename, *output_filename; |
16
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
11 char *starpoints_file; |
19
1d4c693b8f35
unet-bind: sverp netlist reading implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
16
diff
changeset
|
12 int check_completeness, unbound_instances; |
12
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
31
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
14 struct wantattr *want_attr_list; |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
15 static struct wantattr **wantattr_tailp = &want_attr_list; |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
16 |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
17 static void |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
18 add_wanted_attr(attr) |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
19 char *attr; |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
20 { |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
21 struct wantattr *wa; |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
22 |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
23 wa = (struct wantattr *) malloc(sizeof(struct wantattr) + |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
24 strlen(attr) + 1); |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
25 if (!wa) { |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
26 perror("malloc"); |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
27 exit(1); |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
28 } |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
29 wa->name = (char *)(wa + 1); |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
30 strcpy(wa->name, attr); |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
31 wa->next = 0; |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
32 *wantattr_tailp = wa; |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
33 wantattr_tailp = &wa->next; |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
34 } |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
35 |
12
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 static void |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 usage() |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 { |
16
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
39 fprintf(stderr, |
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
40 "usage: unet-bind [options] input.unet [output.unet]\n"); |
12
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 exit(1); |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 } |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 static void |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 process_options(argc, argv) |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 char **argv; |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 { |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 extern char *optarg; |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 register int c; |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 |
31
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
51 while ((c = getopt(argc, argv, "a:cI:M:s:")) != EOF) { |
12
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 switch (c) { |
31
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
53 case 'a': |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
54 add_wanted_attr(optarg); |
61272ee5aadc
unet-bind: implemented -a option for specifying wanted attributes
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
22
diff
changeset
|
55 continue; |
15
c59f52e4bacf
unet-bind option -c reports MCL components with no binding
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
12
diff
changeset
|
56 case 'c': |
c59f52e4bacf
unet-bind option -c reports MCL components with no binding
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
12
diff
changeset
|
57 check_completeness++; |
16
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
58 continue; |
12
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 case 'I': |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 add_symfile_dir(optarg); |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 continue; |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 case 'M': |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 MCLfile = optarg; |
16
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
64 continue; |
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
65 case 's': |
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
66 starpoints_file = optarg; |
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
67 continue; |
12
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 default: |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 usage(); |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 } |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 } |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 } |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 main(argc, argv) |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 char **argv; |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 { |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 extern int optind; |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 process_options(argc, argv); |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 if (argc < optind + 1 || argc > optind + 2) |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 usage(); |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 input_filename = argv[optind]; |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 output_filename = argv[optind+1]; |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 /* process all inputs from the MCL */ |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 read_MCL(); |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 set_default_sympath(); |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 read_pinouts(); |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 init_outcomp_from_MCL(); |
16
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
90 /* do we have any star points? */ |
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
91 if (starpoints_file) |
65a515c20db8
unet-bind: starpoint entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
15
diff
changeset
|
92 process_starpoints_file(); |
19
1d4c693b8f35
unet-bind: sverp netlist reading implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
16
diff
changeset
|
93 /* read the netlist from sverp */ |
1d4c693b8f35
unet-bind: sverp netlist reading implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
16
diff
changeset
|
94 process_input_unet(); |
1d4c693b8f35
unet-bind: sverp netlist reading implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
16
diff
changeset
|
95 if (unbound_instances) { |
1d4c693b8f35
unet-bind: sverp netlist reading implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
16
diff
changeset
|
96 fprintf(stderr, |
1d4c693b8f35
unet-bind: sverp netlist reading implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
16
diff
changeset
|
97 "error: %s input contains unbound instances, aborting\n", |
1d4c693b8f35
unet-bind: sverp netlist reading implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
16
diff
changeset
|
98 input_filename); |
1d4c693b8f35
unet-bind: sverp netlist reading implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
16
diff
changeset
|
99 exit(1); |
1d4c693b8f35
unet-bind: sverp netlist reading implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
16
diff
changeset
|
100 } |
21
f7b09a54c2ce
unet-bind: implemented the check for unclaimed instances
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
19
diff
changeset
|
101 check_unclaimed_instances(); |
22
c7ebd6179f5d
ueda-bind: output implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
21
diff
changeset
|
102 generate_output(); |
12
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 exit(0); |
51893347bc42
unet-bind implementation started
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 } |