Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / api / inf / inf_API.c
1 #include <math.h>
2 #include <stdlib.h>
3 #include <ctype.h>
4
5 #include AVT_H
6 #include MUT_H
7 #include INF_H
8
9 #define API_USE_REAL_TYPES
10 #include "inf_API.h"
11
12 static char *inffigurename=".unknown.", warned=0;
13
14
15 void inf_DumpRegistry_i(char *name)
16 {
17 inffig_list *ifl=getloadedinffig(name);
18 inf_DumpRegistry(stdout,ifl,0);
19 }
20
21 void inf_CheckRegistry_i(char *name, int level, chain_list *data)
22 {
23 inffig_list *ifl=getloadedinffig(name);
24 inf_CheckRegistry(stdout,ifl,level,data);
25 }
26
27 inffig_list *__giveinf()
28 {
29 inffig_list *ifl;
30 if (warned==0 && inffigurename==".unknown.")
31 {
32 avt_errmsg(INF_API_ERRMSG, "001", AVT_FATAL);
33 // avt_error("infapi", AVT_WAR, 1, "you must first use 'inf_SetFigureName' prior to use other functions\n");
34 warned=1;
35 }
36 if ((ifl=getloadedinffig(inffigurename))!=NULL) return ifl;
37 ifl=addinffig(inffigurename);
38 return ifl;
39 }
40
41 void inf_SetFigureName(char *name)
42 {
43 inffigurename=namealloc(name);
44 }
45
46 void inf_LoadInformationFile(char *figname)
47 {
48 inffig_list *ifl;
49 inf_Dirty(figname);
50 if ((ifl=getinffig(figname))==NULL)
51 {
52 avt_errmsg(INF_API_ERRMSG, "002", AVT_WARNING, figname);
53 // avt_error("infapi", AVT_WAR, 2, "figure '%s' could not be found\n",figname);
54 ifl=addinffig(figname);
55 }
56 else
57 inf_SetFigureName(figname);
58 }
59
60 void inf_LoadAndMergeInformationFile(char *figname)
61 {
62 infRead(figname, 1);
63 inf_SetFigureName(figname);
64 }
65
66 void inf_AddFile(char *filename, char *figname)
67 {
68 inffig_list *ret;
69 inf_ignorename=1;
70 ret=_infRead(figname, filename, 0);
71 avt_log(LOGFILEACCESS, 0, "Loading INF file \"%s\" for figure \"%s\"%s\n", filename, figname,ret!=NULL?" done.":" failed.");
72 // avt_error("infapi", -1, AVT_INFO, "load INF '¤2%s¤.' for figure '%s'%s\n", filename, figname,ret!=NULL?" ¤7done¤.":" ¤6failed¤.");
73 inf_ignorename=0;
74 }
75
76 void inf_Drive(char *outputname)
77 {
78 inffig_list *ifl;
79 ifl=__giveinf();
80 infDrive(ifl, outputname, INF_LOADED_LOCATION, NULL);
81 }
82
83 void inf_ExportSections(char *outputname, char *section)
84 {
85 inffig_list *ifl;
86 ifl=__giveinf();
87 infDrive_filtered(ifl, outputname, INF_LOADED_LOCATION, NULL, section);
88 }
89
90 void inf_DefineSlew(char *name, double slope_rise, double slope_fall)
91 {
92 inffig_list *ifl;
93 ifl=__giveinf();
94 if (slope_rise<1e-12) slope_rise=1e-12;
95 if (slope_fall<1e-12) slope_fall=1e-12;
96 inf_AddDouble(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_PIN_RISING_SLEW, slope_rise, NULL);
97 inf_AddDouble(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_PIN_FALLING_SLEW, slope_fall, NULL);
98 }
99
100 void inf_DefineSlope(char *name, double slope_rise, double slope_fall)
101 {
102 inf_DefineSlew(name, slope_rise, slope_fall);
103 }
104
105 void inf_DefineDelay(char *origin, char *destination, double delay)
106 {
107 inffig_list *ifl;
108 ifl=__giveinf();
109 inf_AddAssociation(ifl, INF_LOADED_LOCATION, INF_DELAY, "", mbk_decodeanyvector(origin), mbk_decodeanyvector(destination), 0, delay, NULL);
110 }
111
112 void inf_DefineStop(char *name)
113 {
114 inffig_list *ifl;
115 ifl=__giveinf();
116 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_STOP, NULL, NULL);
117 }
118
119 void inf_DefineRename(char *origin, char *destination)
120 {
121 inffig_list *ifl;
122 ifl=__giveinf();
123 inf_AddAssociation(ifl, INF_LOADED_LOCATION, INF_RENAME, "", mbk_decodeanyvector(origin), mbk_decodeanyvector(destination), 0, 0, NULL);
124 }
125
126 void inf_DefineMemsym(char *origin, char *destination)
127 {
128 inffig_list *ifl;
129 ifl=__giveinf();
130 inf_AddAssociation(ifl, INF_LOADED_LOCATION, INF_MEMSYM, "", mbk_decodeanyvector(origin), mbk_decodeanyvector(destination), 0, 0, NULL);
131 }
132
133 void inf_DefineSensitive(char *name)
134 {
135 inffig_list *ifl;
136 ifl=__giveinf();
137 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_SENSITIVE, NULL, NULL);
138 }
139
140 void inf_DefineSuppress(char *name)
141 {
142 inffig_list *ifl;
143 ifl=__giveinf();
144 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_SUPPRESS, NULL, NULL);
145 }
146
147 void inf_DefineInputs(char *name)
148 {
149 inffig_list *ifl;
150 ifl=__giveinf();
151 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_INPUTS, NULL, NULL);
152 }
153
154 void inf_DefineNotLatch(char *name)
155 {
156 inffig_list *ifl;
157 ifl=__giveinf();
158 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_NOTLATCH, NULL, NULL);
159 }
160
161 void inf_DefineKeepTristateBehaviour(char *name)
162 {
163 inffig_list *ifl;
164 ifl=__giveinf();
165 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_KEEP_TRISTATE_BEHAVIOUR, NULL, NULL);
166 }
167
168 void inf_DefineRC(char *name)
169 {
170 inffig_list *ifl;
171 ifl=__giveinf();
172 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_RC, INF_YES, NULL);
173 }
174
175 void inf_DefineNORC(char *name)
176 {
177 inffig_list *ifl;
178 ifl=__giveinf();
179 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_RC, INF_NO, NULL);
180 }
181
182 void inf_DefineAsynchron(char *name)
183 {
184 inffig_list *ifl;
185 ifl=__giveinf();
186 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_ASYNCHRON, NULL, NULL);
187 }
188
189 void inf_DefineDoNotCross(char *name)
190 {
191 inffig_list *ifl;
192 ifl=__giveinf();
193 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_DONTCROSS, NULL, NULL);
194 }
195
196 void inf_DefineTransparent(char *name)
197 {
198 inffig_list *ifl;
199 ifl=__giveinf();
200 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_TRANSPARENT, NULL, NULL);
201 }
202
203 void inf_DefineInter(char *name)
204 {
205 inffig_list *ifl;
206 ifl=__giveinf();
207 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_INTER, NULL, NULL);
208 }
209
210 void inf_DefineBreak(char *name)
211 {
212 inffig_list *ifl;
213 ifl=__giveinf();
214 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_BREAK, NULL, NULL);
215 }
216
217 void inf_DefineStrictSetup(char *name)
218 {
219 inffig_list *ifl;
220 ifl=__giveinf();
221 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_STRICT_SETUP, NULL, NULL);
222 }
223
224 void inf_DefineCkPrech(char *name)
225 {
226 inffig_list *ifl;
227 ifl=__giveinf();
228 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_CKPRECH, NULL, NULL);
229 }
230
231 void inf_DefineNoFalling(char *name)
232 {
233 inffig_list *ifl;
234 ifl=__giveinf();
235 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_NOFALLING, NULL, NULL);
236 }
237
238 void inf_DefineNoRising(char *name)
239 {
240 inffig_list *ifl;
241 ifl=__giveinf();
242 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_NORISING, NULL, NULL);
243 }
244
245 void inf_SetPeriod(double value)
246 {
247 inffig_list *ifl;
248 ifl=__giveinf();
249 inf_AddDouble(ifl, INF_LOADED_LOCATION, INF_STB_HEADER, INF_DEFAULT_PERIOD, value, NULL);
250 }
251
252 void inf_SetSetupMargin(double value)
253 {
254 inffig_list *ifl;
255 ifl=__giveinf();
256 inf_AddDouble(ifl, INF_LOADED_LOCATION, INF_STB_HEADER, INF_SETUPMARGIN, value, NULL);
257 }
258
259 void inf_SetHoldMargin(double value)
260 {
261 inffig_list *ifl;
262 ifl=__giveinf();
263 inf_AddDouble(ifl, INF_LOADED_LOCATION, INF_STB_HEADER, INF_HOLDMARGIN, value, NULL);
264 }
265
266 void inf_DefineConstraint(char *name, int value)
267 {
268 inffig_list *ifl;
269 ifl=__giveinf();
270 inf_AddInt(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_STUCK, value?1:0, NULL);
271 }
272
273 void inf_DefineConditionedCommandStates(char *name, char *state)
274 {
275 inffig_list *ifl;
276 ifl=__giveinf();
277
278 if (strcasecmp(state,"up")==0) state=INF_VERIFUP;
279 else if (strcasecmp(state,"down")==0) state=INF_VERIFDOWN;
280 else if (strcasecmp(state,"rising")==0) state=INF_VERIFRISE;
281 else if (strcasecmp(state,"falling")==0) state=INF_VERIFFALL;
282 else if (strcasecmp(state,"noverif")==0) state=INF_NOVERIF;
283 else
284 {
285 avt_errmsg(INF_API_ERRMSG, "003", AVT_ERROR, state);
286 // avt_error("infapi", AVT_ERR, 1, "invalid command state given: '%s'\n", state);
287 return;
288 }
289 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_VERIF_STATE, state, NULL);
290 }
291
292 void inf_DefineClockPriority(char *name, char *clock)
293 {
294 inffig_list *ifl;
295 ifl=__giveinf();
296 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_PREFERED_CLOCK, infTasVectName(clock), NULL);
297 }
298
299 void inf_DefineDLatch(char *name)
300 {
301 inffig_list *ifl;
302 ifl=__giveinf();
303 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_DLATCH, INF_YES, NULL);
304 }
305
306 void inf_DefineFlipFlop(char *name)
307 {
308 inffig_list *ifl;
309 ifl=__giveinf();
310 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_FLIPFLOP, NULL, NULL);
311 }
312
313 void inf_DefineNotDLatch(char *name)
314 {
315 inffig_list *ifl;
316 ifl=__giveinf();
317 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_DLATCH, INF_NO, NULL);
318 }
319
320 void inf_DefinePrecharge(char *name)
321 {
322 inffig_list *ifl;
323 ifl=__giveinf();
324 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_PRECHARGE, INF_YES, NULL);
325 }
326
327 void inf_DefineNotPrecharge(char *name)
328 {
329 inffig_list *ifl;
330 ifl=__giveinf();
331 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_PRECHARGE, INF_NO, NULL);
332 }
333
334 void inf_DefineModelLatchLoop(char *name)
335 {
336 inffig_list *ifl;
337 ifl=__giveinf();
338 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_MODELLOOP, INF_YES, NULL);
339 }
340
341 void inf_DefineCkLatch(char *name)
342 {
343 inffig_list *ifl;
344 ifl=__giveinf();
345 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_CKLATCH, INF_YES, NULL);
346 }
347
348 void inf_DefineNotCkLatch(char *name)
349 {
350 inffig_list *ifl;
351 ifl=__giveinf();
352 inf_AddString(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_CKLATCH, INF_NO, NULL);
353 }
354
355 void inf_DefineDirout(char *name, int level)
356 {
357 inffig_list *ifl;
358 ifl=__giveinf();
359 inf_AddInt(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_DIROUT, level, NULL);
360 }
361
362 void inf_DefineClock(chain_list *elems)
363 {
364 inffig_list *ifl;
365 char *aname, *bname;
366 int mode, val;
367 double minup, maxup, mindown, maxdown, period, mult, delta;
368
369 if (elems!=NULL)
370 {
371 if (strcasecmp(elems->DATA,"virtual")==0) mode=INF_CLOCK_VIRTUAL, elems=elems->NEXT;
372 else if (strcasecmp(elems->DATA,"ideal")==0) mode=INF_CLOCK_IDEAL, elems=elems->NEXT;
373 else mode=0;
374
375 if (elems!=NULL && strcasecmp(elems->DATA,"!")==0) mode|=INF_CLOCK_INVERTED, elems=elems->NEXT;
376
377 if (elems!=NULL)
378 {
379 aname=infTasVectName((char *)elems->DATA);
380 elems=elems->NEXT;
381
382 ifl=__giveinf();
383 inf_AddInt(ifl, INF_LOADED_LOCATION, aname, INF_CLOCK_TYPE, mode, NULL);
384
385 if (elems!=NULL)
386 {
387 if (strcasecmp(elems->DATA,"clock")!=0)
388 {
389 if (countchain(elems)>=5)
390 {
391 minup=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
392 maxup=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
393 mindown=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
394 maxdown=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
395 period=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
396 }
397 else
398 avt_errmsg(INF_API_ERRMSG, "004", AVT_ERROR);
399 // avt_error("infapi", 6, AVT_ERR, "missing clock parameter\n");
400 }
401 else
402 {
403 elems=elems->NEXT;
404 if (countchain(elems)>=3)
405 {
406 bname=infTasVectName((char *)elems->DATA); elems=elems->NEXT;
407 mult=atof((char *)elems->DATA); elems=elems->NEXT;
408 delta=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
409
410 if (inf_GetInt(ifl, bname, INF_CLOCK_TYPE, &val)==0)
411 avt_errmsg(INF_API_ERRMSG, "005", AVT_ERROR, bname);
412 // avt_error("infapi", 11, AVT_ERR, "clock '%s' not defined yet\n", bname);
413 else
414 {
415 double per, defper, min;
416 double minr=0, maxr=0, minf=1e-12, maxf=1e-12;
417 if (!inf_GetDouble(ifl, INF_STB_HEADER, INF_DEFAULT_PERIOD, &defper)) defper=-1;
418 if (!inf_GetDouble(ifl, bname, INF_CLOCK_PERIOD, &per)) per=-1;
419
420 if (defper==-1 && per==-1 && fabs(mult-1)<=1e-15)
421 avt_errmsg(INF_API_ERRMSG, "006", AVT_ERROR, bname);
422 // avt_error("infapi", 12, AVT_ERR, "no period specified for clock '%s' or no default period\n", bname);
423 else
424 {
425 if (per!=-1)
426 period=per*mult;
427 else if (defper!=-1)
428 period=defper*mult;
429 else
430 period=0;
431
432 inf_GetDouble(INF_FIG, bname, INF_MIN_RISE_TIME, &minr);
433 inf_GetDouble(INF_FIG, bname, INF_MAX_RISE_TIME, &maxr);
434 inf_GetDouble(INF_FIG, bname, INF_MIN_FALL_TIME, &minf);
435 inf_GetDouble(INF_FIG, bname, INF_MAX_FALL_TIME, &maxf);
436
437 if (minr<minf) min=minr; else min=minf;
438
439 minup=min+(minr-min)*mult+delta;
440 maxup=min+(maxr-min)*mult+delta;
441 mindown=min+(minf-min)*mult+delta;
442 maxdown=min+(maxf-min)*mult+delta;
443
444 if ((val & INF_CLOCK_INVERTED)!=0)
445 {
446 min=minup; minup=mindown; mindown=min;
447 min=maxup; maxup=maxdown; maxdown=min;
448 }
449 }
450 }
451 }
452 else
453 avt_errmsg(INF_API_ERRMSG, "007", AVT_ERROR);
454 // avt_error("infapi", 6, AVT_ERR, "missing clock parameter\n");
455 }
456
457 if (mode & INF_CLOCK_IDEAL)
458 {
459 if (countchain(elems)>=4)
460 {
461 // latencies
462 minup+=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
463 maxup+=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
464 mindown+=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
465 maxdown+=avt_parse_unit((char *)elems->DATA, 't'); elems=elems->NEXT;
466 }
467 else if (countchain(elems)!=0)
468 avt_errmsg(INF_API_ERRMSG, "007", AVT_ERROR);
469 // avt_error("infapi", 6, AVT_ERR, "missing clock parameter\n");
470 }
471
472 if (elems!=NULL)
473 avt_errmsg(INF_API_ERRMSG, "008", AVT_ERROR, (char *)elems->DATA);
474 //avt_error("infapi", 5, AVT_WAR, "too many parameters starting at '%s'\n", (char *)elems->DATA);
475
476 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_MIN_RISE_TIME, minup, NULL);
477 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_MAX_RISE_TIME, maxup, NULL);
478
479 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_MIN_FALL_TIME, mindown, NULL);
480 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_MAX_FALL_TIME, maxdown, NULL);
481
482 if (period>0)
483 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_CLOCK_PERIOD, period, NULL);
484 }
485 }
486 else
487 avt_errmsg(INF_API_ERRMSG, "007", AVT_ERROR);
488 // avt_error("infapi", 6, AVT_ERR, "missing clock parameter\n");
489 }
490 else
491 avt_errmsg(INF_API_ERRMSG, "007", AVT_ERROR);
492 // avt_error("infapi", 6, AVT_ERR, "missing clock parameter\n");
493 }
494
495 /*
496 void inf_DefineClock(char *name, double minup, double maxup, double mindown, double maxdown, double period)
497 {
498 inffig_list *ifl;
499 char *aname;
500
501 ifl=__giveinf();
502 aname=infTasVectName(name);
503 inf_AddInt(ifl, INF_LOADED_LOCATION, aname, INF_CLOCK_TYPE, 0, NULL);
504
505 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_MIN_RISE_TIME, minup, NULL);
506 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_MAX_RISE_TIME, maxup, NULL);
507
508 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_MIN_FALL_TIME, mindown, NULL);
509 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_MAX_FALL_TIME, maxdown, NULL);
510
511 if (period>0)
512 inf_AddDouble(ifl, INF_LOADED_LOCATION, aname, INF_CLOCK_PERIOD, period, NULL);
513 }
514 */
515
516 void inf_DefineBypass(char *name, char *where)
517 {
518 inffig_list *ifl;
519 ifl=__giveinf();
520
521 if (strcasecmp(where,"<")==0) where=INF_IN;
522 else if (strcasecmp(where,">")==0) where=INF_OUT;
523 else if (strcasecmp(where,"!")==0) where=INF_ONLYEND;
524 else if (strcasecmp(where,"")==0) where=INF_ALL;
525 else
526 {
527 avt_errmsg(INF_API_ERRMSG, "009", AVT_ERROR, where);
528 // avt_error("infapi", AVT_ERR, 2, "invalid bypass location given: '%s'\n", where);
529 return;
530 }
531 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_BYPASS, where, NULL);
532 }
533
534 void inf_DefineMutex(char *type, chain_list *list)
535 {
536 inffig_list *ifl;
537 chain_list *cl, *ch;
538
539 ifl=__giveinf();
540
541 if (strcasecmp(type,"muxup")==0) type=INF_MUXU;
542 else if (strcasecmp(type,"muxdn")==0) type=INF_MUXD;
543 else if (strcasecmp(type,"cmpup")==0) type=INF_CMPU;
544 else if (strcasecmp(type,"cmpdn")==0) type=INF_CMPD;
545 else
546 {
547 avt_errmsg(INF_API_ERRMSG, "010", AVT_ERROR, type);
548 // avt_error("infapi", AVT_ERR, 3, "unknown mutex type given: '%s'\n", type);
549 return;
550 }
551
552 cl=dupchainlst(list);
553 for (ch=cl; ch!=NULL; ch=ch->NEXT)
554 ch->DATA=mbk_decodeanyvector((char *)ch->DATA);
555 inf_AddList(ifl, INF_LOADED_LOCATION, type, "", cl, NULL);
556 }
557
558 void inf_DefineCrosstalkMutex(char *type, chain_list *list)
559 {
560 inffig_list *ifl;
561 chain_list *cl, *ch;
562
563 ifl=__giveinf();
564
565 if (strcasecmp(type,"muxup")==0) type=INF_CROSSTALKMUXU;
566 else if (strcasecmp(type,"muxdn")==0) type=INF_CROSSTALKMUXD;
567 else
568 {
569 avt_errmsg(INF_API_ERRMSG, "011", AVT_ERROR, type);
570 // avt_error("infapi", AVT_ERR, 3, "unknown crosstalk mutex type given: '%s'\n", type);
571 return;
572 }
573
574 cl=dupchainlst(list);
575 for (ch=cl; ch!=NULL; ch=ch->NEXT)
576 ch->DATA=mbk_decodeanyvector((char *)ch->DATA);
577 inf_AddList(ifl, INF_LOADED_LOCATION, type, "", cl, NULL);
578 }
579
580 void inf_DefineDisable(char *origin, char *destination)
581 {
582 inffig_list *ifl;
583 char *o, *d;
584
585 ifl=__giveinf();
586
587 if (origin==NULL || strcmp(origin,"")==0) o=NULL;
588 else o=infTasVectName(origin);
589 if (destination==NULL || strcmp(destination,"")==0) d=NULL;
590 else d=infTasVectName(destination);
591
592 if (o==NULL && d==NULL) return;
593
594 inf_AddAssociation(ifl, INF_LOADED_LOCATION, INF_DISABLE_PATH, "", o, d, 0, 0, NULL);
595 }
596
597 void inf_CleanFigure()
598 {
599 inffig_list *ifl;
600 ifl=__giveinf();
601 infClean(ifl, INF_LOADED_LOCATION);
602 }
603
604 void inf_DefineAsynchronousClockGroup(char *domain, chain_list *list, double period)
605 {
606 inffig_list *ifl;
607 chain_list *ch;
608
609 ifl=__giveinf();
610
611 for (ch=list; ch!=NULL; ch=ch->NEXT)
612 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName((char *)ch->DATA), INF_ASYNC_CLOCK_GROUP, infTasVectName(domain), NULL);
613
614 if (period>0)
615 inf_AddDouble(ifl, INF_LOADED_LOCATION, INF_ASYNC_CLOCK_GROUP_PERIOD, infTasVectName(domain), period, NULL);
616 }
617
618 void inf_DefineEquivalentClockGroup(char *domain, chain_list *list)
619 {
620 inffig_list *ifl;
621 chain_list *ch;
622
623 ifl=__giveinf();
624
625 for (ch=list; ch!=NULL; ch=ch->NEXT)
626 inf_AddString(ifl, INF_LOADED_LOCATION, infTasVectName((char *)ch->DATA), INF_EQUIV_CLOCK_GROUP, infTasVectName(domain), NULL);
627 }
628
629 void inf_DefinePower(char *name, double voltage)
630 {
631 inffig_list *ifl;
632
633 ifl=__giveinf();
634 inf_AddDouble(ifl, INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_POWER, voltage, NULL);
635 }
636
637 void inf_DefineTemperature(double temp)
638 {
639 inffig_list *ifl;
640
641 ifl=__giveinf();
642 inf_AddDouble(ifl, INF_LOADED_LOCATION, INF_OPERATING_CONDITION, INF_TEMPERATURE,temp,NULL);
643 }
644
645 void inf_DefineFalsePath(chain_list *elems)
646 {
647 ptype_list *pt=NULL;
648 char *name;
649 long type;
650 inffig_list *ifl;
651
652 while (elems!=NULL && strcmp(elems->DATA,":")!=0)
653 {
654 if (strcasecmp(elems->DATA,"<void>")==0)
655 name=NULL, type=INF_NOTHING;
656 else
657 {
658 name=infTasVectName(elems->DATA);
659 type=INF_UPDOWN;
660 if (elems->NEXT!=NULL)
661 {
662 if (strcasecmp(elems->NEXT->DATA,"<up>")==0 || strcasecmp(elems->NEXT->DATA,"<rise>")==0) type=INF_UP, elems=elems->NEXT;
663 else if (strcasecmp(elems->NEXT->DATA,"<down>")==0 || strcasecmp(elems->NEXT->DATA,"<fall>")==0) type=INF_DOWN, elems=elems->NEXT;
664 }
665 }
666 pt=addptype(pt, type, name);
667 elems=elems->NEXT;
668 }
669
670 while (pt!=NULL && pt->TYPE==INF_NOTHING) pt=delptype(pt, INF_NOTHING);
671 pt=(ptype_list *)reverse((chain_list *)pt);
672 while (pt!=NULL && pt->TYPE==INF_NOTHING) pt=delptype(pt, INF_NOTHING);
673 pt=(ptype_list *)reverse((chain_list *)pt);
674
675 if (pt==NULL) // { avt_error("infapi", 6, AVT_WAR, "no signal elements in falsepath\n"); }
676 avt_errmsg(INF_API_ERRMSG, "012", AVT_ERROR);
677 else
678 {
679 if (elems!=NULL)
680 {
681 if (elems->NEXT==NULL)
682 avt_errmsg(INF_API_ERRMSG, "007", AVT_ERROR);
683 // { avt_error("infapi", 6, AVT_ERR, "missing clock parameter\n"); }
684 else if (elems->NEXT->NEXT!=NULL)
685 avt_errmsg(INF_API_ERRMSG, "008", AVT_ERROR, (char *)elems->NEXT->NEXT->DATA);
686 // { avt_error("infapi", 5, AVT_WAR, "too many parameters starting at '%s'\n", (char *)elems->NEXT->NEXT->DATA); }
687 else
688 {
689 if (strcasecmp((char *)elems->NEXT->DATA, "<hz>")==0)
690 pt=addptype(pt, INF_CK, infTasVectName("^"));
691 else if (strcasecmp((char *)elems->NEXT->DATA, "<nothz>")==0)
692 pt=addptype(pt, INF_CK, infTasVectName("°"));
693 else
694 pt=addptype(pt, INF_CK, infTasVectName(elems->NEXT->DATA));
695 }
696 }
697 }
698
699 if (pt!=NULL)
700 {
701 ifl=__giveinf();
702 pt=(ptype_list *)reverse((chain_list *)pt);
703 ifl->LOADED.INF_FALSEPATH=addchain(ifl->LOADED.INF_FALSEPATH, pt);
704 }
705 }
706
707 void inf_DefinePathDelayMargin(char *type, char *name, double factor, double delta, char *pathtype_s)
708 {
709 int sigtype, pathtype, i, j, k;
710 char *c, *tok;
711 char buf[1024];
712 inffig_list *ifl;
713 struct
714 {
715 int t;
716 char *s;
717 } run[]=
718 {
719 {INF_MARGIN_ON_MINDELAY, INF_PATHDELAYMARGINMIN},
720 {INF_MARGIN_ON_MAXDELAY, INF_PATHDELAYMARGINMAX},
721 {INF_MARGIN_ON_CLOCKPATH, INF_PATHDELAYMARGINCLOCK},
722 {INF_MARGIN_ON_DATAPATH, INF_PATHDELAYMARGINDATA},
723 {INF_MARGIN_ON_RISEDELAY, INF_PATHDELAYMARGINRISE},
724 {INF_MARGIN_ON_FALLDELAY, INF_PATHDELAYMARGINFALL}
725 };
726 char section[128];
727
728 if (strcasecmp(type,"any")==0) sigtype=INF_MARGIN_ON_LATCH|INF_MARGIN_ON_BREAK|INF_MARGIN_ON_CONNECTOR|INF_MARGIN_ON_PRECHARGE|INF_MARGIN_ON_CMD;
729 else if (strcasecmp(type,"latch")==0) sigtype=INF_MARGIN_ON_LATCH;
730 else if (strcasecmp(type,"prech")==0) sigtype=INF_MARGIN_ON_PRECHARGE;
731 else if (strcasecmp(type,"break")==0) sigtype=INF_MARGIN_ON_BREAK;
732 else if (strcasecmp(type,"cmd")==0) sigtype=INF_MARGIN_ON_CMD;
733 else if (strcasecmp(type,"con")==0) sigtype=INF_MARGIN_ON_CONNECTOR;
734 else
735 {
736 avt_errmsg(INF_API_ERRMSG, "013", AVT_ERROR, type);
737 // avt_error("infapi", 7, AVT_ERR, "invalid signal type '%s'\n", type);
738 return;
739 }
740
741 pathtype=0;
742 strcpy(buf, pathtype_s);
743 tok=strtok_r(buf, " _", &c);
744 while (tok!=NULL)
745 {
746 if (strcasecmp(tok,"min")==0) pathtype|=INF_MARGIN_ON_MINDELAY;
747 else if (strcasecmp(tok,"max")==0) pathtype|=INF_MARGIN_ON_MAXDELAY;
748 else if (strcasecmp(tok,"rise")==0) pathtype|=INF_MARGIN_ON_RISEDELAY;
749 else if (strcasecmp(tok,"fall")==0) pathtype|=INF_MARGIN_ON_FALLDELAY;
750 else if (strcasecmp(tok,"clockpath")==0) pathtype|=INF_MARGIN_ON_CLOCKPATH;
751 else if (strcasecmp(tok,"datapath")==0) pathtype|=INF_MARGIN_ON_DATAPATH;
752 else
753 {
754 avt_errmsg(INF_API_ERRMSG, "014", AVT_ERROR, tok);
755 // avt_error("infapi", 8, AVT_ERR, "unrecognized token '%s'\n", tok);
756 }
757 tok=strtok_r(NULL, " ", &c);
758 }
759
760 ifl=__giveinf();
761
762 if (fabs(delta)>=1) delta*=1e-12;
763
764 if ((pathtype & (INF_MARGIN_ON_MINDELAY|INF_MARGIN_ON_MAXDELAY))==0)
765 pathtype|=INF_MARGIN_ON_MINDELAY|INF_MARGIN_ON_MAXDELAY;
766 if ((pathtype & (INF_MARGIN_ON_CLOCKPATH|INF_MARGIN_ON_DATAPATH))==0)
767 pathtype|=INF_MARGIN_ON_CLOCKPATH|INF_MARGIN_ON_DATAPATH;
768 if ((pathtype & (INF_MARGIN_ON_RISEDELAY|INF_MARGIN_ON_FALLDELAY))==0)
769 pathtype|=INF_MARGIN_ON_RISEDELAY|INF_MARGIN_ON_FALLDELAY;
770
771 for (i=0; i<2; i++)
772 for (j=2; j<4; j++)
773 for (k=4; k<6; k++)
774 {
775 if ((pathtype & (run[i].t|run[j].t|run[k].t))==(run[i].t|run[j].t|run[k].t))
776 {
777 sprintf(section,INF_PATHDELAYMARGINPREFIX"|%s,%s,%s",run[i].s, run[j].s, run[k].s);
778 inf_AddMiscData(ifl, INF_LOADED_LOCATION, infTasVectName(name), section, NULL, NULL, pathtype|sigtype, factor, delta, NULL);
779 }
780
781 }
782
783 /*
784 if ((pathtype & (INF_MARGIN_ON_MINDELAY|INF_MARGIN_ON_CLOCKPATH))==(INF_MARGIN_ON_MINDELAY|INF_MARGIN_ON_CLOCKPATH))
785 inf_AddMiscData(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_PATHDELAYMARGINCLOCKMIN, NULL, NULL, pathtype|sigtype, factor, delta, NULL);
786
787 if ((pathtype & (INF_MARGIN_ON_MAXDELAY|INF_MARGIN_ON_CLOCKPATH))==(INF_MARGIN_ON_MAXDELAY|INF_MARGIN_ON_CLOCKPATH))
788 inf_AddMiscData(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_PATHDELAYMARGINCLOCKMAX, NULL, NULL, pathtype|sigtype, factor, delta, NULL);
789
790 if ((pathtype & (INF_MARGIN_ON_MINDELAY|INF_MARGIN_ON_DATAPATH))==(INF_MARGIN_ON_MINDELAY|INF_MARGIN_ON_DATAPATH))
791 inf_AddMiscData(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_PATHDELAYMARGINDATAMIN, NULL, NULL, pathtype|sigtype, factor, delta, NULL);
792
793 if ((pathtype & (INF_MARGIN_ON_MAXDELAY|INF_MARGIN_ON_DATAPATH))==(INF_MARGIN_ON_MAXDELAY|INF_MARGIN_ON_DATAPATH))
794 inf_AddMiscData(ifl, INF_LOADED_LOCATION, infTasVectName(name), INF_PATHDELAYMARGINDATAMAX, NULL, NULL, pathtype|sigtype, factor, delta, NULL);
795 */
796
797 }
798
799
800 void inf_DefineIgnore(char *type, chain_list *list)
801 {
802 inffig_list *ifl;
803 chain_list *ch;
804 char *section_type;
805
806 ifl=__giveinf();
807
808 if (strcasecmp(type,"instance")==0 || strcasecmp(type,"instances")==0)
809 section_type=INF_IGNORE_INSTANCE;
810 else if (strcasecmp(type,"transistor")==0 || strcasecmp(type,"transistors")==0)
811 section_type=INF_IGNORE_TRANSISTOR;
812 else if (strcasecmp(type,"resistance")==0 || strcasecmp(type,"resistances")==0)
813 section_type=INF_IGNORE_RESISTANCE;
814 else if (strcasecmp(type,"diode")==0 || strcasecmp(type,"diodes")==0)
815 section_type=INF_IGNORE_DIODE;
816 else if (strcasecmp(type,"capacitance")==0 || strcasecmp(type,"capacitances")==0)
817 section_type=INF_IGNORE_CAPACITANCE;
818 else if (strcasecmp(type,"signalname")==0 || strcasecmp(type,"signalnames")==0)
819 section_type=INF_IGNORE_NAMES;
820 else if (strcasecmp(type,"parasitics")==0)
821 section_type=INF_IGNORE_PARASITICS;
822 else
823 {
824 avt_errmsg(INF_API_ERRMSG, "015", AVT_ERROR, type);
825 // avt_error("infapi", 9, AVT_ERR, "unknown section '%s', ignoring section.\n", type);
826 section_type=NULL;
827 }
828
829 if (section_type!=NULL)
830 for (ch=list; ch!=NULL; ch=ch->NEXT)
831 inf_AddAssociation(ifl, INF_LOADED_LOCATION, section_type, "", namealloc((char *)ch->DATA), NULL, 0, 0, NULL);
832 }
833
834 void inf_DefineConnectorDirections(char *type, chain_list *list)
835 {
836 inffig_list *ifl;
837 chain_list *ch;
838 char *val;
839
840 ifl=__giveinf();
841
842 if (strcasecmp(type,"input")==0) val="I";
843 else if (strcasecmp(type,"output")==0) val="O";
844 else if (strcasecmp(type,"inout")==0) val="B";
845 else if (strcasecmp(type,"tristate")==0) val="T";
846 else if (strcasecmp(type,"hz")==0) val="Z";
847 else if (strcasecmp(type,"unknown")==0) val="X";
848 else
849 {
850 avt_errmsg(INF_API_ERRMSG, "015", AVT_ERROR, type);
851 // avt_error("infapi", 10, AVT_ERR, "unknown direction '%s', ignoring section.\n", type);
852 val=NULL;
853 }
854
855 if (val!=NULL)
856 for (ch=list; ch!=NULL; ch=ch->NEXT)
857 inf_AddString(ifl, INF_LOADED_LOCATION, namealloc((char *)ch->DATA), INF_CONNECTOR_DIRECTION, val, NULL);
858
859 }
860
861 void inf_DefineConnectorSwing(char *name, double lowlevel, double highlevel)
862 {
863 inffig_list *ifl;
864 char *name0;
865 ifl=__giveinf();
866
867 name0=infTasVectName (name);
868
869 if (lowlevel!=0)
870 inf_AddDouble(ifl, INF_LOADED_LOCATION, name0, INF_PIN_LOW_VOLTAGE, lowlevel, NULL);
871 inf_AddDouble(ifl, INF_LOADED_LOCATION, name0, INF_PIN_HIGH_VOLTAGE, highlevel, NULL);
872 }
873
874 static void convert_data(inffig_list *ifl, char *name, char *section, chain_list *data, int mode, char tm)
875 {
876 chain_list *cl, *ch;
877 double val, *al;
878
879 for (cl=data, ch=NULL; cl!=NULL; cl=cl->NEXT)
880 {
881 val=avt_parse_unit((char *)cl->DATA, tm);
882 al=(double *)mbkalloc(sizeof(double));
883 *al=val;
884 ch=addchain(ch, al);
885 }
886
887 ch=reverse(ch);
888 if (mode==0)
889 {
890 inf_RemoveKey(ifl, INF_LOADED_LOCATION, name, section);
891
892 for (cl=ch; cl!=NULL; cl=cl->NEXT)
893 {
894 inf_AddAssociation(ifl, INF_LOADED_LOCATION, name, section, NULL, NULL, 0, *(double *)cl->DATA, NULL);
895 mbkfree(cl->DATA);
896 }
897 }
898 else
899 {
900 if (countchain(ch)!=3)
901 avt_errmsg(INF_API_ERRMSG, "017", AVT_ERROR);
902 //avt_error("infapi", AVT_ERR, 11, "too much values for slope or capa generation\n");
903 else
904 {
905 double a=*(double *)ch->DATA, b=*(double *)ch->NEXT->DATA, s=*(double *)ch->NEXT->NEXT->DATA;
906 inf_RemoveKey(ifl, INF_LOADED_LOCATION, name, section);
907 for (val = 0 ; val <= (b - a+1e-18) / s ; val++)
908 {
909 inf_AddAssociation(ifl, INF_LOADED_LOCATION, name, section, NULL, NULL, 0, a + s * val, NULL);
910 }
911 }
912 for (cl=ch; cl!=NULL; cl=cl->NEXT)
913 {
914 mbkfree(cl->DATA);
915 }
916 }
917 freechain(ch);
918 }
919
920 static void inf_DefineAxis(char *name, chain_list *list, char *type, char *section, char tm)
921 {
922 inffig_list *ifl;
923
924 ifl=__giveinf();
925
926 if (strcasecmp(type,"linear")==0)
927 convert_data(ifl, infTasVectName(name), section, list, 1, tm);
928 else if (strcasecmp(type,"custom")==0)
929 convert_data(ifl, infTasVectName(name), section, list, 0, tm);
930 else
931 avt_errmsg(INF_API_ERRMSG, "018", AVT_ERROR, type);
932 // avt_error("infapi", AVT_ERR, 13, "unknown type given: '%s'\n", type);
933 }
934
935 void inf_DefineSlopeRange(char *name, chain_list *list, char *type)
936 {
937 inf_DefineAxis(name, list, type, INF_SLOPEIN, 't');
938 }
939
940 void inf_DefineCapacitanceRange(char *name, chain_list *list, char *type)
941 {
942 inf_DefineAxis(name, list, type, INF_CAPAOUT, 'c');
943 }
944
945 void inf_MarkSignal(char *name, char *marks)
946 {
947 inf_AddInt(__giveinf(), INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_MARKSIG, inf_code_marksig(marks), NULL);
948 }
949
950 void inf_MarkTransistor(char *name, char *marks)
951 {
952 inf_AddInt(__giveinf(), INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_MARKTRANS, inf_code_marktrans(marks), NULL);
953 }
954
955 void inf_DisableTimingArc(char *input, char *output, char *direction)
956 {
957 int dir;
958 if (strlen(direction)==2)
959 {
960 if (tolower(direction[0])=='u' || tolower(direction[0])=='r') dir=0x20;
961 else if (tolower(direction[0])=='d' || tolower(direction[0])=='f') dir=0x10;
962 else if (direction[0]=='?') dir=0x30;
963 else
964 {
965 avt_errmsg(INF_API_ERRMSG, "019", AVT_ERROR, direction);
966 // avt_error("infapi", AVT_ERR, 14, "inf_DisableTimingArc: invalid direction '%s'\n", direction);
967 return;
968 }
969
970 if (tolower(direction[1])=='u' || tolower(direction[1])=='r') dir|=0x02;
971 else if (tolower(direction[1])=='d' || tolower(direction[1])=='f') dir|=0x01;
972 else if (direction[1]=='?') dir|=0x03;
973 else
974 {
975 avt_errmsg(INF_API_ERRMSG, "019", AVT_ERROR, direction);
976 // avt_error("infapi", AVT_ERR, 14, "inf_DisableTimingArc: invalid direction '%s'\n", direction);
977 return;
978 }
979
980 inf_AddAssociation(__giveinf(), INF_LOADED_LOCATION, infTasVectName(output), INF_DISABLE_GATE_DELAY, infTasVectName(input), NULL, dir, 0, NULL);
981 }
982 else
983 avt_errmsg(INF_API_ERRMSG, "019", AVT_ERROR, direction);
984 // avt_error("infapi", AVT_ERR, 14, "inf_DisableTimingArc: invalid direction '%s'\n", direction);
985 }
986
987 void inf_DefineCharacteristics(char *type, chain_list *list)
988 {
989 inffig_list *ifl;
990 chain_list *ch;
991 char *val;
992
993 ifl=__giveinf();
994
995 if (strcasecmp(type,"data")==0) val=INF_CHARAC_DATA;
996 else
997 {
998 avt_errmsg(INF_API_ERRMSG, "020", AVT_ERROR, type);
999 // avt_error("infapi", 15, AVT_ERR, "unknown characteristic '%s', ignoring section.\n", type);
1000 val=NULL;
1001 }
1002
1003 if (val!=NULL)
1004 for (ch=list; ch!=NULL; ch=ch->NEXT)
1005 inf_AddString(ifl, INF_LOADED_LOCATION, namealloc((char *)ch->DATA), val, type, NULL);
1006
1007 }
1008 //chain_list *list)
1009 void inf_DefineDirective_sub(chain_list *list)
1010 {
1011 int val, delaymode;
1012 char temp, temp1, act;
1013 char *nom1, *nom2;
1014 splitint *si=(splitint *)&val;
1015 inffig_list *ifl;
1016 double margin;
1017
1018 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1019
1020 ifl=__giveinf();
1021
1022 if (strcasecmp((char *)list->DATA, "filter")==0) si->cval.a=INF_DIRECTIVE_FILTER;
1023 else if (strcasecmp((char *)list->DATA, "check")==0) si->cval.a=0;
1024 else { avt_errmsg(INF_API_ERRMSG, "018", AVT_ERROR, (char *)list->DATA); return; }
1025
1026 list=list->NEXT;
1027 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1028
1029 if (strcasecmp((char *)list->DATA, "clock")==0) temp=INF_DIRECTIVE_CLOCK, list=list->NEXT;
1030 else if (strcasecmp((char *)list->DATA, "data")==0) temp=0, list=list->NEXT;
1031 else temp=0; //{ avt_errmsg(INF_API_ERRMSG, "018", AVT_ERROR, sig1type); return; }
1032
1033 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1034
1035 nom1=(char *)list->DATA;
1036
1037 list=list->NEXT;
1038 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1039
1040 if (!strcasecmp((char *)list->DATA,"rising")) temp|=INF_DIRECTIVE_RISING, list=list->NEXT;
1041 else if (!strcasecmp((char *)list->DATA,"falling")) temp|=INF_DIRECTIVE_FALLING, list=list->NEXT;
1042 // else temp|=INF_DIRECTIVE_FALLING|INF_DIRECTIVE_RISING;
1043 // else { avt_errmsg(INF_API_ERRMSG, "018", AVT_ERROR, dir1); return; }
1044
1045 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1046
1047 delaymode=0;
1048 if (strcasecmp((char *)list->DATA, "before")==0) act=INF_DIRECTIVE_BEFORE;
1049 else if (strcasecmp((char *)list->DATA, "after")==0) act=INF_DIRECTIVE_AFTER;
1050 else if (strcasecmp((char *)list->DATA, "with")==0) act=0;
1051 else { avt_errmsg(INF_API_ERRMSG, "018", AVT_ERROR, (char *)list->DATA); return; }
1052
1053 list=list->NEXT;
1054 if (list==NULL){ avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1055
1056 if (strcasecmp((char *)list->DATA, "clock")==0) temp1=INF_DIRECTIVE_CLOCK, list=list->NEXT;
1057 else if (strcasecmp((char *)list->DATA, "data")==0) temp1=0, list=list->NEXT;
1058 else if (strcasecmp((char *)list->DATA, "delay")==0) delaymode=1;
1059 else temp1=0;
1060
1061 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1062
1063 if (delaymode==0)
1064 {
1065
1066 nom2=(char *)list->DATA;
1067
1068 list=list->NEXT;
1069 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1070
1071 if (act==0)
1072 {
1073 if ((temp1 & INF_DIRECTIVE_CLOCK)==0)
1074 { avt_errmsg(INF_API_ERRMSG, "026", AVT_ERROR); return; }
1075 if (!strcasecmp((char *)list->DATA,"up")) temp1|=INF_DIRECTIVE_UP;
1076 else if (!strcasecmp((char *)list->DATA,"down")) temp1|=INF_DIRECTIVE_DOWN;
1077 else { avt_errmsg(INF_API_ERRMSG, "018", AVT_ERROR, (char *)list->DATA); return; }
1078 }
1079 else
1080 {
1081 if (!strcasecmp((char *)list->DATA,"rising")) temp1|=INF_DIRECTIVE_RISING;
1082 else if (!strcasecmp((char *)list->DATA,"falling")) temp1|=INF_DIRECTIVE_FALLING;
1083 else temp1|=INF_DIRECTIVE_FALLING|INF_DIRECTIVE_RISING;
1084 // else { avt_errmsg(INF_API_ERRMSG, "018", AVT_ERROR, dir2); return; }
1085 }
1086
1087 if ((si->cval.a & INF_DIRECTIVE_FILTER)!=0 && ((temp & INF_DIRECTIVE_CLOCK)!=0 || (temp1 & INF_DIRECTIVE_CLOCK)==0 || act!=0))
1088 { avt_errmsg(INF_ERRMSG, "027", AVT_ERROR); return; }
1089
1090 list=list->NEXT;
1091 if (list!=NULL)
1092 {
1093 margin=avt_parse_unit((char *)list->DATA, 't');
1094 if (list->NEXT!=NULL) avt_errmsg(INF_API_ERRMSG, "008", AVT_ERROR, (char *)list->NEXT->DATA);
1095 }
1096 else margin=0;
1097 si->cval.d=temp1;
1098 }
1099 else
1100 {
1101 nom2="*";
1102 si->cval.d=INF_DIRECTIVE_DELAY;
1103 list=list->NEXT;
1104 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1105 margin=avt_parse_unit((char *)list->DATA, 't');
1106 list=list->NEXT;
1107 if (list!=NULL && !strcasecmp((char *)list->DATA,"from"))
1108 {
1109 list=list->NEXT;
1110 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1111 nom2=(char *)list->DATA;
1112 list=list->NEXT;
1113 if (list!=NULL)
1114 {
1115 temp1=0;
1116 if (!strcasecmp((char *)list->DATA,"rising")) temp1|=INF_DIRECTIVE_RISING;
1117 else if (!strcasecmp((char *)list->DATA,"falling")) temp1|=INF_DIRECTIVE_FALLING;
1118 si->cval.d|=temp1;
1119 list=list->NEXT;
1120 }
1121 }
1122 if (list!=NULL) avt_errmsg(INF_API_ERRMSG, "008", AVT_ERROR, (char *)list->NEXT->DATA);
1123 }
1124 si->cval.b=temp;
1125 si->cval.c=act;
1126
1127 inf_AddAssociation(ifl, INF_LOADED_LOCATION, INF_DIRECTIVES, "", infTasVectName(nom1), infTasVectName(nom2), val, margin, NULL);
1128 }
1129
1130 void inf_DefineRS(char *name, char *type)
1131 {
1132 int mark=inf_code_markRS(type);
1133 if (mark!=0) inf_AddInt(__giveinf(), INF_LOADED_LOCATION, mbk_decodeanyvector(name), INF_MARKRS, mark, NULL);
1134 else avt_errmsg(INF_ERRMSG, "028", AVT_WARNING, type);
1135 }
1136
1137 void inf_DefineFalseSlack_sub(chain_list *list)
1138 {
1139 char *nom1, *nom2, *nom3, *nom4;
1140 char dir1, dir2, dir3, dir4, what;
1141 ptype_list *pt;
1142 inffig_list *ifl;
1143
1144
1145 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1146
1147 ifl=__giveinf();
1148
1149 what=INF_FALSESLACK_SETUP|INF_FALSESLACK_HOLD;
1150 nom1=(char *)list->DATA;
1151 nom2=strrchr(nom1,':');
1152 if (nom2!=NULL && *(nom2+1)=='\0')
1153 {
1154 char buf[1024], *tok, *c;
1155 char val=0;
1156 strcpy(buf, nom1);
1157 *strrchr(buf,':')='\0';
1158 tok=strtok_r(buf, "-", &c);
1159 while (tok!=NULL)
1160 {
1161 if (strcasecmp(tok, "setup")==0) val|=INF_FALSESLACK_SETUP;
1162 else if (strcasecmp(tok, "hold")==0) val|=INF_FALSESLACK_HOLD;
1163 else if (strcasecmp(tok, "latch")==0) val|=INF_FALSESLACK_LATCH;
1164 else if (strcasecmp(tok, "prech")==0) val|=INF_FALSESLACK_PRECH;
1165 else
1166 {
1167 avt_errmsg(INF_API_ERRMSG, "025", AVT_ERROR, tok);
1168 }
1169 tok=strtok_r(NULL, " ", &c);
1170 }
1171 if ((val & (INF_FALSESLACK_SETUP|INF_FALSESLACK_HOLD))==0)
1172 val|=INF_FALSESLACK_SETUP|INF_FALSESLACK_HOLD;
1173 what=val;
1174 list=list->NEXT;
1175 }
1176
1177 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1178
1179 nom1=(char *)list->DATA, list=list->NEXT;
1180 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1181
1182 if (strcasecmp((char *)list->DATA, "<up>")==0 || strcasecmp((char *)list->DATA, "<rise>")==0) dir1=INF_FALSESLACK_UP, list=list->NEXT;
1183 else if (strcasecmp((char *)list->DATA, "<down>")==0 || strcasecmp((char *)list->DATA, "<fall>")==0) dir1=INF_FALSESLACK_DOWN, list=list->NEXT;
1184 else dir1=INF_FALSESLACK_UP|INF_FALSESLACK_DOWN;
1185
1186 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1187
1188 nom2=(char *)list->DATA, list=list->NEXT;
1189 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1190
1191 if (strcasecmp((char *)list->DATA, "<up>")==0 || strcasecmp((char *)list->DATA, "<rise>")==0) dir2=INF_FALSESLACK_UP, list=list->NEXT;
1192 else if (strcasecmp((char *)list->DATA, "<down>")==0 || strcasecmp((char *)list->DATA, "<fall>")==0) dir2=INF_FALSESLACK_DOWN, list=list->NEXT;
1193 else dir2=INF_FALSESLACK_UP|INF_FALSESLACK_DOWN;
1194
1195 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1196
1197 nom3=(char *)list->DATA, list=list->NEXT;
1198 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1199
1200 if (strcasecmp((char *)list->DATA, "<up>")==0 || strcasecmp((char *)list->DATA, "<rise>")==0) dir3=INF_FALSESLACK_UP, list=list->NEXT;
1201 else if (strcasecmp((char *)list->DATA, "<down>")==0 || strcasecmp((char *)list->DATA, "<fall>")==0) dir3=INF_FALSESLACK_DOWN, list=list->NEXT;
1202 else dir3=INF_FALSESLACK_UP|INF_FALSESLACK_DOWN;
1203
1204 if (strcasecmp((char *)list->DATA, "<hz>")==0) dir3|=INF_FALSESLACK_HZ, list=list->NEXT;
1205 else if (strcasecmp((char *)list->DATA, "<nothz>")==0) dir3|=INF_FALSESLACK_NOTHZ, list=list->NEXT;
1206 else dir3|=INF_FALSESLACK_HZ|INF_FALSESLACK_NOTHZ;
1207
1208 if (list==NULL) { avt_errmsg(INF_API_ERRMSG, "024", AVT_ERROR); return; }
1209
1210 nom4=(char *)list->DATA, list=list->NEXT;
1211 if (list!=NULL)
1212 {
1213 if (strcasecmp((char *)list->DATA, "<up>")==0 || strcasecmp((char *)list->DATA, "<rise>")==0) dir4=INF_FALSESLACK_UP, list=list->NEXT;
1214 else if (strcasecmp((char *)list->DATA, "<down>")==0 || strcasecmp((char *)list->DATA, "<fall>")==0) dir4=INF_FALSESLACK_DOWN, list=list->NEXT;
1215 else dir4=INF_FALSESLACK_UP|INF_FALSESLACK_DOWN;
1216 }
1217 else dir4=INF_FALSESLACK_UP|INF_FALSESLACK_DOWN;
1218
1219 if (list!=NULL) avt_errmsg(INF_API_ERRMSG, "008", AVT_ERROR, (char *)list->DATA);
1220
1221 pt=addptype(NULL, dir4, infTasVectName(nom4));
1222 pt=addptype(pt, dir3, infTasVectName(nom3));
1223 pt=addptype(pt, dir2, infTasVectName(nom2));
1224 pt=addptype(pt, dir1|what, infTasVectName(nom1));
1225 ifl->LOADED.INF_FALSESLACK=addchain(ifl->LOADED.INF_FALSESLACK, pt);
1226 }
1227
1228 void inf_DefineSwitchingProbability(char *name, double val)
1229 {
1230 inffig_list *ifl;
1231
1232 ifl=__giveinf();
1233 if (val>=0 && val<=1)
1234 {
1235 name=infTasVectName (name);
1236 inf_AddDouble(ifl, INF_LOADED_LOCATION, name, INF_SWITCHING_PROBABILITY, val, NULL);
1237 }
1238 else
1239 avt_errmsg(INF_API_ERRMSG, "029", AVT_ERROR, val);
1240 }
1241