-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathflow.cc
More file actions
227 lines (194 loc) · 4.56 KB
/
Copy pathflow.cc
File metadata and controls
227 lines (194 loc) · 4.56 KB
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
/*************************************************************************
*
* 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 <string.h>
#include "flow.h"
int output_window_width;
/*************************************************************************
*
*
* Utility functions
*
*
*************************************************************************
*/
static const char *get_state_str (void)
{
static char buf[1024];
int sz = 1024;
int pos = 0;
int len;
const char *s = NULL;
switch (F.s) {
case STATE_ANY:
s = "[any]";
break;
case STATE_EMPTY:
s = "[no design]";
break;
case STATE_DESIGN:
s = "[unexpanded design]";
break;
case STATE_EXPANDED:
s = "[expanded design]";
break;
case STATE_ERROR:
s = "[error]";
break;
case STATE_DIRTY:
s = "[dirty]";
break;
}
snprintf (buf + pos, sz, "%s\n ", s);
len = strlen (buf + pos);
pos += len;
sz -= len;
if (F.ckt_gen) {
snprintf (buf + pos, sz, " ckt:yes");
}
else {
snprintf (buf + pos, sz, " ckt:no");
}
len = strlen (buf + pos);
pos += len;
sz -= len;
if (F.cell_map) {
snprintf (buf + pos, sz, " cells:yes");
}
else {
snprintf (buf + pos, sz, " cells:no");
}
len = strlen (buf + pos);
pos += len;
sz -= len;
if (F.act_toplevel) {
snprintf (buf + pos, sz, " top:set");
}
else {
snprintf (buf + pos, sz, " top:unset");
}
len = strlen (buf + pos);
pos += len;
sz -= len;
if (F.timer == 0) {
snprintf (buf + pos, sz, " timer:none");
}
else if (F.timer == TIMER_INIT) {
snprintf (buf + pos, sz, " timer:init");
}
else if (F.timer == TIMER_RUN) {
snprintf (buf + pos, sz, " timer:run");
}
len = strlen (buf + pos);
pos += len;
sz -= len;
#ifdef FOUND_dali
if (F.dali) {
snprintf (buf + pos, sz, " placer:init");
}
else {
snprintf (buf + pos, sz, " placer:none");
}
len = strlen (buf + pos);
pos += len;
sz -= len;
#endif
#ifdef FOUND_phydb
if (F.phydb) {
snprintf (buf + pos, sz, " phydb:init");
}
else {
snprintf (buf + pos, sz, " phydb:none");
}
len = strlen (buf + pos);
pos += len;
sz -= len;
#endif
return buf;
}
/*--------------------------------------------------------------------------
Check that # args match, and that we are in a valid flow state
for the command.
--------------------------------------------------------------------------*/
int std_argcheck (int argc, char **argv, int argnum, const char *usage,
design_state required)
{
if (argc != argnum) {
fprintf (stderr, "Usage: %s %s\n", argv[0], usage);
return 0;
}
if (required == STATE_ANY || F.s == required) {
return 1;
}
warning ("%s: command failed; incorrect flow state.\n Current flow state: %s", argv[0], get_state_str ());
fprintf (stderr, "\n");
return 0;
}
/*--------------------------------------------------------------------------
Open/close output file, interpreting "-" as stdout
--------------------------------------------------------------------------*/
FILE *std_open_output (const char *cmd, const char *s)
{
FILE *fp;
if (strcmp (s, "-") == 0) {
fp = stdout;
}
else {
fp = fopen (s, "w");
if (!fp) {
return NULL;
}
}
return fp;
}
void std_close_output (FILE *fp)
{
if (fp != stdout) {
fclose (fp);
}
}
void flow_init (void)
{
F.s = STATE_EMPTY;
F.cell_map = 0;
F.ckt_gen = 0;
F.timer = 0;
F.sp = NULL;
F.tp = NULL;
F.act_design = new Act ();
F.act_toplevel = NULL;
#ifdef FOUND_dali
F.dali = NULL;
#endif
#ifdef FOUND_pwroute
F.pwroute = NULL;
#endif
#ifdef FOUND_sproute
F.sproute = NULL;
#endif
#ifdef FOUND_phydb
F.phydb = NULL;
F.phydb_cell = 0;
F.phydb_lef = 0;
F.phydb_def = 0;
#endif
}