-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrouting_cmds.cc
264 lines (207 loc) · 7.22 KB
/
routing_cmds.cc
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*************************************************************************
*
* Copyright (c) 2021 Rajit Manohar
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
**************************************************************************
*/
#include <stdio.h>
#include <act/passes.h>
#include <common/list.h>
#include <common/pp.h>
#include <lispCli.h>
#include "all_cmds.h"
#include "ptr_manager.h"
#include "flow.h"
#include <act/tech.h>
#if defined(FOUND_pwroute)
static int process_pwroute_init (int argc, char **argv) {
if (!std_argcheck (argc, argv, 2, "<verbose>", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.phydb == NULL) {
fprintf (stderr, "%s: phydb needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
F.pwroute = new pwroute::PWRoute(F.phydb, atoi(argv[1]));
save_to_log (argc, argv, "i");
return LISP_RET_TRUE;
}
static int process_pwroute_set_parameters (int argc, char **argv) {
if (!std_argcheck (argc, argv, 4, "<reinforcement_width, reinforcement_step, cluster_mesh_width>", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.pwroute == NULL) {
fprintf (stderr, "%s: pwroute needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
F.pwroute->SetMeshWidthStep(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
save_to_log (argc, argv, "");
return LISP_RET_TRUE;
}
static int process_pwroute_set_reinforcement (int argc, char **argv) {
if (!std_argcheck (argc, argv, 2, "<bool>", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.pwroute == NULL) {
fprintf (stderr, "%s: pwroute needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
F.pwroute->SetReinforcement(atoi(argv[1]));
save_to_log (argc, argv, "");
return LISP_RET_TRUE;
}
static int process_pwroute_run (int argc, char **argv) {
if (!std_argcheck (argc, argv, 1, "", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.pwroute == NULL) {
fprintf (stderr, "%s: pwroute needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
F.pwroute->RunPWRoute();
save_to_log (argc, argv, "f");
return LISP_RET_TRUE;
}
static int process_pwroute_export_phydb (int argc, char **argv) {
if (!std_argcheck (argc, argv, 1, "", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.pwroute == NULL) {
fprintf (stderr, "%s: pwroute needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
F.pwroute->ExportToPhyDB();
save_to_log (argc, argv, "");
return LISP_RET_TRUE;
}
static int process_pwroute_close (int argc, char **argv) {
if (!std_argcheck (argc, argv, 1, "", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.pwroute != NULL) {
delete F.pwroute;
F.pwroute = NULL;
}
save_to_log (argc, argv, "");
return LISP_RET_TRUE;
}
static struct LispCliCommand pwroute_cmds[] = {
{ NULL, "Power Routing for Gridded Cells", NULL },
{ "init", "<verbose> -initialize pwroute engine <verbose> ", process_pwroute_init },
{ "set_parameters", "<reinforcement_width, reinforcement_step, cluster_mesh_width> - run pw route with mesh configuration. Default is <8, 16, 2>",
process_pwroute_set_parameters},
{ "set_reinforcement", "<bool>, enable/disable reinforcement connection (default: 1) ", process_pwroute_set_reinforcement },
{ "run", "run pwroute", process_pwroute_run },
{ "export-phydb", "-export power and ground wires to phydb", process_pwroute_export_phydb },
{ "close", "-close pwroute", process_pwroute_close }
};
#endif
#if defined(FOUND_sproute)
static int process_sproute_init (int argc, char **argv) {
if (!std_argcheck (argc, argv, 2, "<verbose>", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.phydb == NULL) {
fprintf (stderr, "%s: phydb needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
init_galois_shmemsys(0);
F.sproute = new sproute::SPRoute(F.phydb, atoi(argv[1]));
save_to_log (argc, argv, "i");
return LISP_RET_TRUE;
}
static int process_sproute_set_num_threads (int argc, char **argv) {
if (!std_argcheck (argc, argv, 2, "<int>", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.sproute == NULL) {
fprintf (stderr, "%s: sproute needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
F.sproute->SetNumThreads(atoi(argv[1]));
save_to_log (argc, argv, "");
return LISP_RET_TRUE;
}
static int process_sproute_set_algo (int argc, char **argv) {
if (!std_argcheck (argc, argv, 2, "Det/NonDet", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.sproute == NULL) {
fprintf (stderr, "%s: sproute needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
F.sproute->SetAlgo(string(argv[1]));
save_to_log (argc, argv, "");
return LISP_RET_TRUE;
}
static int process_sproute_set_max_iteration (int argc, char **argv) {
if (!std_argcheck (argc, argv, 2, "<int>", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.sproute == NULL) {
fprintf (stderr, "%s: sproute needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
F.sproute->SetMaxIteration(atoi(argv[1]));
save_to_log (argc, argv, "");
return LISP_RET_TRUE;
}
static int process_sproute_run (int argc, char **argv) {
if (!std_argcheck (argc, argv, 1, "", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.sproute == NULL) {
fprintf (stderr, "%s: sproute needs to be initialized!\n", argv[0]);
return LISP_RET_ERROR;
}
F.sproute->Run();
save_to_log (argc, argv, "f");
return LISP_RET_TRUE;
}
static int process_sproute_close (int argc, char **argv) {
if (!std_argcheck (argc, argv, 1, "", STATE_EXPANDED)) {
return LISP_RET_ERROR;
}
if (F.sproute != NULL) {
delete F.sproute;
F.sproute = NULL;
}
save_to_log (argc, argv, "");
return LISP_RET_TRUE;
}
static struct LispCliCommand sproute_cmds[] = {
{ NULL, "Global Routing", NULL },
{ "init", "initialize sproute engine", process_sproute_init },
{ "set-num-threads", "set num threads, default = 1", process_sproute_set_num_threads},
{ "set-algo", "Det/NonDet, default is NonDet", process_sproute_set_algo},
{ "set-max-iterations", "set max iterations of maze routing, default = 30", process_sproute_set_max_iteration},
{ "run", "run sproute", process_sproute_run },
{ "close", "close sproute", process_sproute_close }
};
#endif
void routing_cmds_init (void)
{
#if defined(FOUND_pwroute)
LispCliAddCommands ("pwroute", pwroute_cmds,
sizeof (pwroute_cmds)/sizeof (pwroute_cmds[0]));
#endif
#if defined(FOUND_sproute)
LispCliAddCommands ("sproute", sproute_cmds,
sizeof (sproute_cmds)/sizeof (sproute_cmds[0]));
#endif
}