Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / api / stb / stb_API_power_tools.c
1 #include MUT_H
2 #include MLO_H
3 #include MLU_H
4 #include RCN_H
5 #include MSL_H
6 #include AVT_H
7 #include INF_H
8 #include ELP_H
9 #include CNS_H
10 #include YAG_H
11 #include TLC_H
12 #include TRC_H
13 #include STM_H
14 #include TTV_H
15 #include MCC_H
16 #include SIM_H
17 #include TAS_H
18 #include FCL_H
19 #include BEH_H
20 #include CBH_H
21 #include LIB_H
22 #include TLF_H
23 #include STB_H
24
25 #define API_USE_REAL_TYPES
26 #include "../ttv/ttv_API_LOCAL.h"
27 #include "ttv_API.h"
28 #include "../ttv/ttv_API_display.h"
29 #include "../ttv/ttv_API_util.h"
30 #include "stb_LOCAL.h"
31 #include "stb_API.h"
32 #include "../../tas/stb/stb_transfer.h"
33 #include "../../tas/stb/stb_util.h"
34 #define SETUP_SLOPE_INFO 0xfab70124
35 #define SETUP_SLOPE_SOURCE 0xfab70125
36 typedef struct
37 {
38 long setup_slope;
39 long setup_slope_hz;
40 long period;
41 stbck *ck;
42 } setup_slope_info_phase;
43
44 typedef struct
45 {
46 long worst_slack;
47 setup_slope_info_phase *ssip;
48 } setup_slope_info;
49
50 static setup_slope_info *stb_get_setup_slope_info(ttvevent_list *tve)
51 {
52 ptype_list *pt;
53 if ((pt=getptype(tve->USER, SETUP_SLOPE_INFO))!=NULL) return (setup_slope_info *)pt->DATA;
54 return NULL;
55 }
56
57 static setup_slope_info *stb_give_setup_slope_info(ttvevent_list *tve, int nbphase)
58 {
59 setup_slope_info *ssi;
60 int i;
61 if ((ssi=stb_get_setup_slope_info(tve))!=NULL) return ssi;
62 ssi=(setup_slope_info *)mbkalloc(sizeof(setup_slope_info));
63 ssi->ssip=(setup_slope_info_phase *)mbkalloc(sizeof(setup_slope_info_phase)*nbphase);
64
65 for (i=0; i<nbphase; i++)
66 {
67 ssi->ssip[i].setup_slope=ssi->ssip[i].setup_slope_hz=TTV_NOTIME;
68 ssi->ssip[i].ck=NULL;
69 }
70 ssi->worst_slack=TTV_NOTIME;
71 tve->USER=addptype(tve->USER, SETUP_SLOPE_INFO, ssi);
72 return ssi;
73 }
74
75 static void stb_delete_setup_slope_info(ttvevent_list *tve)
76 {
77 setup_slope_info *ssi;
78 if ((ssi=stb_get_setup_slope_info(tve))!=NULL)
79 {
80 mbkfree(ssi->ssip);
81 mbkfree(ssi);
82 tve->USER=delptype(tve->USER, SETUP_SLOPE_INFO);
83 }
84 }
85
86
87 void stb_propagate_setup_slope (stbfig_list *stbfig, ttvevent_list *event)
88 {
89 stbnode *node;
90 ttvevent_list *inevent, *cmdmax;
91 ttvline_list *line;
92 stbck *ck;
93 long delaymax;
94 long delaymin;
95 long slope, period;
96 char phase;
97 char level;
98 int hz, newstartslope, i, slopesource, sourcechanged;
99 setup_slope_info *ssi, *outssi;
100 long *pslope;
101
102 if((node = stb_getstbnode (event)) == NULL)
103 return ;
104
105 if ((stbfig->STABILITYMODE & STB_STABILITY_LAST) == STB_STABILITY_LAST)
106 level = stbfig->FIG->INFO->LEVEL;
107 else
108 level = event->ROOT->ROOT->INFO->LEVEL;
109
110 if (stbfig->GRAPH == STB_RED_GRAPH)
111 {
112 ttv_expfigsig (stbfig->FIG, event->ROOT, level, stbfig->FIG->INFO->LEVEL,
113 TTV_STS_CL_PJT, TTV_FILE_TTX);
114 line = event->INPATH;
115 }
116 else
117 {
118 ttv_expfigsig (stbfig->FIG, event->ROOT, level, stbfig->FIG->INFO->LEVEL,
119 TTV_STS_CLS_FED, TTV_FILE_DTX);
120 line = event->INLINE;
121 }
122
123 if (stb_get_setup_slope_info(event)!=NULL) sourcechanged=1; else sourcechanged=0;
124 outssi=stb_give_setup_slope_info(event, node->NBINDEX);
125
126 for (; line; line = line->NEXT)
127 {
128 if (((line->TYPE & TTV_LINE_CONT) == TTV_LINE_CONT) ||
129 (((line->TYPE & (TTV_LINE_D | TTV_LINE_T)) != 0) &&
130 (line->FIG != stbfig->FIG)) ||
131 (((line->TYPE & (TTV_LINE_P | TTV_LINE_F)) != 0) &&
132 (line->FIG != stbfig->FIG) &&
133 ((stbfig->STABILITYMODE & STB_STABILITY_LAST) == STB_STABILITY_LAST)))
134 continue;
135
136 if ((line->TYPE & TTV_LINE_HZ)!=0) hz=1; else hz=0;
137
138 inevent = line->NODE;
139 delaymin = ttv_getdelaymin (line);
140 delaymax = ttv_getdelaymax (line);
141 if (delaymin == TTV_NOTIME) delaymin = delaymax;
142 if (delaymax == TTV_NOTIME) delaymax = delaymin;
143
144 newstartslope=0;
145 ssi=stb_give_setup_slope_info(inevent, node->NBINDEX);
146
147 if (getptype(inevent->USER, SETUP_SLOPE_SOURCE)!=NULL) slopesource=1; else slopesource=0;
148
149 for (ck=node->CK; node->CK==NULL || ck!=NULL ; ck=ck->NEXT)
150 {
151 if(ck != NULL && ck->CMD!=NULL)
152 {
153 cmdmax = ttv_getlinecmd(stbfig->FIG, line, TTV_LINE_CMDMAX) ;
154 if(ck->CMD != cmdmax) continue ;
155
156 // if (!stb_checkvalidcommand(event, ck)) continue;
157 }
158
159 slope=stb_getsetupslope(stbfig, node, ck, hz, &phase);
160 if (slope!=TTV_NOTIME && phase!=STB_NO_INDEX)
161 {
162 newstartslope=1;
163 if (sourcechanged)
164 {
165 for (i=0; i<node->NBINDEX; i++) outssi->ssip[i].setup_slope=ssi->ssip[i].setup_slope_hz=TTV_NOTIME;
166 outssi->worst_slack=TTV_NOTIME;
167 sourcechanged=0;
168 }
169 if (getptype(event->USER, SETUP_SLOPE_SOURCE)==NULL)
170 event->USER=addptype(event->USER, SETUP_SLOPE_SOURCE, NULL);
171
172 if (!hz) pslope=&outssi->ssip[(int)phase].setup_slope; else pslope=&outssi->ssip[(int)phase].setup_slope_hz;
173 if (*pslope==TTV_NOTIME || *pslope>slope)
174 {
175 *pslope=slope;
176 outssi->ssip[(int)phase].period=ck!=NULL?ck->PERIOD:0;
177 outssi->ssip[(int)phase].ck=ck;
178 }
179 outssi->worst_slack=node->SETUP!=STB_NO_TIME?node->SETUP:TTV_NOTIME;
180
181 slope-=delaymax;
182 if (slopesource==0)
183 {
184 if (ssi->ssip[(int)phase].setup_slope==TTV_NOTIME || ssi->ssip[(int)phase].setup_slope>slope)
185 {
186 ssi->ssip[(int)phase].setup_slope=slope;
187 ssi->ssip[(int)phase].period=ck!=NULL?ck->PERIOD:0;
188 ssi->ssip[(int)phase].ck=NULL;
189 }
190 if (ssi->worst_slack==TTV_NOTIME || ssi->worst_slack>outssi->worst_slack)
191 ssi->worst_slack=outssi->worst_slack;
192 }
193 }
194 if (ck==NULL) break;
195 }
196
197 if ((slope=stb_get_directive_setup_slope(stbfig, node, &phase, &period, 0))!=TTV_NOTIME)
198 {
199 newstartslope=1;
200 if (sourcechanged)
201 {
202 for (i=0; i<node->NBINDEX; i++) outssi->ssip[i].setup_slope=ssi->ssip[i].setup_slope_hz=TTV_NOTIME;
203 sourcechanged=0;
204 }
205 if (getptype(event->USER, SETUP_SLOPE_SOURCE)==NULL)
206 event->USER=addptype(event->USER, SETUP_SLOPE_SOURCE, NULL);
207 if (outssi->ssip[(int)phase].setup_slope==TTV_NOTIME || outssi->ssip[(int)phase].setup_slope>slope)
208 {
209 outssi->ssip[(int)phase].setup_slope=slope;
210 outssi->ssip[(int)phase].period=period;
211 outssi->ssip[(int)phase].ck=NULL;
212 }
213
214 slope-=delaymax;
215
216 if (slopesource==0 && (ssi->ssip[(int)phase].setup_slope==TTV_NOTIME || ssi->ssip[(int)phase].setup_slope>slope))
217 {
218 ssi->ssip[(int)phase].setup_slope=slope;
219 ssi->ssip[(int)phase].period=period;
220 ssi->ssip[(int)phase].ck=NULL;
221 }
222 }
223
224 if (!newstartslope && !slopesource)
225 {
226 for (i=0; i<node->NBINDEX; i++)
227 {
228 if (outssi->ssip[i].setup_slope!=TTV_NOTIME)
229 {
230 slope=outssi->ssip[i].setup_slope-delaymax;
231 if (ssi->ssip[i].setup_slope==TTV_NOTIME || ssi->ssip[i].setup_slope>slope)
232 {
233 ssi->ssip[i].setup_slope=slope;
234 ssi->ssip[i].period=outssi->ssip[i].period;
235 ssi->ssip[i].ck=NULL;
236 }
237 if (ssi->worst_slack==TTV_NOTIME || ssi->worst_slack>outssi->worst_slack)
238 ssi->worst_slack=outssi->worst_slack;
239 }
240 }
241 }
242 }
243 }
244
245 static void stb_getstab(stbfig_list *stbfig, stbnode *node, stbpair_list **STBTAB, stbpair_list **STBHZ, stbck *ck)
246 {
247 int i;
248
249 for (i=0; i<node->NBINDEX; i++) STBHZ[i]=NULL, STBTAB[i]=NULL;
250
251 stb_transferstbline (stbfig, node->EVENT, node , STBTAB, STBHZ, 0, 1, NULL, ck, 1, STB_TRANSFERT_NOFILTERING|STB_TRANSFERT_NOPHASECHANGE) ;
252
253 }
254
255
256 long stb_computelocalmargin(stbfig_list *stbfig, ttvevent_list *tve, FILE *f)
257 {
258 stbnode *node;
259 setup_slope_info *ssi;
260 int i, j;
261 long period, setup_margin=TTV_NOTIME, val;
262 stbpair_list *STBTAB[256], *STBHZ[256], *pair, *pairhz;
263 stbdomain_list *ptdomain;
264
265 if((node = stb_getstbnode (tve)) == NULL) return TTV_NOTIME;
266
267 // qq heursistique reportee ici pour coller
268 if ((tve->ROOT->TYPE & TTV_SIG_R)!=0)
269 {
270 if (V_INT_TAB[__STB__PRECHARGE_DATA_HEURISTIC].VALUE==2 && (tve->TYPE & TTV_NODE_UP)!=0)
271 return TTV_NOTIME;
272 }
273
274 if ((ssi=stb_get_setup_slope_info(tve))!=NULL)
275 {
276 for (i=0; i<node->NBINDEX; i++)
277 {
278 for (j=0; j<node->NBINDEX; j++)
279 {
280 ptdomain = stb_getstbdomain(stbfig->CKDOMAIN, j) ;
281
282 if (i>=ptdomain->CKMIN && i<=ptdomain->CKMAX)
283 {
284 stb_getstab(stbfig, node, STBTAB, STBHZ, ssi->ssip[j].ck);
285 for (pair=STBTAB[i]; pair!=NULL && pair->NEXT!=NULL; pair=pair->NEXT) ;
286 for (pairhz=STBHZ[i]; pairhz!=NULL && pairhz->NEXT!=NULL; pairhz=pairhz->NEXT) ;
287
288 if (stb_cmpphase(stbfig, i, j)>0/*i>j*/)
289 period=ssi->ssip[j].period;
290 else if (i==j)
291 {
292 if((stbfig->STABILITYMODE & STB_STABILITY_FF) != 0)
293 period=ssi->ssip[j].period;
294 else if((stbfig->STABILITYMODE & STB_STABILITY_LT) != 0)
295 period=0;
296 else
297 period=ssi->ssip[j].period;
298 }
299 else period=0;
300
301 if (pair!=NULL && ssi->ssip[j].setup_slope!=TTV_NOTIME)
302 {
303 val=ssi->ssip[j].setup_slope+period-pair->U;
304 if (setup_margin==TTV_NOTIME || val<setup_margin) setup_margin=val;
305 if (f!=NULL) fprintf(f,"\t\t\t (%d->%d %ld+%ld-%ld=%ld) worst:%ld\n", i, j, ssi->ssip[j].setup_slope, period, pair->U, val, ssi->worst_slack);
306 }
307 if (pairhz!=NULL && ssi->ssip[j].setup_slope_hz!=TTV_NOTIME)
308 {
309 val=ssi->ssip[j].setup_slope_hz+period-pairhz->U;
310 if (setup_margin==TTV_NOTIME || val<setup_margin) setup_margin=val;
311 if (f!=NULL) fprintf(f,"\t\t\t (hz:%d->%d %ld+%ld-%ld=%ld) worst:%ld\n", i, j, ssi->ssip[j].setup_slope_hz, period, pairhz->U, val, ssi->worst_slack);
312 }
313 if (setup_margin!=TTV_NOTIME && setup_margin<ssi->worst_slack)
314 {
315 setup_margin=ssi->worst_slack;
316 if (f!=NULL) fprintf(f,"\t\t *CAPPED %ld*\n", setup_margin);
317 }
318
319 stb_freestbtabpair(STBHZ, node->NBINDEX);
320 stb_freestbtabpair(STBTAB, node->NBINDEX);
321 }
322 }
323 }
324 }
325
326 return setup_margin;
327 }
328
329
330
331 void stb_compute_local_margins(stbfig_list *stbfig)
332 {
333 chain_list *cl;
334 FILE *f;
335 setup_slope_info *ssi;
336 ttvevent_list *tve, *maxtve=NULL;
337 stbnode *node;
338 int i;
339 long val, min=TTV_NOTIME, max=TTV_NOTIME, val1;
340
341 if (stbfig==NULL) {printf("stb_compute_local_margins: NULL stbfig\n");return;}
342 stbfig->NODE = reverse(stbfig->NODE);
343 for (cl=stbfig->NODE; cl!=NULL; cl=cl->NEXT) stb_delete_setup_slope_info((ttvevent_list *)cl->DATA);
344 for (cl=stbfig->NODE; cl!=NULL; cl=cl->NEXT) stb_propagate_setup_slope(stbfig, (ttvevent_list *)cl->DATA);
345
346 for (cl=stbfig->NODE; cl!=NULL; cl=cl->NEXT)
347 {
348 tve=(ttvevent_list *)cl->DATA;
349 tve->USER=testanddelptype(tve->USER, SETUP_SLOPE_SOURCE);
350 }
351
352 f=fopen("test.log","wt");
353 for (cl=stbfig->NODE; cl!=NULL; cl=cl->NEXT)
354 {
355 tve=(ttvevent_list *)cl->DATA;
356 node=stb_getstbnode(tve);
357 ssi=stb_get_setup_slope_info(tve);
358 if (ssi!=NULL)
359 {
360 if ((tve->ROOT->TYPE & TTV_SIG_L)!=0)
361 fprintf(f, "L");
362 else if ((tve->ROOT->TYPE & TTV_SIG_R)!=0)
363 fprintf(f, "P");
364 else
365 fprintf(f, " ");
366 fprintf(f, "%20s %20s (%c) ", tve->ROOT->NETNAME, tve->ROOT->NAME, (tve->TYPE & TTV_NODE_UP)?'R':'F');
367 if (ssi->worst_slack!=TTV_NOTIME) fprintf(f, " worst=%ld", ssi->worst_slack);
368
369 for (i=0; i<node->NBINDEX; i++)
370 {
371 if (ssi->ssip[i].setup_slope!=TTV_NOTIME)
372 fprintf(f," (%d: %ld %ld)", i, ssi->ssip[i].setup_slope, ssi->ssip[i].period);
373 }
374 fprintf(f, "\n");
375 val=stb_computelocalmargin(stbfig, tve, f);
376 if (node->SETUP!=STB_NO_TIME && val!=node->SETUP)
377 fprintf(f, " *** FAILED orig: %ld != %ld ***\n", node->SETUP,val);
378 if ((tve->TYPE & TTV_NODE_UP)!=0 && ttv_isgateoutput(stbfig->FIG, tve->ROOT, TTV_FILE_DTX))
379 {
380 val1=stb_computelocalmargin(stbfig, tve->ROOT->NODE, NULL);
381 if (val1!=TTV_NOTIME && val1<val) val=val1;
382 if (val!=TTV_NOTIME)
383 {
384 if (min==TTV_NOTIME || val<min) min=val;
385 if (max==TTV_NOTIME || val>max)
386 {
387 max=val;
388 if ((tve->ROOT->TYPE & TTV_SIG_L)==0)
389 {
390 if (ttv_testsigflag(tve->ROOT, TTV_SIG_FLAGS_ISSLAVE)==0
391 && ttv_testsigflag(tve->ROOT, TTV_SIG_FLAGS_ISMASTER)==0)
392 maxtve=tve;
393 }
394 }
395 }
396 }
397 }
398 }
399
400 fclose(f);
401
402 #define MAX 10
403
404 #define RANGE_MIN 1
405 #define RANGE_MAX 2
406 #define SIG_NUMBER 3
407 #define SIG_POURC 4
408 #define NB_MASTER 5
409 #define NB_SLAVE 6
410 #define NB_CTRL_POINT 7
411
412 f=fopen("histo.log","wt");
413
414 {
415 struct
416 {
417 int nbs, nbm, nbctrl;
418 int nb;
419 } nb[MAX];
420 int idx, j;
421 int tot=0;
422 Board *b;
423 char buf[1024];
424 float step;
425
426 fprintf(f, "* min=%.1f max=%.1f (%s)\n", min/TTV_UNIT, max/TTV_UNIT, maxtve?maxtve->ROOT->NAME:"?");
427
428 b=Board_CreateBoard();
429 Board_SetSize(b, RANGE_MIN, 7, DISPLAY_number_justify);
430 Board_SetSize(b, RANGE_MAX, 7, DISPLAY_number_justify);
431 Board_SetSize(b, SIG_NUMBER, 7, DISPLAY_number_justify);
432 Board_SetSize(b, SIG_POURC, 7, DISPLAY_number_justify);
433 Board_SetSize(b, NB_MASTER, 7, DISPLAY_number_justify);
434 Board_SetSize(b, NB_SLAVE, 7, DISPLAY_number_justify);
435 Board_SetSize(b, NB_CTRL_POINT, 7, DISPLAY_number_justify);
436 Board_NewLine(b);
437
438 Board_SetValue(b, RANGE_MIN, "éRange");
439 Board_SetValue(b, RANGE_MAX, "è");
440
441 Board_NewLine(b);
442
443 Board_SetValue(b, RANGE_MIN, "Min");
444 Board_SetValue(b, RANGE_MAX, "Max");
445 Board_SetValue(b, SIG_NUMBER, "# Gates");
446 Board_SetValue(b, SIG_POURC, "% Gates");
447 Board_SetValue(b, NB_MASTER, "# Masters");
448 Board_SetValue(b, NB_SLAVE, "# Slaves");
449 Board_SetValue(b, NB_CTRL_POINT, "# CTRLPoints");
450
451 Board_NewSeparation(b);
452
453 /* if (abs(min)>abs(max)) min=-abs(min), max=abs(min);
454 else min=-abs(max), max=abs(max);*/
455 step=(MAX)/(float)(max-min);
456 for (i=0; i<MAX; i++) nb[i].nb=0, nb[i].nbs=0, nb[i].nbm=0, nb[i].nbctrl=0;
457 for (cl=stbfig->NODE; cl!=NULL; cl=cl->NEXT)
458 {
459 tve=(ttvevent_list *)cl->DATA;
460 if ((tve->TYPE & TTV_NODE_UP)!=0 && ttv_isgateoutput(stbfig->FIG, tve->ROOT, TTV_FILE_DTX))
461 {
462 val=stb_computelocalmargin(stbfig, tve, NULL);
463 val1=stb_computelocalmargin(stbfig, tve->ROOT->NODE, NULL);
464 if (val1!=TTV_NOTIME && val1<val) val=val1;
465 if (val!=TTV_NOTIME)
466 {
467 idx=(int)(step*(float)(val-min));
468 // if (val<0) idx--;
469 if (idx>=MAX) idx=MAX-1;
470 if (idx<0) idx=0;
471 nb[idx].nb++;
472 tot++;
473 if (stb_getstbnode(tve)->SETUP!=STB_NO_TIME || stb_getstbnode(tve->ROOT->NODE)->SETUP!=STB_NO_TIME) nb[idx].nbctrl++;
474
475 if (ttv_testsigflag(tve->ROOT, TTV_SIG_FLAGS_ISSLAVE)!=0) nb[idx].nbs++;
476 if (ttv_testsigflag(tve->ROOT, TTV_SIG_FLAGS_ISMASTER)!=0) nb[idx].nbm++;
477 }
478 }
479 }
480 for (i=0; i<MAX && nb[i].nb==0; i++) ;
481 for (j=MAX-1; j>=0 && nb[i].nb==0; j--) ;
482 while (i<=j)
483 {
484 Board_NewLine(b);
485
486 Board_SetValue(b, RANGE_MIN, FormaT(_LONG_TO_DOUBLE(min+i/step)*DISPLAY_time_unit, buf, DISPLAY_time_format));
487 Board_SetValue(b, RANGE_MAX, FormaT(_LONG_TO_DOUBLE(min+(i+1)/step)*DISPLAY_time_unit, buf, DISPLAY_time_format));
488 sprintf(buf, "%d", nb[i].nb);
489 Board_SetValue(b, SIG_NUMBER, buf);
490 sprintf(buf, "%.1f%%", nb[i].nb*100.0/tot);
491 Board_SetValue(b, SIG_POURC, buf);
492 sprintf(buf, "%d", nb[i].nbm);
493 Board_SetValue(b, NB_MASTER, buf);
494 sprintf(buf, "%d", nb[i].nbs);
495 Board_SetValue(b, NB_SLAVE, buf);
496 sprintf(buf, "%d", nb[i].nbctrl);
497 Board_SetValue(b, NB_CTRL_POINT, buf);
498
499 // fprintf(f, "%.1f - %.1f : %d (%.1f%%) / s=%d m=%d\n", (min+i*(max-min)/MAX)/TTV_UNIT, (min+(i+1)*(max-min)/MAX)/TTV_UNIT, nb[i].nb, nb[i].nb*100.0/tot, nb[i].nbs, nb[i].nbm);
500 i++;
501 }
502 Board_Display(f, b, "");
503 Board_FreeBoard(b);
504 }
505 fclose(f);
506
507
508 stbfig->NODE = reverse(stbfig->NODE);
509 }
510
511
512 #define TEMPMARK_SOURCE 0xfab70411
513
514 static void stb_find_stb_path (stbfig_list *stbfig, ttvevent_list *event, ttvevent_list *prev, long time )
515 {
516 stbnode *node;
517 ttvevent_list *inevent;
518 ttvline_list *line;
519 stbpair_list *sp;
520 long delaymax;
521 long delaymin;
522 char phase=STB_NO_INDEX;
523 char level, f;
524 int i;
525
526 if((node = stb_getstbnode (event)) == NULL)
527 return ;
528
529 if ((stbfig->STABILITYMODE & STB_STABILITY_LAST) == STB_STABILITY_LAST)
530 level = stbfig->FIG->INFO->LEVEL;
531 else
532 level = event->ROOT->ROOT->INFO->LEVEL;
533
534 if (stbfig->GRAPH == STB_RED_GRAPH)
535 {
536 ttv_expfigsig (stbfig->FIG, event->ROOT, level, stbfig->FIG->INFO->LEVEL,
537 TTV_STS_CL_PJT, TTV_FILE_TTX);
538 line = event->INPATH;
539 }
540 else
541 {
542 ttv_expfigsig (stbfig->FIG, event->ROOT, level, stbfig->FIG->INFO->LEVEL,
543 TTV_STS_CLS_FED, TTV_FILE_DTX);
544 line = event->INLINE;
545 }
546
547 for (i=0; i<node->NBINDEX; i++)
548 {
549 sp=stb_globalstbpair (node->STBTAB[i]);
550 if (sp!=NULL)
551 {
552 if (time==sp->U) { phase=i; break; }
553 }
554 stb_freestbpair(sp);
555 }
556
557 if (phase==STB_NO_INDEX) return;
558
559 if (event->ROOT->TYPE & TTV_SIG_L) f='L';
560 else if (event->ROOT->TYPE & TTV_SIG_R) f='P';
561 else f='-';
562 fprintf(stdout,"found '%s %s(%c)' (%c) at %ld phase %d\n", event->ROOT->NAME, event->ROOT->NETNAME, event->TYPE & TTV_NODE_UP?'R':'F', f, time, phase);
563
564 if (prev!=NULL && (event->ROOT->TYPE & (TTV_SIG_L|TTV_SIG_R))!=0) return;
565 if (getptype(event->USER, TEMPMARK_SOURCE)!=NULL) return;
566 event->USER=addptype(event->USER, TEMPMARK_SOURCE, NULL);
567 for (; line; line = line->NEXT)
568 {
569 if (((line->TYPE & TTV_LINE_CONT) == TTV_LINE_CONT) ||
570 (((line->TYPE & (TTV_LINE_D | TTV_LINE_T)) != 0) &&
571 (line->FIG != stbfig->FIG)) ||
572 (((line->TYPE & (TTV_LINE_P | TTV_LINE_F)) != 0) &&
573 (line->FIG != stbfig->FIG) &&
574 ((stbfig->STABILITYMODE & STB_STABILITY_LAST) == STB_STABILITY_LAST)))
575 continue;
576
577 if ((line->TYPE & TTV_LINE_HZ)!=0) continue; //hz=1; else hz=0;
578
579 inevent = line->NODE;
580 delaymin = ttv_getdelaymin (line);
581 delaymax = ttv_getdelaymax (line);
582 if (delaymin == TTV_NOTIME) delaymin = delaymax;
583 if (delaymax == TTV_NOTIME) delaymax = delaymin;
584
585
586 stb_find_stb_path (stbfig, inevent, event, time-delaymax );
587 }
588 event->USER=delptype(event->USER, TEMPMARK_SOURCE);
589 }
590
591 void stb_trackstbpath (stbfig_list *stbfig, char *nodename, char dir, double timeo)
592 {
593 ttvsig_list *tvs;
594 int num;
595 long time;
596 chain_list *cl, *ch;
597
598
599 cl=addchain(NULL, namealloc(nodename));
600
601 ch = ttv_getsigbytype_and_netname(stbfig->FIG,NULL,TTV_SIG_TYPEALL,cl) ;
602 freechain(cl);
603
604 time=mbk_long_round(timeo*1e12*TTV_UNIT);
605 if (tolower(dir)=='r' || tolower(dir)=='u') num=1;
606 else if (tolower(dir)=='f' || tolower(dir)=='d') num=0;
607 else {printf("direction %c invalide\n",dir);return;}
608
609 while (ch!=NULL)
610 {
611 tvs=(ttvsig_list *)ch->DATA;
612 stb_find_stb_path (stbfig, &tvs->NODE[num], NULL, time );
613 fprintf(stdout,"------------\n");
614 ch=delchain(ch, ch);
615 }
616 }