1 // *****************************************************************************
2 // *****************************************************************************
3 // Copyright 2013 - 2015, Cadence Design Systems
4 //
5 // This file is part of the Cadence LEF/DEF Open Source
6 // Distribution, Product Version 5.8.
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied. See the License for the specific language governing
18 // permissions and limitations under the License.
19 //
20 // For updates, support, or to become part of the LEF/DEF Community,
21 // check www.openeda.org for details.
22 //
23 // $Author: dell $
24 // $Revision: #1 $
25 // $Date: 2017/06/06 $
26 // $State: $
27 // *****************************************************************************
28 // *****************************************************************************
29
30 #include <string.h>
31 #include <stdlib.h>
32 #include "lex.h"
33 #include "defiIOTiming.hpp"
34 #include "defiDebug.hpp"
35
36 BEGIN_LEFDEF_PARSER_NAMESPACE
37
38 //////////////////////////////////////////////
39 //////////////////////////////////////////////
40 //
41 // defiIOTiming
42 //
43 //////////////////////////////////////////////
44 //////////////////////////////////////////////
45
46
defiIOTiming(defrData * data)47 defiIOTiming::defiIOTiming(defrData *data)
48 : defData(data)
49 {
50 Init();
51 }
52
53
Init()54 void defiIOTiming::Init() {
55 inst_ = 0;
56 instLength_ = 0;
57 pin_ = 0;
58 pinLength_ = 0;
59 from_ = 0;
60 fromLength_ = 0;
61 to_ = 0;
62 toLength_ = 0;
63 driveCell_ = 0;
64 driveCellLength_ = 0;
65 hasVariableRise_ = 0;
66 hasVariableFall_ = 0;
67 hasSlewRise_ = 0;
68 hasSlewFall_ = 0;
69 hasCapacitance_ = 0;
70 hasDriveCell_ = 0;
71 hasFrom_ = 0;
72 if (pin_) free(pin_);
73 pin_ = 0;
74 pinLength_ = 0;
75
76 hasTo_ = 0;
77 hasParallel_ = 0;
78 variableFallMin_ = 0.0;
79 variableRiseMin_ = 0.0;
80 variableFallMax_ = 0.0;
81 variableRiseMax_ = 0.0;
82 slewFallMin_ = 0.0;
83 slewRiseMin_ = 0.0;
84 slewFallMax_ = 0.0;
85 slewRiseMax_ = 0.0;
86 capacitance_ = 0.0;
87 parallel_ = 0.0;
88 }
89
90
~defiIOTiming()91 defiIOTiming::~defiIOTiming() {
92 Destroy();
93 }
94
95
Destroy()96 void defiIOTiming::Destroy() {
97
98 if (inst_) free(inst_);
99 inst_ = 0;
100 instLength_ = 0;
101
102 if (pin_) free(pin_);
103 pin_ = 0;
104 pinLength_ = 0;
105
106 if (from_) free(from_);
107 from_ = 0;
108 fromLength_ = 0;
109
110 if (to_) free(to_);
111 to_ = 0;
112 toLength_ = 0;
113
114 if (driveCell_) free(driveCell_);
115 driveCell_ = 0;
116 driveCellLength_ = 0;
117
118 clear();
119 }
120
121
clear()122 void defiIOTiming::clear() {
123 hasVariableRise_ = 0;
124 hasVariableFall_ = 0;
125 hasSlewRise_ = 0;
126 hasSlewFall_ = 0;
127 hasCapacitance_ = 0;
128 hasDriveCell_ = 0;
129 hasFrom_ = 0;
130 hasTo_ = 0;
131 hasParallel_ = 0;
132 variableFallMin_ = 0.0;
133 variableRiseMin_ = 0.0;
134 variableFallMax_ = 0.0;
135 variableRiseMax_ = 0.0;
136 slewFallMin_ = 0.0;
137 slewRiseMin_ = 0.0;
138 slewFallMax_ = 0.0;
139 slewRiseMax_ = 0.0;
140 capacitance_ = 0.0;
141 parallel_ = 0.0;
142 }
143
144
setName(const char * inst,const char * pin)145 void defiIOTiming::setName(const char* inst, const char* pin) {
146 int len;
147
148 clear();
149
150 len = strlen(inst) + 1;
151 if (len > instLength_) {
152 if (inst_) free(inst_);
153 instLength_ = len;
154 inst_ = (char*)malloc(len);
155 }
156 strcpy(inst_, defData->DEFCASE(inst));
157
158 len = strlen(pin) + 1;
159 if (len > pinLength_) {
160 if (pin_) free(pin_);
161 pinLength_ = len;
162 pin_ = (char*)malloc(len);
163 }
164 strcpy(pin_, defData->DEFCASE(pin));
165
166 }
167
168
print(FILE * f) const169 void defiIOTiming::print(FILE* f) const {
170 fprintf(f, "IOTiming '%s' '%s'\n", inst_, pin_);
171
172 if (hasSlewRise())
173 fprintf(f, " Slew rise %5.2f %5.2f\n",
174 slewRiseMin(),
175 slewRiseMax());
176
177 if (hasSlewFall())
178 fprintf(f, " Slew fall %5.2f %5.2f\n",
179 slewFallMin(),
180 slewFallMax());
181
182 if (hasVariableRise())
183 fprintf(f, " variable rise %5.2f %5.2f\n",
184 variableRiseMin(),
185 variableRiseMax());
186
187 if (hasVariableFall())
188 fprintf(f, " variable fall %5.2f %5.2f\n",
189 variableFallMin(),
190 variableFallMax());
191
192 if (hasCapacitance())
193 fprintf(f, " capacitance %5.2f\n",
194 capacitance());
195
196 if (hasDriveCell())
197 fprintf(f, " drive cell '%s'\n",
198 driveCell());
199
200 if (hasFrom())
201 fprintf(f, " from pin '%s'\n",
202 from());
203
204 if (hasTo())
205 fprintf(f, " to pin '%s'\n",
206 to());
207
208 if (hasParallel())
209 fprintf(f, " parallel %5.2f\n",
210 parallel());
211 }
212
213
214
setVariable(const char * riseFall,double min,double max)215 void defiIOTiming::setVariable(const char* riseFall, double min, double max) {
216 if (*riseFall == 'R') {
217 hasVariableRise_ = 1;
218 variableRiseMin_ = min;
219 variableRiseMax_ = max;
220
221 } else if (*riseFall == 'F') {
222 hasVariableFall_ = 1;
223 variableFallMin_ = min;
224 variableFallMax_ = max;
225
226 } else {
227 defiError(0, 6060, "ERROR (DEFPARS-6060): Invalid value specified for IOTIMING rise/fall. The valid value for rise is 'R' and for fall is 'F'. Specify a valid value and then try again.", defData);
228 }
229 }
230
231
setSlewRate(const char * riseFall,double min,double max)232 void defiIOTiming::setSlewRate(const char* riseFall, double min, double max) {
233 if (*riseFall == 'R') {
234 hasSlewRise_ = 1;
235 slewRiseMin_ = min;
236 slewRiseMax_ = max;
237
238 } else if (*riseFall == 'F') {
239 hasSlewFall_ = 1;
240 slewFallMin_ = min;
241 slewFallMax_ = max;
242
243 } else {
244 defiError(0, 6060, "ERROR (DEFPARS-6060): Invalid value specified for IOTIMING rise/fall. The valid value for rise is 'R' and for fall is 'F'. Specify a valid value and then try again.", defData);
245 }
246 }
247
248
setCapacitance(double num)249 void defiIOTiming::setCapacitance(double num) {
250 hasCapacitance_ = 1;
251 capacitance_ = num;
252 }
253
254
setDriveCell(const char * name)255 void defiIOTiming::setDriveCell(const char* name) {
256 int len = strlen(name) + 1;
257
258 if (driveCellLength_ < len) {
259 if (driveCell_) free(driveCell_);
260 driveCell_ = (char*) malloc(len);
261 driveCellLength_ = len;
262 }
263
264 strcpy(driveCell_, defData->DEFCASE(name));
265 hasDriveCell_ = 1;
266 }
267
268
setFrom(const char * name)269 void defiIOTiming::setFrom(const char* name) {
270 int len = strlen(name) + 1;
271
272 if (fromLength_ < len) {
273 if (from_) free(from_);
274 from_ = (char*) malloc(len);
275 fromLength_ = len;
276 }
277
278 strcpy(from_, defData->DEFCASE(name));
279 hasFrom_ = 1;
280 }
281
282
setTo(const char * name)283 void defiIOTiming::setTo(const char* name) {
284 int len = strlen(name) + 1;
285
286 if (toLength_ < len) {
287 if (to_) free(to_);
288 to_ = (char*) malloc(len);
289 toLength_ = len;
290 }
291
292 strcpy(to_, defData->DEFCASE(name));
293 hasTo_ = 1;
294 }
295
296
setParallel(double num)297 void defiIOTiming::setParallel(double num) {
298 hasParallel_ = 1;
299 parallel_ = num;
300 }
301
302
hasVariableRise() const303 int defiIOTiming::hasVariableRise() const {
304 return hasVariableRise_;
305 }
306
307
hasVariableFall() const308 int defiIOTiming::hasVariableFall() const {
309 return hasVariableFall_;
310 }
311
312
hasSlewRise() const313 int defiIOTiming::hasSlewRise() const {
314 return hasSlewRise_;
315 }
316
317
hasSlewFall() const318 int defiIOTiming::hasSlewFall() const {
319 return hasSlewFall_;
320 }
321
322
hasCapacitance() const323 int defiIOTiming::hasCapacitance() const {
324 return hasCapacitance_;
325 }
326
327
hasDriveCell() const328 int defiIOTiming::hasDriveCell() const {
329 return hasDriveCell_;
330 }
331
332
hasFrom() const333 int defiIOTiming::hasFrom() const {
334 return hasFrom_;
335 }
336
337
hasTo() const338 int defiIOTiming::hasTo() const {
339 return hasTo_;
340 }
341
342
hasParallel() const343 int defiIOTiming::hasParallel() const {
344 return hasParallel_;
345 }
346
347
inst() const348 const char* defiIOTiming::inst() const {
349 return inst_;
350 }
351
352
pin() const353 const char* defiIOTiming::pin() const {
354 return pin_;
355 }
356
357
variableFallMin() const358 double defiIOTiming::variableFallMin() const {
359 return variableFallMin_;
360 }
361
362
variableRiseMin() const363 double defiIOTiming::variableRiseMin() const {
364 return variableRiseMin_;
365 }
366
367
variableFallMax() const368 double defiIOTiming::variableFallMax() const {
369 return variableFallMax_;
370 }
371
372
variableRiseMax() const373 double defiIOTiming::variableRiseMax() const {
374 return variableRiseMax_;
375 }
376
377
slewFallMin() const378 double defiIOTiming::slewFallMin() const {
379 return slewFallMin_;
380 }
381
382
slewRiseMin() const383 double defiIOTiming::slewRiseMin() const {
384 return slewRiseMin_;
385 }
386
387
slewFallMax() const388 double defiIOTiming::slewFallMax() const {
389 return slewFallMax_;
390 }
391
392
slewRiseMax() const393 double defiIOTiming::slewRiseMax() const {
394 return slewRiseMax_;
395 }
396
397
capacitance() const398 double defiIOTiming::capacitance() const {
399 return capacitance_;
400 }
401
402
driveCell() const403 const char* defiIOTiming::driveCell() const {
404 return driveCell_;
405 }
406
407
from() const408 const char* defiIOTiming::from() const {
409 return from_;
410 }
411
412
to() const413 const char* defiIOTiming::to() const {
414 return to_;
415 }
416
417
parallel() const418 double defiIOTiming::parallel() const {
419 return parallel_;
420 }
421
422
423 END_LEFDEF_PARSER_NAMESPACE
424
425