forked from JackHack96/logic-synthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.c
161 lines (147 loc) · 4.04 KB
/
options.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
* Symbolic encoding program for compiling a symbolic
* description into a binary representation. Target
* is multi-level logic synthesis
*
* History:
*
* Bill Lin
* University of California, Berkeley
* Comments to [email protected]
*
* Copyright (c) 1989 Bill Lin, UC Berkeley CAD Group
* Permission is granted to do anything with this
* code except sell it or remove this message.
*/
#include <stdio.h>
#include "jedi.h"
int parse_options(); /* forward declaration */
extern FILE *infp; /* jedi.c */
extern FILE *outfp; /* jedi.c */
usage()
{
(void) fprintf(stderr, "usage: jedi [options] [input] \n");
(void) fprintf(stderr, " -%s\t\t%s\n", "h", "print help message" );
(void) fprintf(stderr, " -%s %s\t%s\n", "e", "option", "specify encoding option" );
(void) fprintf(stderr, "\t\t%s\n", " r: random encoding" );
(void) fprintf(stderr, "\t\t%s\n", " h: one hot encoding" );
(void) fprintf(stderr, "\t\t%s\n", " d: dynamic random encoding" );
(void) fprintf(stderr, "\t\t%s\n", " s: straightforward mapping" );
(void) fprintf(stderr, "\t\t%s\n", " i: input dominant algorithm" );
(void) fprintf(stderr, "\t\t%s\n", " o: output dominant algorithm (default)" );
(void) fprintf(stderr, "\t\t%s\n", " c: coupled dominant algorithm" );
(void) fprintf(stderr, "\t\t%s\n", " y: modified output dominant algorithm" );
(void) fprintf(stderr, " -%s %s\t%s\n", "s", "length", "code length for state assignment" );
(void) fprintf(stderr, " -%s\t\t%s\n", "x", "expand state code" );
(void) fprintf(stderr, " -%s\t\t%s\n", "c", "use group based embedding algorithm" );
(void) fprintf(stderr, " -%s\t\t%s\n", "p", "output in PLA format" );
(void) fprintf(stderr, " -%s\t\t%s\n", "g", "general symbolic encoding format" );
(void) fprintf(stderr, "\n");
(void) fprintf(stderr, " [%s]\t%s\n", "input", "file to be processed (default stdin)" );
(void) fprintf(stderr, "\n");
(void) fprintf(stderr, "%s\n", HEADER );
(void) fprintf(stderr, "\n");
(void) exit(-1);
}
parse_options(argc, argv)
int argc;
char **argv;
{
extern int optind;
extern char *optarg;
int c;
/*
* set defaults
*/
beginningStates = 1;
endingStates = 10;
startingTemperature = 1000;
maximumTemperature = INFINITY;
bitsFlag = FALSE;
addDontCareFlag = TRUE;
kissFlag = TRUE;
verboseFlag = FALSE;
sequentialFlag = FALSE;
clusterFlag = FALSE;
srandomFlag = FALSE;
drandomFlag = FALSE;
variationFlag = TRUE;
oneplaneFlag = FALSE;
hotFlag = FALSE;
expandFlag = FALSE;
plaFlag = FALSE;
weightType = OUTPUT;
/*
* parse options
*/
while ((c=getopt(argc,argv,"hxcpge:s:"))!=EOF) {
switch(c) {
case 'h':
usage();
break;
case 'e':
if (!strcmp(optarg, "s")) {
sequentialFlag = TRUE;
break;
} else if (!strcmp(optarg, "r")) {
srandomFlag = TRUE;
break;
} else if (!strcmp(optarg, "d")) {
drandomFlag = TRUE;
break;
} else if (!strcmp(optarg, "h")) {
hotFlag = TRUE;
break;
} else if (!strcmp(optarg, "i")) {
weightType = INPUT;
variationFlag = FALSE;
break;
} else if (!strcmp(optarg, "o")) {
weightType = OUTPUT;
variationFlag = TRUE;
break;
} else if (!strcmp(optarg, "c")) {
weightType = COUPLED;
variationFlag = TRUE;
break;
} else if (!strcmp(optarg, "y")) {
weightType = OUTPUT;
variationFlag = FALSE;
break;
} else {
usage();
break;
}
case 's':
bitsFlag = TRUE;
code_length = atoi(optarg);
break;
case 'x':
expandFlag = TRUE;
break;
case 'c':
clusterFlag = TRUE;
break;
case 'p':
plaFlag = TRUE;
break;
case 'g':
kissFlag = FALSE;
break;
default:
usage();
}
}
/*
* check for sufficient arguments
*/
if (optind != argc && optind != argc-1) {
usage();
}
if (optind == argc) {
infp = stdin;
} else {
infp = my_fopen(argv[argc-1], "r");
}
outfp = stdout;
} /* end of parse_options */