-
Notifications
You must be signed in to change notification settings - Fork 6
/
Resizer.i
307 lines (263 loc) · 6.14 KB
/
Resizer.i
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
%module resizer
// OpenSTA, Static Timing Analyzer
// Copyright (c) 2019, Parallax Software, Inc.
//
// 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 3 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, see <https://www.gnu.org/licenses/>.
%include "StaException.i"
%{
#include "Machine.hh"
#include "ResizerConfig.hh" // RESIZER_VERSION
#include "Error.hh"
#include "Liberty.hh"
#include "LefReader.hh"
#include "DefReader.hh"
#include "DefWriter.hh"
#include "LefDefNetwork.hh"
#include "Resizer.hh"
namespace sta {
// Defined in StaTcl.i
LibertyLibrarySeq *
tclListSeqLibertyLibrary(Tcl_Obj *const source,
Tcl_Interp *interp);
LibertyCellSeq *
tclListSeqLibertyCell(Tcl_Obj *const source,
Tcl_Interp *interp);
LefDefNetwork *
lefDefNetwork()
{
Sta *sta = Sta::sta();
return dynamic_cast<LefDefNetwork*>(sta->network());
}
Resizer *
getResizer()
{
return static_cast<Resizer*>(Sta::sta());
}
void
networkLibertyLibraries(Network *network,
// Return value.
LibertyLibrarySeq &libs)
{
LibertyLibraryIterator *lib_iter = network->libertyLibraryIterator();
while (lib_iter->hasNext()) {
LibertyLibrary *lib = lib_iter->next();
libs.push_back(lib);
}
delete lib_iter;
}
} // namespace
using namespace sta;
%}
////////////////////////////////////////////////////////////////
//
// SWIG type definitions.
// (copied from StaTcl.i because I don't see how to share them.
//
////////////////////////////////////////////////////////////////
%typemap(in) TransRiseFall* {
int length;
const char *arg = Tcl_GetStringFromObj($input, &length);
TransRiseFall *tr = TransRiseFall::find(arg);
if (tr == nullptr) {
Tcl_SetResult(interp,const_cast<char*>("Error: unknown transition name."),
TCL_STATIC);
return TCL_ERROR;
}
$1 = tr;
}
%typemap(in) LibertyLibrarySeq* {
$1 = tclListSeqLibertyLibrary($input, interp);
}
%typemap(in) LibertyCellSeq* {
$1 = tclListSeqLibertyCell($input, interp);
}
////////////////////////////////////////////////////////////////
//
// C++ functions visible as TCL functions.
//
////////////////////////////////////////////////////////////////
%inline %{
const char *
resizer_version()
{
return RESIZER_VERSION;
}
const char *
resizer_git_sha1()
{
return RESIZER_GIT_SHA1;
}
void
read_lef(const char *filename)
{
LefDefNetwork *network = lefDefNetwork();
readLef(filename, network);
}
bool
lef_exists()
{
LefDefNetwork *network = lefDefNetwork();
return network->lefLibrary() != nullptr;
}
void
read_def(const char *filename)
{
Resizer *resizer = getResizer();
resizer->readDef(filename);
}
void
set_die_size_cmd(// Die area (meters).
double die_lx,
double die_ly,
double die_ux,
double die_uy)
{
Resizer *resizer = getResizer();
resizer->setDieSize(die_lx, die_ly, die_ux, die_uy);
}
bool
have_die_area()
{
Resizer *resizer = getResizer();
return resizer->haveDieArea();
}
void
set_core_size_cmd(// Core area (meters).
double core_lx,
double core_ly,
double core_ux,
double core_uy)
{
Resizer *resizer = getResizer();
resizer->setCoreSize(core_lx, core_ly, core_ux, core_uy);
}
bool
have_core_area()
{
Resizer *resizer = getResizer();
return resizer->haveCoreArea();
}
double
utilization()
{
Resizer *resizer = getResizer();
return resizer->utilization();
}
void
write_def_cmd(const char *filename,
int units,
const char *site_name,
const char *tracks_file,
bool auto_place_pins,
bool sort)
{
LefDefNetwork *network = lefDefNetwork();
Resizer *resizer = getResizer();
if (site_name[0] == '\0')
site_name = nullptr;
if (tracks_file[0] == '\0')
tracks_file = nullptr;
double die_lx, die_ly, die_ux, die_uy;
resizer->dieSize(die_lx, die_ly, die_ux, die_uy);
double core_lx, core_ly, core_ux, core_uy;
resizer->coreSize(core_lx, core_ly, core_ux, core_uy);
writeDef(filename, units,
die_lx, die_ly, die_ux, die_uy,
core_lx, core_ly, core_ux, core_uy,
site_name, tracks_file, auto_place_pins, sort, network);
}
void
set_wire_rc_cmd(float res,
float cap,
Corner *corner)
{
Resizer *resizer = getResizer();
resizer->setWireRC(res, cap, corner);
}
void
set_max_utilization(double max_utilization)
{
Resizer *resizer = getResizer();
resizer->setMaxUtilization(max_utilization);
}
void
set_dont_use(LibertyCellSeq *dont_use)
{
Resizer *resizer = getResizer();
resizer->setDontUse(dont_use);
}
void
resizer_preamble(LibertyLibrarySeq *resize_libs)
{
Resizer *resizer = getResizer();
resizer->resizePreamble(resize_libs);
}
void
buffer_inputs(LibertyCell *buffer_cell)
{
Resizer *resizer = getResizer();
resizer->bufferInputs(buffer_cell);
}
void
buffer_outputs(LibertyCell *buffer_cell)
{
Resizer *resizer = getResizer();
resizer->bufferOutputs(buffer_cell);
}
void
resize_to_target_slew()
{
Resizer *resizer = getResizer();
resizer->resizeToTargetSlew();
}
void
rebuffer_nets(bool repair_max_cap,
bool repair_max_slew,
LibertyCell *buffer_cell)
{
Resizer *resizer = getResizer();
resizer->rebufferNets(repair_max_cap, repair_max_slew, buffer_cell);
}
void
resize_instance_to_target_slew(Instance *inst)
{
Resizer *resizer = getResizer();
resizer->resizeToTargetSlew(inst);
}
void
rebuffer_net(Net *net,
LibertyCell *buffer_cell)
{
Resizer *resizer = getResizer();
resizer->rebuffer(net, buffer_cell);
}
double
resize_target_slew(const TransRiseFall *tr)
{
Resizer *resizer = getResizer();
return resizer->targetSlew(tr);
}
double
resize_target_load_cap(LibertyCell *cell)
{
Resizer *resizer = getResizer();
return resizer->targetLoadCap(cell);
}
float
design_area()
{
Resizer *resizer = getResizer();
return resizer->designArea();
}
%} // inline