1 /****************************************************************************/
3 /* Chaine de CAO & VLSI AVERTEC */
5 /* Produit : STB Version 1.00 */
6 /* Fichier : stb_parse.c */
8 /* (c) copyright 2000 AVERTEC */
9 /* Tous droits reserves */
11 /* Auteur(s) : Karim DIOURY */
13 /* 03082004 : Antony PINTO */
14 /* several functions moved from stb.yac */
16 /****************************************************************************/
22 #include "stb_error.h"
23 #include "stb_parse.h"
24 #include "stb_fromx.h"
27 #define STB_P_MEM 5 // node memory
28 #define STB_P_NOD 6 // node
29 #define STB_P_ONOD 7 // output node
30 #define STB_P_INOD 8 // input node
31 #define STB_P_LOC 9 // locon
32 #define STB_P_ILOCD 10 // input default locon
33 #define STB_P_OLOCD 11 // output define locon
35 #define STB_P_DUPPAIR 1
36 #define STB_P_ADDPAIR 2
38 #define BEGIN //printf("%s\n",__func__);
40 extern int stbparse();
41 extern void stbrestart();
42 extern void stb_parse_init_stab(stb_parse
*stab
);
46 static stb_parse
*STAB
;
48 /****************************************************************************/
52 /****************************************************************************/
56 if (STAB
->PTINSCHAIN
!= NULL
) {
57 freechain(STAB
->PTINSCHAIN
);
58 STAB
->PTINSCHAIN
= NULL
;
60 if (STAB
->PTSTABLELIST
!= NULL
) {
61 freechain(STAB
->PTSTABLELIST
);
62 STAB
->PTSTABLELIST
= NULL
;
64 if (STAB
->PTUNSTABLELIST
!= NULL
) {
65 freechain(STAB
->PTUNSTABLELIST
);
66 STAB
->PTUNSTABLELIST
= NULL
;
68 if (STAB
->PARSEDFIG
!= NULL
) {
69 stb_delstbfig(STAB
->PARSEDFIG
);
70 STAB
->PARSEDFIG
= NULL
;
75 stb_parse_init_stab(stb_parse
*stab
)
78 stb_parse_init(STAB
,stb_yyclean
);
82 stb_convert_inf_to_stb_1(stbfig_list
*ptstbfig
)
85 static stb_parse stab
= {
89 NULL
, // ptunstablelist
100 fxt
.STBFIG
= ptstbfig
;
104 stb_parse_init_stab(&stab
);
105 stb_fromX_STEP1_traditional(&fxt
, &stab
);
112 stb_convert_inf_to_stb_2(stbfig_list
*ptstbfig
, stb_parse
*stab
)
115 fxt
.STBFIG
= ptstbfig
;
119 stb_fromX_STEP2_stability(&fxt
, stab
);
120 stb_fromX_STEP3_finish(&fxt
, stab
);
127 stb_loadstbfig(stbfig_list
*ptstbfig
)
134 static stb_parse stab
= {
137 NULL
, // ptstablelist
138 NULL
, // ptunstablelist
151 if (STB_FILE_FORMAT
== STB_SDC_FORMAT
) {
152 if (STB_FOREIGN_CONSTRAINT_FILE
== NULL
) {
153 strcpy (str
, ptstbfig
->FIG
->INFO
->FIGNAME
);
154 strcat (str
, ".sdc");
155 STB_FOREIGN_CONSTRAINT_FILE
= namealloc (str
);
160 if (pid
== (pid_t
) (-1))
161 stb_error (ERR_CANNOT_RUN
, "sdc2stb", 0, STB_FATAL
);
164 if (execlp ("sdc2stb", "sdc2stb", STB_FOREIGN_CONSTRAINT_FILE
, "-tu", STB_FOREIGN_TIME_UNIT
, "-out", ptstbfig
->FIG
->INFO
->FIGNAME
, NULL
)==-1)
166 perror("system says ");
171 j
= mbkwaitpid (pid
, 1, &status
);
172 if ((j
== 0) || (WIFEXITED (status
) == 0))
173 fprintf (stderr
, "cannot execute sdc2stb\n");
174 else if (WEXITSTATUS (status
) != 0)
175 fprintf (stderr
, "sdc2stb exit with a non zero value\n");
179 inf_Dirty(ptstbfig
->FIG
->INFO
->FIGNAME
);
180 getinffig(ptstbfig
->FIG
->INFO
->FIGNAME
);
187 if ((stbin = mbkfopen(ptstbfig->FIG->INFO->FIGNAME, "stb", READ_TEXT)) == NULL) {
188 stb_error(ERR_CANNOT_OPEN, NULL, 0, STB_FATAL);
198 fxt
.STBFIG
= ptstbfig
;
202 stb_parse_init_stab(&stab
);
203 stb_fromX(&fxt
,&stab
);
208 stb_error(ERR_CANNOT_CLOSE, NULL, 0, STB_FATAL);
215 /*}}}************************************************************************/
216 /****************************************************************************/
217 /*{{{ Parse struct */
218 /****************************************************************************/
219 /*{{{ stb_parse_init(); */
222 /****************************************************************************/
224 stb_parse_init(stb_parse
*stab
, void (*cleanfunc
)(void))
226 stab
->PARSEDFIG
= NULL
;
227 stab
->PTINSCHAIN
= NULL
;
228 stab
->PTSTABLELIST
= NULL
;
229 stab
->PTUNSTABLELIST
= NULL
;
230 stab
->CKDOMAINS
= NULL
;
232 stab
->DEFAULTPHASE
= STB_NO_INDEX
;
233 stab
->DOMAININDEX
= 0;
238 stab
->CLEANFUNC
= cleanfunc
;
241 /*}}}************************************************************************/
242 /*}}}************************************************************************/
244 /****************************************************************************/
248 /****************************************************************************/
250 addstbck(stbnode
*ptstbnode
, stb_parse_pulse
*pulse
, stbfig_list
*parsedfig
)
252 stb_addstbck(ptstbnode
,
253 pulse
->supmin
, pulse
->supmax
,
254 pulse
->sdnmin
, pulse
->sdnmax
,
256 parsedfig
->SETUP
, parsedfig
->HOLD
,
257 STB_NO_INDEX
, 0, STB_NO_VERIF
, STB_TYPE_CLOCK
, ptstbnode
->EVENT
);
261 /*}}}************************************************************************/
262 /*{{{ stb_parse_cklocon() */
265 /****************************************************************************/
267 static chain_list
*clocksigpriority(chain_list
*cl
)
269 chain_list
*ch
=NULL
, *runcl
;
271 long go
[4]={TTV_SIG_B
, TTV_SIG_L
, TTV_SIG_C
, 0};
276 for (runcl
=cl
; runcl
!=NULL
; runcl
=runcl
->NEXT
)
278 tvs
=(ttvsig_list
*)runcl
->DATA
;
279 if (tvs
!=NULL
&& (go
[i
]==0 || (tvs
->TYPE
& go
[i
])!=0))
281 ch
=addchain(ch
, tvs
);
290 static long stb_findlatency(inffig_list
*ifl
, stb_parse
*stab
, ttvsig_list
*ptttvsig
, char *type
, int *found
)
292 chain_list
*list
, *chainx
, *cl
;
296 list
= inf_GetEntriesByType(ifl
,type
,INF_ANY_VALUES
);
297 for (chainx
= list
; chainx
&& res
==0; chainx
= delchain(chainx
,chainx
))
299 cl
=addchain(NULL
, (char *)chainx
->DATA
);
300 res
=ttv_testnetnamemask(stab
->PARSEDFIG
->FIG
, ptttvsig
, cl
);
303 inf_GetDouble(ifl
, (char *)chainx
->DATA
, type
, &val
);
308 return val
*1e12
*TTV_UNIT
;
312 stb_parse_cklocon(stb_parse
*stab
, char *ident
, stb_parse_pulse
*pulse
, inffig_list
*ifl
)
314 ttvsig_list
*ptttvsig
;
316 chain_list
*headlist
, *cl
;
320 stb_propagated_clock_to_clock
*spctc
;
322 name
= namealloc(ident
);
323 if (pulse
->supmin
==STB_NO_TIME
|| pulse
->sdnmin
==STB_NO_TIME
)
324 avt_errmsg(STB_ERRMSG
, "044", AVT_FATAL
, name
);
326 headlist
= ttv_getsigbytype(stab
->PARSEDFIG
->FIG
, NULL
,
327 TTV_SIG_C
|TTV_SIG_B
|TTV_SIG_L
/*|TTV_SIG_Q*/, NULL
);
329 headlist
=clocksigpriority(headlist
);
331 cl
=addchain(NULL
, name
);
332 for (ptchain
= headlist
; ptchain
; ptchain
= ptchain
->NEXT
)
334 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
335 if (ttv_testnetnamemask(stab
->PARSEDFIG
->FIG
, ptttvsig
, cl
))
337 ttvevent_list
*ptevent
;
342 ptttvsig
->USER
= addptype (ptttvsig
->USER
, STB_INVERTED_CLOCK
, 0);
343 swap
=pulse
->supmin
, pulse
->supmin
=pulse
->sdnmin
, pulse
->sdnmin
=swap
;
344 swap
=pulse
->supmax
, pulse
->supmax
=pulse
->sdnmax
, pulse
->sdnmax
=swap
;
347 ptttvsig
->USER
= addptype (ptttvsig
->USER
, STB_IDEAL_CLOCK
, 0);
349 period
= pulse
->period
;
350 stab
->PARSEDFIG
->CLOCK
= addchain(stab
->PARSEDFIG
->CLOCK
, ptttvsig
);
352 ptevent
= ptttvsig
->NODE
;
353 ptstbnode
= stb_getstbnode(ptevent
);
354 addstbck(ptstbnode
,pulse
,stab
->PARSEDFIG
);
356 ptevent
= ptttvsig
->NODE
+1;
357 ptstbnode
= stb_getstbnode(ptevent
);
358 addstbck(ptstbnode
,pulse
,stab
->PARSEDFIG
);
360 spctc
=(stb_propagated_clock_to_clock
*)mbkalloc(sizeof(stb_propagated_clock_to_clock
));
361 spctc
->edges
=pulse
->master_edges
;
362 spctc
->master
=pulse
->master_clock
;
363 memcpy(&spctc
->original_waveform
, ptstbnode
->CK
, sizeof(stbck
));
365 spctc
->latencies
.SUPMIN
=stb_findlatency(ifl
,stab
, ptttvsig
, INF_LATENCY_RISE_MIN
,&spctc
->haslatency
);
366 spctc
->latencies
.SUPMAX
=stb_findlatency(ifl
,stab
, ptttvsig
, INF_LATENCY_RISE_MAX
,&spctc
->haslatency
);
367 spctc
->latencies
.SDNMIN
=stb_findlatency(ifl
,stab
, ptttvsig
, INF_LATENCY_FALL_MIN
,&spctc
->haslatency
);
368 spctc
->latencies
.SDNMAX
=stb_findlatency(ifl
,stab
, ptttvsig
, INF_LATENCY_FALL_MAX
,&spctc
->haslatency
);
371 swap
=spctc
->latencies
.SUPMIN
; spctc
->latencies
.SUPMIN
=spctc
->latencies
.SDNMIN
; spctc
->latencies
.SDNMIN
=swap
;
372 swap
=spctc
->latencies
.SUPMAX
; spctc
->latencies
.SUPMAX
=spctc
->latencies
.SDNMAX
; spctc
->latencies
.SDNMAX
=swap
;
374 ptstbnode
->CK
->SUPMIN
+=spctc
->latencies
.SUPMIN
; ptstbnode
->CK
->SUPMAX
+=spctc
->latencies
.SUPMAX
;
375 ptstbnode
->CK
->SDNMIN
+=spctc
->latencies
.SDNMIN
; ptstbnode
->CK
->SDNMAX
+=spctc
->latencies
.SDNMAX
;
376 ptttvsig
->USER
= addptype (ptttvsig
->USER
, STB_IS_CLOCK
, spctc
);
380 if (!mbk_isregex_name(name
))
391 ttvevent_list
*ptevent
;
393 ptttvsig
= (ttvsig_list
*)mbkalloc(sizeof(ttvsig_list
));
394 ttv_init_refsig(stab
->PARSEDFIG
->FIG
, ptttvsig
, ident
, ident
, 0, TTV_SIG_C
);
395 stb_addstbnode (ptttvsig
->NODE
);
396 stb_addstbnode (ptttvsig
->NODE
+1);
398 ptttvsig
->USER
= addptype (ptttvsig
->USER
, STB_VIRTUAL_CLOCK
, 0);
402 ptttvsig
->USER
= addptype (ptttvsig
->USER
, STB_INVERTED_CLOCK
, 0);
403 swap
=pulse
->supmin
, pulse
->supmin
=pulse
->sdnmin
, pulse
->sdnmin
=swap
;
404 swap
=pulse
->supmax
, pulse
->supmax
=pulse
->sdnmax
, pulse
->sdnmax
=swap
;
407 ptttvsig
->USER
= addptype (ptttvsig
->USER
, STB_IDEAL_CLOCK
, 0);
409 period
= pulse
->period
;
410 stab
->PARSEDFIG
->CLOCK
= addchain(stab
->PARSEDFIG
->CLOCK
, ptttvsig
);
412 ptevent
= ptttvsig
->NODE
;
413 ptstbnode
= stb_getstbnode(ptevent
);
414 addstbck(ptstbnode
,pulse
,stab
->PARSEDFIG
);
416 ptevent
= ptttvsig
->NODE
+1;
417 ptstbnode
= stb_getstbnode(ptevent
);
418 addstbck(ptstbnode
,pulse
,stab
->PARSEDFIG
);
420 spctc
=(stb_propagated_clock_to_clock
*)mbkalloc(sizeof(stb_propagated_clock_to_clock
));
421 spctc
->edges
=pulse
->master_edges
;
422 spctc
->master
=pulse
->master_clock
;
423 memcpy(&spctc
->original_waveform
, ptstbnode
->CK
, sizeof(stbck
));
425 spctc
->latencies
.SUPMIN
=stb_findlatency(ifl
,stab
, ptttvsig
, INF_LATENCY_RISE_MIN
,&spctc
->haslatency
);
426 spctc
->latencies
.SUPMAX
=stb_findlatency(ifl
,stab
, ptttvsig
, INF_LATENCY_RISE_MAX
,&spctc
->haslatency
);
427 spctc
->latencies
.SDNMIN
=stb_findlatency(ifl
,stab
, ptttvsig
, INF_LATENCY_FALL_MIN
,&spctc
->haslatency
);
428 spctc
->latencies
.SDNMAX
=stb_findlatency(ifl
,stab
, ptttvsig
, INF_LATENCY_FALL_MAX
,&spctc
->haslatency
);
431 swap
=spctc
->latencies
.SUPMIN
; spctc
->latencies
.SUPMIN
=spctc
->latencies
.SDNMIN
; spctc
->latencies
.SDNMIN
=swap
;
432 swap
=spctc
->latencies
.SUPMAX
; spctc
->latencies
.SUPMAX
=spctc
->latencies
.SDNMAX
; spctc
->latencies
.SDNMAX
=swap
;
434 ptstbnode
->CK
->SUPMIN
+=spctc
->latencies
.SUPMIN
; ptstbnode
->CK
->SUPMAX
+=spctc
->latencies
.SUPMAX
;
435 ptstbnode
->CK
->SDNMIN
+=spctc
->latencies
.SDNMIN
; ptstbnode
->CK
->SDNMAX
+=spctc
->latencies
.SDNMAX
;
436 ptttvsig
->USER
= addptype (ptttvsig
->USER
, STB_IS_CLOCK
, spctc
);
444 stb_error(ERR_NO_CLOCK_CONNECTOR
, name
, yylineno
, STB_FATAL
);
452 /*}}}************************************************************************/
453 /*{{{ stb_parse_ckdeclar() */
456 /****************************************************************************/
457 static inline char edge(char org
)
461 case INF_STB_RISING
: return STB_SLOPE_UP
;
462 case INF_STB_FALLING
: return STB_SLOPE_DN
;
463 case INF_STB_SLOPEALL
: return STB_SLOPE_ALL
;
464 default : printf("0) Ca va pas non!!\n"); return 0;
469 treatpin_mark(stb_fromX_t
*fxt
, char *name
, char *type
)
476 if (inf_GetPointer(inf
,name
,type
,(void **)&ipss
))
480 if (ipss
->CKNAME
!=NULL
)
482 if ((tve
=stb_getclockevent(fxt
->STBFIG
, ipss
->CKNAME
, edge(ipss
->CKEDGE
)))!=NULL
)
484 long flag
=STB_SLOPE_DN
;
485 if ((tve
->TYPE
& TTV_NODE_UP
)==TTV_NODE_UP
) flag
=STB_SLOPE_UP
;
486 stb_getstbnode (tve
->ROOT
->NODE
)->CK
->ACTIVE
|= flag
;
487 stb_getstbnode (tve
->ROOT
->NODE
+ 1)->CK
->ACTIVE
|= flag
;
496 static int stb_ismultiple(long val0
, long val1
)
498 if (val0
<val1
) return (val1
% val0
)==0;
499 return (val0
% val1
)==0;
503 stb_parse_ckdeclar(void *fxt0
, stb_parse
*stab
)
505 ttvsig_list
*ptttvsig
;
506 chain_list
*ptchain
, *ptchain1
, *list
;
507 chain_list
*foundchain
= NULL
;
511 stb_fromX_t
*fxt
=(stb_fromX_t
*)fxt0
;
512 stab
->DOMAININDEX
++;
513 for (ptchain
= stab
->PARSEDFIG
->CLOCK
; ptchain
; ptchain
= ptchain
->NEXT
)
515 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
516 if (getptype(ptttvsig
->USER
, STB_DOMAIN
) == NULL
)
518 foundchain
= addchain(foundchain
, ptttvsig
);
519 ptttvsig
->USER
= addptype(ptttvsig
->USER
, STB_DOMAIN
,
520 (void *)((long)stab
->DOMAININDEX
));
522 ptstbck
= stb_getstbnode(ptttvsig
->NODE
)->CK
;
523 if (ptstbck
->PERIOD
== STB_NO_TIME
)
525 if (stab
->PARSEDFIG
->CLOCKPERIOD
== STB_NO_TIME
)
528 stb_error(ERR_UNDEFINED_PERIOD
,
529 ttv_getsigname(stab
->PARSEDFIG
->FIG
, namebuf
, ptttvsig
),
532 ptstbck
->PERIOD
= stab
->PARSEDFIG
->CLOCKPERIOD
;
533 ptstbck
= stb_getstbnode(ptttvsig
->NODE
+1)->CK
;
534 ptstbck
->PERIOD
= stab
->PARSEDFIG
->CLOCKPERIOD
;
537 if (foundchain
!= NULL
)
539 stab
->CKDOMAINS
= addchain(stab
->CKDOMAINS
, foundchain
);
540 stab
->PARSEDFIG
->CKDOMAIN
= stb_addstbdomain(stab
->PARSEDFIG
->CKDOMAIN
,
541 STB_NO_INDEX
, STB_NO_INDEX
);
543 stab
->PARSEDFIG
->USER
= addptype(stab
->PARSEDFIG
->USER
, STB_DOMAIN
,
546 /* verify that domains have equivalent periods */
547 for (ptchain
= stab
->CKDOMAINS
; ptchain
; ptchain
= ptchain
->NEXT
)
549 period
= STB_NO_TIME
;
550 for (ptchain1
= (chain_list
*)ptchain
->DATA
;
552 ptchain1
= ptchain1
->NEXT
)
554 ptttvsig
= (ttvsig_list
*)ptchain1
->DATA
;
555 ptstbck
= stb_getstbnode(ptttvsig
->NODE
)->CK
;
556 if (period
== STB_NO_TIME
)
557 period
= ptstbck
->PERIOD
;
558 else if (!stb_ismultiple(ptstbck
->PERIOD
,period
))
560 stb_error( ERR_INCOHERENT_PERIOD
,
562 ttv_getsigname(stab
->PARSEDFIG
->FIG
, namebuf
, ptttvsig
) :
571 // marquage pour les phases des inputs
572 list
= inf_GetEntriesByType(fxt
->INFFIG
,INF_SPECIN
,INF_ANY_VALUES
);
573 for (ptchain
= list
; ptchain
; ptchain
= delchain(ptchain
,ptchain
))
574 treatpin_mark(fxt
,ptchain
->DATA
,INF_SPECIN
);
576 // marquage pour les phases des outputs
577 list
= inf_GetEntriesByType(fxt
->INFFIG
,INF_SPECOUT
,INF_ANY_VALUES
);
578 for (ptchain
= list
; ptchain
; ptchain
= delchain(ptchain
,ptchain
))
579 treatpin_mark(fxt
,ptchain
->DATA
,INF_SPECOUT
);
581 /* initialise the clocks */
582 stb_initclock(stab
->PARSEDFIG
,0);
583 stb_checkclock(stab
->PARSEDFIG
);
586 /*}}}************************************************************************/
587 /*{{{ stb_parse_domain_groups() */
590 /****************************************************************************/
592 stb_parse_domain_groups(stb_parse
*stab
, chain_list
*group
)
594 ttvsig_list
*ptttvsig
;
598 stab
->DOMAININDEX
++;
599 stab
->CKDOMAINS
= addchain(stab
->CKDOMAINS
, group
);
600 for (ptchain
= group
; ptchain
; ptchain
= ptchain
->NEXT
)
602 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
603 if (getptype(ptttvsig
->USER
, STB_DOMAIN
) != NULL
)
605 ttv_getsigname(stab
->PARSEDFIG
->FIG
, name
, ptttvsig
);
607 stb_error(ERR_MULTIPLE_DOMAIN
, name
, yylineno
, STB_FATAL
);
609 ptttvsig
->USER
= addptype(ptttvsig
->USER
, STB_DOMAIN
,
610 (void *)((long)stab
->DOMAININDEX
));
612 stab
->PARSEDFIG
->CKDOMAIN
= stb_addstbdomain(stab
->PARSEDFIG
->CKDOMAIN
,
613 STB_NO_INDEX
, STB_NO_INDEX
);
616 /*}}}************************************************************************/
617 /*{{{ stb_parse_ckprio_pair() */
620 /****************************************************************************/
622 stb_parse_ckprio_pair(stb_parse
*stab
, char *id1
, char *id3
)
624 char cknamebuf
[1024];
625 char cknetnamebuf
[1024];
627 stbpriority
*res
= NULL
;
628 ttvsig_list
*ptttvsig
;
630 for (ptchain
= stab
->PARSEDFIG
->CLOCK
; ptchain
; ptchain
= ptchain
->NEXT
)
632 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
633 ttv_getsigname(stab
->PARSEDFIG
->FIG
, cknamebuf
, ptttvsig
);
634 ttv_getnetname(stab
->PARSEDFIG
->FIG
, cknetnamebuf
, ptttvsig
);
635 if (!mbk_casestrcmp(cknamebuf
, id3
) || !mbk_casestrcmp(cknetnamebuf
, id3
))
637 res
= (stbpriority
*)mbkalloc (sizeof (struct stbpriority
)) ;
638 res
->CLOCK
= ptttvsig
;
639 res
->MASK
= strdup(id1
) ;
644 stb_error(ERR_NO_CLOCK_CONNECTOR
, id3
, yylineno
, STB_FATAL
);
649 /*}}}************************************************************************/
650 /*{{{ stb_parse_ckname_list() */
653 /****************************************************************************/
655 stb_parse_ckname_list(stb_parse
*stab
, chain_list
*cklist
, char *ident
)
661 ck
= namealloc(ident
);
662 cl
= stb_getsigfromlist(stab
->PARSEDFIG
->FIG
,
663 stab
->PARSEDFIG
->CLOCK
,
669 stb_error(ERR_NO_CLOCK_CONNECTOR
, ck
, yylineno
, STB_FATAL
);
671 //res = addchain(cklist,sig);
674 if (getchain(cklist
, cl
->DATA
)==NULL
)
675 cklist
=addchain(cklist
, cl
->DATA
);
676 // res = append(cklist,cl);
683 /*}}}************************************************************************/
684 /*{{{ stb_parse_group() */
687 /****************************************************************************/
689 stb_parse_group(chain_list
*cklist
, long period
)
691 ttvsig_list
*ptttvsig
;
695 if (period
!= STB_NO_TIME
)
697 for (ptchain
= cklist
; ptchain
; ptchain
= ptchain
->NEXT
)
699 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
701 ptstbck
= stb_getstbnode(ptttvsig
->NODE
)->CK
;
702 if (ptstbck
->PERIOD
== STB_NO_TIME
)
703 ptstbck
->PERIOD
= period
;
705 ptstbck
= stb_getstbnode(ptttvsig
->NODE
+1)->CK
;
706 if (ptstbck
->PERIOD
== STB_NO_TIME
)
707 ptstbck
->PERIOD
= period
;
714 /*}}}************************************************************************/
715 /*{{{ stb_parse_eqvt_groups() */
718 /****************************************************************************/
720 stb_parse_eqvt_groups(stb_parse
*stab
, chain_list
*group
)
722 ttvsig_list
*ptttvsig
;
725 char curdomain
= STB_NO_INDEX
;
729 stab
->CKEQVT
= addchain(stab
->CKEQVT
, group
);
731 for (ptchain
= group
; ptchain
; ptchain
= ptchain
->NEXT
)
733 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
734 if (getptype(ptttvsig
->USER
, STB_EQUIVALENT
) != NULL
)
736 ttv_getsigname(stab
->PARSEDFIG
->FIG
, name
, ptttvsig
);
738 stb_error(ERR_MULTIPLE_EQUIVALENCE
, name
, yylineno
, STB_FATAL
);
741 if ((ptuser
= getptype(ptttvsig
->USER
, STB_DOMAIN
)) == NULL
)
744 sigdomain
= (char)((long)ptuser
->DATA
);
746 if (curdomain
== STB_NO_INDEX
)
747 curdomain
= sigdomain
;
748 else if (sigdomain
!= curdomain
)
750 ttv_getsigname(stab
->PARSEDFIG
->FIG
, name
, ptttvsig
);
752 stb_error(ERR_DOMAIN_NOT_EQUIVALENT
, name
, yylineno
, STB_FATAL
);
755 ptttvsig
->USER
= addptype(ptttvsig
->USER
, STB_EQUIVALENT
,
756 (void *)((long)stab
->EQVTINDEX
));
760 chain_list
*stb_auto_create_equivalent_groups(stb_parse
*stab
)
762 stb_propagated_clock_to_clock
*spctc
;
763 chain_list
*cl
, *ch
, *clocks
;
766 ttvsig_list
*tvs
, *tvso
;
767 char clockname
[1024];
768 char *thisgroupmaster
, ok
;
769 chain_list
*grp
, *res
=NULL
;
771 void *refdomain
, *curdomain
;
773 clocks
=dupchainlst(stab
->PARSEDFIG
->CLOCK
);
775 for (cl
= clocks
; cl
; cl
= cl
->NEXT
)
777 tvso
=(ttvsig_list
*)cl
->DATA
;
780 /* if ((pt=getptype(tvso->USER, STB_IS_CLOCK))!=NULL)
782 spctc=(stb_propagated_clock_to_clock *)pt->DATA;
783 ref=&spctc->original_waveform;
786 ref
=stb_getstbnode(&tvso
->NODE
[0])->CK
;
787 if ((pt
=getptype(tvso
->USER
, STB_DOMAIN
))!=NULL
) refdomain
=pt
->DATA
;
790 grp
=addchain(NULL
, tvso
);
792 for (ch
= cl
->NEXT
; ch
; ch
= ch
->NEXT
)
794 tvs
=(ttvsig_list
*)ch
->DATA
;
797 /* if ((pt=getptype(tvs->USER, STB_IS_CLOCK))!=NULL)
799 spctc=(stb_propagated_clock_to_clock *)pt->DATA;
800 cur=&spctc->original_waveform;
803 cur
=stb_getstbnode(&tvs
->NODE
[0])->CK
;
805 if ((pt
=getptype(tvso
->USER
, STB_DOMAIN
))!=NULL
) curdomain
=pt
->DATA
;
807 if (curdomain
==refdomain
&& cur
->PERIOD
==ref
->PERIOD
808 && ((cur
->SUPMAX
==ref
->SUPMAX
&& cur
->SUPMIN
==ref
->SUPMIN
809 && cur
->SDNMAX
==ref
->SDNMAX
&& cur
->SDNMIN
==ref
->SDNMIN
)
810 || (cur
->SUPMAX
==ref
->SDNMAX
&& cur
->SUPMIN
==ref
->SDNMIN
811 && cur
->SDNMAX
==ref
->SUPMAX
&& cur
->SDNMIN
==ref
->SUPMIN
)))
813 grp
=addchain(grp
, tvs
);
820 avt_log(LOGSTABILITY
,1, "New equivalent clock group:");
821 for (ch
=grp
; ch
!=NULL
; ch
=ch
->NEXT
)
822 avt_log(LOGSTABILITY
,1, " %s", ttv_getsigname(stab
->PARSEDFIG
->FIG
,clockname
,(ttvsig_list
*)ch
->DATA
));
823 avt_log(LOGSTABILITY
,1, "\n");
825 res
=addchain(res
, grp
);
835 chain_list
*stb_merge_equiv_if_needed(chain_list
*equiv
, chain_list
*equiv_auto
)
837 chain_list
*cl
, *ch
, *ecl
, *ech
, *toapp
;
838 while (equiv_auto
!=NULL
)
841 for (ch
=(chain_list
*)equiv_auto
->DATA
; ch
!=NULL
; ch
=ch
->NEXT
)
843 for (ecl
=equiv
; ecl
!=NULL
; ecl
=ecl
->NEXT
)
845 for (ech
=(chain_list
*)ecl
->DATA
; ech
!=NULL
&& ech
->DATA
!=ch
->DATA
; ech
=ech
->NEXT
) ;
848 toapp
=append(ecl
->DATA
, toapp
);
855 for (ch
=(chain_list
*)equiv_auto
->DATA
; ch
!=NULL
&& ch
->DATA
!=toapp
->DATA
; ch
=ch
->NEXT
) ;
857 equiv_auto
->DATA
=addchain(equiv_auto
->DATA
, toapp
->DATA
);
858 toapp
=delchain(toapp
, toapp
);
860 equiv
=addchain(equiv
, append((chain_list
*)equiv_auto
->DATA
, toapp
));
861 equiv_auto
=delchain(equiv_auto
, equiv_auto
);
866 /*}}}************************************************************************/
867 /*{{{ stb_parse_eqvt_clocks() */
870 /****************************************************************************/
872 stb_parse_eqvt_clocks(stb_parse
*stab
)
874 stab
->PARSEDFIG
->USER
= addptype(stab
->PARSEDFIG
->USER
, STB_EQUIVALENT
,
878 /*}}}************************************************************************/
879 /*}}}************************************************************************/
881 /****************************************************************************/
882 /*{{{ command_state */
885 /****************************************************************************/
887 command_state(ttvsig_list
*ptttvsig
, char state
, int isdefault
)
889 stbnode
*ptstbnode_up
;
890 stbnode
*ptstbnode_dn
;
892 ptstbnode_dn
= stb_getstbnode(ptttvsig
->NODE
);
893 ptstbnode_up
= stb_getstbnode(ptttvsig
->NODE
+1);
894 if (state
== STB_NO_VERIF
)
896 ptstbnode_dn
->CK
->VERIF
= state
;
897 ptstbnode_up
->CK
->VERIF
= state
;
903 ptstbnode_dn
->CK
->VERIF
&= ~(STB_UP
|STB_DN
);
904 ptstbnode_up
->CK
->VERIF
&= ~(STB_UP
|STB_DN
);
906 ptstbnode_dn
->CK
->VERIF
= state
;
907 ptstbnode_up
->CK
->VERIF
= state
;
911 /*}}}************************************************************************/
912 /*{{{ stb_parse_command() */
915 /****************************************************************************/
917 stb_parse_command(stb_parse
*stab
, char *ident
, char state
)
919 ttvsig_list
*ptttvsig
;
921 char *name
= namealloc(ident
);
922 chain_list
*cl
, *start
;
926 if ((start
=getStartForNode_HT(stab
->PARSEDFIG
, name
, 0))==NULL
)
927 start
=stab
->PARSEDFIG
->COMMAND
, tag
=0;
928 cl
=addchain(NULL
, name
);
929 for (ptchain
= start
; ptchain
; ptchain
= ptchain
->NEXT
)
931 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
932 if (getptype(ptttvsig
->USER
, STB_WENABLE
) != NULL
)
934 if (tag
|| ttv_testnetnamemask(stab
->PARSEDFIG
->FIG
, ptttvsig
, cl
))
936 ptttvsig
->USER
= addptype(ptttvsig
->USER
, STB_WENABLE
, (void *)NULL
);
937 command_state(ptttvsig
,state
,0);
938 if (!mbk_isregex_name(name
))
942 if (tag
) freechain(start
);
944 if (ptchain
== NULL
&& !mbk_isregex_name(name
))
947 stb_error(ERR_NO_COMMAND
, name
, yylineno
, STB_FATAL
);
951 /*}}}************************************************************************/
952 /*{{{ stb_parse_comdefault() */
955 /****************************************************************************/
957 stb_parse_comdefault(stb_parse
*stab
, char state
)
959 ttvsig_list
*ptttvsig
;
962 for (ptchain
= stab
->PARSEDFIG
->COMMAND
; ptchain
; ptchain
= ptchain
->NEXT
)
964 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
965 if (getptype(ptttvsig
->USER
, STB_WENABLE
) != NULL
)
967 command_state(ptttvsig
,state
,1);
971 /*}}}************************************************************************/
972 /*{{{ Node abstraction */
975 /****************************************************************************/
976 static inline ttvsig_list
*
977 getSigForNode(chain_list
*ptchain
, int type
)
979 ttvsig_list
*res
= NULL
;
987 res
= (ttvsig_list
*)ptchain
->DATA
;
990 res
= ((ttvevent_list
*)ptchain
->DATA
)->ROOT
;
996 static NameAllocator stb_na
;
997 static ht
*stb_sight
=NULL
;
1000 getStartForNode_HT(stbfig_list
*parsedfig
, char *ident
, int type
)
1006 if (stb_sight
==NULL
)
1008 stb_sight
=addht(10000);
1009 CreateNameAllocator(20000, &stb_na
, CASE_SENSITIVE
);
1010 for (cl
=parsedfig
->MEMORY
; cl
!=NULL
; cl
=cl
->NEXT
)
1012 ttv_getsigname(parsedfig
->FIG
, buf
, (ttvsig_list
*)cl
->DATA
);
1013 addhtitem(stb_sight
, NameAlloc(&stb_na
, buf
), (long)cl
->DATA
);
1015 for (cl
=parsedfig
->CONNECTOR
; cl
!=NULL
; cl
=cl
->NEXT
)
1017 ttv_getsigname(parsedfig
->FIG
, buf
, (ttvsig_list
*)cl
->DATA
);
1018 addhtitem(stb_sight
, NameAlloc(&stb_na
, buf
), (long)cl
->DATA
);
1020 for (cl
=parsedfig
->NODE
; cl
!=NULL
; cl
=cl
->NEXT
)
1022 ttv_getsigname(parsedfig
->FIG
, buf
, ((ttvevent_list
*)cl
->DATA
)->ROOT
);
1023 addhtitem(stb_sight
, NameAlloc(&stb_na
, buf
), (long)((ttvevent_list
*)cl
->DATA
)->ROOT
);
1027 if ((l
=gethtitem(stb_sight
, NameAlloc(&stb_na
, ident
)))==EMPTYHT
)
1030 return addchain(NULL
, (void *)l
);
1033 void cleanStartForNode_HT()
1035 if (stb_sight
!=NULL
)
1038 DeleteNameAllocator(&stb_na
);
1043 static inline chain_list
*
1044 getStartForNode(stbfig_list
*parsedfig
, int type
)
1046 chain_list
*res
= NULL
;
1050 res
= parsedfig
->MEMORY
;
1053 res
= parsedfig
->NODE
;
1057 res
= parsedfig
->CONNECTOR
;
1065 contForNode(ttvsig_list
*ptttvsig
, int type
)
1072 res
= ((ptttvsig
->TYPE
& TTV_SIG_C
) == TTV_SIG_C
||
1073 (ptttvsig
->TYPE
& TTV_SIG_L
) != TTV_SIG_L
);
1076 res
= ((ptttvsig
->TYPE
& TTV_SIG_C
) == TTV_SIG_C
||
1077 (ptttvsig
->TYPE
& TTV_SIG_L
) == TTV_SIG_L
);
1081 res
= ((ptttvsig
->TYPE
& TTV_SIG_CO
) != TTV_SIG_CO
);
1085 res
= ((ptttvsig
->TYPE
& TTV_SIG_CI
) != TTV_SIG_CI
||
1086 (ptttvsig
->TYPE
& TTV_SIG_CB
) == TTV_SIG_CB
);
1093 chkCkForDefaultNode(stbnode
*ptstbnode
, int type
)
1100 res
= (ptstbnode
->CK
&& ptstbnode
->CK
->TYPE
== STB_TYPE_CLOCK
);
1106 static inline stbpair_list
***
1107 getPairForDefaultNode(stbnode
*ptstbnode
, int type
)
1109 stbpair_list
***pair
= NULL
;
1114 pair
= &(ptstbnode
->SPECIN
);
1117 pair
= &(ptstbnode
->SPECOUT
);
1124 /*}}}************************************************************************/
1125 /*{{{ copyIntervallsForDefaultNode() */
1128 /****************************************************************************/
1130 copyIntervallsForDefaultNode(stbnode
*ptstbnode
,
1131 stbpair_list
*ptstbpair
,
1134 stbfig_list
*parsedfig
,
1135 int type
, int slope
,
1139 stbpair_list
***pair
;
1143 pair
= getPairForDefaultNode(ptstbnode
,type
);
1145 (edge_option
== slope
|| edge_option
== STB_SLOPE_ALL
))
1147 *pair
= stb_alloctab(parsedfig
->PHASENUMBER
);
1148 if (mode
== STB_P_DUPPAIR
)
1149 (*pair
)[phase
] = stb_dupstbpairlist(ptstbpair
);
1150 else if (mode
== STB_P_ADDPAIR
)
1151 (*pair
)[phase
] = stb_addstbpair(NULL
, d
, u
);
1156 /*}}}************************************************************************/
1157 /*{{{ parse_checkPhase() */
1160 /****************************************************************************/
1162 parse_checkPhase(stb_parse
*stab
, char *ident
, int source_phase
)
1166 if (source_phase
== STB_NO_INDEX
)
1167 if (stab
->DEFAULTPHASE
!= STB_NO_INDEX
)
1168 phase
= stab
->DEFAULTPHASE
;
1169 else if (!stab
->PARSEDFIG
->CKDOMAIN
||
1170 !stab
->PARSEDFIG
->CKDOMAIN
->NEXT
)
1171 phase
= (int)stab
->PARSEDFIG
->PHASENUMBER
- 1;
1173 stb_error(ERR_UNKNOWN_PHASE
, ident
, yylineno
, STB_FATAL
);
1175 phase
= source_phase
;
1180 /*}}}************************************************************************/
1184 /****************************************************************************/
1186 node(stb_parse
*stab
, char *ident
, char edge_option
, int source_phase
,
1187 char hz_option
, int type
)
1189 ttvsig_list
*ptttvsig
;
1190 chain_list
*ptchain
;
1196 // + rapide mais consomme localement +
1197 ptchain
= getStartForNode_HT(stab
->PARSEDFIG
, ident
, type
);
1199 for ( ; ptchain
; ptchain
= delchain(ptchain
, ptchain
))
1201 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
1202 if (contForNode(ptttvsig
,type
))
1205 phase
= parse_checkPhase(stab
,ident
,source_phase
);
1211 errcode
= stb_addintervals(stab
->PARSEDFIG
, ptttvsig
,
1213 stab
->PTUNSTABLELIST
, table
,
1214 edge_option
, phase
, hz_option
,type
==STB_P_NOD
?1:0);
1218 stb_error(errcode
, ident
, yylineno
, STB_FATAL
);
1222 stb_parse_freeStab(stab
);
1225 stb_error(ERR_NOT_FOUND_NODE
, ident
, yylineno
, STB_NONFATAL
);
1229 // consomme moins (?) et N2/2 pour les noeuds internes
1230 ptchain
= getStartForNode(stab
->PARSEDFIG
,type
);
1231 for ( ; ptchain
; ptchain
= ptchain
->NEXT
)
1233 ptttvsig
= getSigForNode(ptchain
,type
);
1234 if (contForNode(ptttvsig
,type
))
1236 ttv_getsigname(stab
->PARSEDFIG
->FIG
, namebuf
, ptttvsig
);
1237 // if (namealloc(namebuf) == name)
1238 if (mbk_casestrcmp(namebuf
,ident
)==0)
1240 phase
= parse_checkPhase(stab
,ident
,source_phase
);
1246 errcode
= stb_addintervals(stab
->PARSEDFIG
, ptttvsig
,
1248 stab
->PTUNSTABLELIST
, table
,
1249 edge_option
, phase
, hz_option
,type
==STB_P_NOD
?1:0);
1253 stb_error(errcode
, ident
, yylineno
, STB_FATAL
);
1255 if (type
==STB_P_NOD
) break; // pas de regex et ttvsig en double dans la liste
1258 stb_parse_freeStab(stab
);
1262 /*}}}************************************************************************/
1263 /*{{{ stb_parse_mem() */
1266 /****************************************************************************/
1268 stb_parse_mem(stb_parse
*stab
, char *ident
, char edge_option
,
1269 int source_phase
, char hz_option
)
1271 node(stab
, ident
, edge_option
, source_phase
, hz_option
, STB_P_MEM
);
1274 /*}}}************************************************************************/
1275 /*{{{ stb_parse_node() */
1278 /****************************************************************************/
1280 stb_parse_node(stb_parse
*stab
, char *ident
, char edge_option
,
1281 int source_phase
, char hz_option
)
1283 node(stab
, ident
, edge_option
, source_phase
, hz_option
, STB_P_NOD
);
1286 /*}}}************************************************************************/
1287 /*{{{ stb_parse_outnode() */
1290 /****************************************************************************/
1292 stb_parse_outnode(stb_parse
*stab
, char *ident
, char edge_option
,
1293 int source_phase
, char hz_option
)
1295 node(stab
, ident
, edge_option
, source_phase
, hz_option
, STB_P_ONOD
);
1298 /*}}}************************************************************************/
1299 /*{{{ stb_parse_innode() */
1302 /****************************************************************************/
1304 stb_parse_innode(stb_parse
*stab
, char *ident
, char edge_option
,
1305 int source_phase
, char hz_option
)
1307 node(stab
, ident
, edge_option
, source_phase
, hz_option
, STB_P_INOD
);
1310 /*}}}************************************************************************/
1311 /*{{{ stb_parse_freeStab() */
1314 /****************************************************************************/
1316 stb_parse_freeStab(stb_parse
*stab
)
1318 freechain(stab
->PTSTABLELIST
);
1319 stab
->PTSTABLELIST
= NULL
;
1320 freechain(stab
->PTUNSTABLELIST
);
1321 stab
->PTUNSTABLELIST
= NULL
;
1322 stab
->DEFAULTPHASE
= STB_NO_INDEX
;
1325 /*}}}************************************************************************/
1329 /****************************************************************************/
1331 locon(stb_parse
*stab
, char *ident
, char edge_option
, int source_phase
,
1334 ttvsig_list
*ptttvsig
;
1335 chain_list
*ptchain
;
1336 char *name
= namealloc(ident
);
1338 int errcode
= 0, cx
=0;
1341 for (ptchain
= stab
->PARSEDFIG
->CONNECTOR
; ptchain
; ptchain
= ptchain
->NEXT
)
1343 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
1345 if (table
==STB_SPECIN
&& contForNode(ptttvsig
,STB_P_ILOCD
) && (ptttvsig
->TYPE
& TTV_SIG_CX
) != TTV_SIG_CX
)
1347 if (table
==STB_SPECIN
&& (ptttvsig
->TYPE
& TTV_SIG_CB
) == TTV_SIG_CB
)
1349 if (table
==STB_SPECOUT
&& contForNode(ptttvsig
,STB_P_OLOCD
) && (ptttvsig
->TYPE
& TTV_SIG_CX
) != TTV_SIG_CX
)
1352 if ((ptttvsig
->TYPE
& TTV_SIG_CX
) == TTV_SIG_CX
) cx
=1;
1354 ttv_getsigname(stab
->PARSEDFIG
->FIG
, namebuf
, ptttvsig
);
1356 if (mbk_TestREGEX(namebuf
, name
))
1358 // on evite les clocks
1359 if (getptype(ptttvsig
->USER
, STB_IS_CLOCK
)==NULL
)
1361 phase
= parse_checkPhase(stab
,ident
,source_phase
);
1362 errcode
= stb_addintervals(stab
->PARSEDFIG
, ptttvsig
,
1364 stab
->PTUNSTABLELIST
,
1365 table
, edge_option
, phase
, 0, table
==STB_SPECOUT
?1:0);
1369 stb_error(errcode
, name
, yylineno
, STB_FATAL
);
1372 if (!mbk_isregex_name(name
))
1376 stb_parse_freeStab(stab
);
1377 if (ptchain
== NULL
&& !mbk_isregex_name(name
))
1380 stb_error(ERR_NO_CONNECTOR
, name
, yylineno
, STB_FATAL
);
1384 if (cx
&& !mbk_isregex_name(name
)) avt_errmsg(STB_ERRMSG
, "043", AVT_WARNING
, name
);
1388 /*}}}************************************************************************/
1389 /*{{{ stb_parse_inlocon() */
1392 /****************************************************************************/
1394 stb_parse_inlocon(stb_parse
*stab
, char *ident
, char edge_option
,
1397 locon(stab
,ident
,edge_option
,source_phase
,STB_SPECIN
);
1400 /*}}}************************************************************************/
1401 /*{{{ stb_parse_outlocon() */
1404 /****************************************************************************/
1406 stb_parse_outlocon(stb_parse
*stab
, char *ident
, char edge_option
,
1409 locon(stab
,ident
,edge_option
,source_phase
,STB_SPECOUT
);
1412 /*}}}************************************************************************/
1413 /*{{{ default_locon() */
1416 /****************************************************************************/
1418 default_locon(stb_parse
*stab
, char edge_option
, int source_phase
, int type
)
1420 ttvsig_list
*pttarget
;
1421 stbnode
*ptstbnode_up
;
1422 stbnode
*ptstbnode_dn
;
1423 stbpair_list
*ptstbpair
;
1424 chain_list
*ptchain
;
1429 phase
= parse_checkPhase(stab
,"default",source_phase
);
1430 period
= stb_getperiod(stab
->PARSEDFIG
, phase
);
1431 ptstbpair
= stb_buildintervals(stab
->PTSTABLELIST
,
1432 stab
->PTUNSTABLELIST
,
1437 stb_error(errcode
, "default", yylineno
, STB_FATAL
);
1439 stb_parse_freeStab(stab
);
1441 for (ptchain
= stab
->PARSEDFIG
->CONNECTOR
; ptchain
; ptchain
= ptchain
->NEXT
)
1443 pttarget
= (ttvsig_list
*)ptchain
->DATA
;
1444 if (contForNode(pttarget
,type
))
1446 ptstbnode_dn
= stb_getstbnode(pttarget
->NODE
);
1447 ptstbnode_up
= stb_getstbnode(pttarget
->NODE
+1);
1449 if (chkCkForDefaultNode(ptstbnode_dn
,type
) ||
1450 chkCkForDefaultNode(ptstbnode_up
,type
))
1453 copyIntervallsForDefaultNode(ptstbnode_dn
,ptstbpair
,edge_option
,phase
,
1454 stab
->PARSEDFIG
,type
,STB_SLOPE_DN
,0,0,
1456 copyIntervallsForDefaultNode(ptstbnode_up
,ptstbpair
,edge_option
,phase
,
1457 stab
->PARSEDFIG
,type
,STB_SLOPE_UP
,0,0,
1460 stb_freestbpair(ptstbpair
);
1463 /*}}}************************************************************************/
1464 /*{{{ stb_parse_indefault() */
1467 /****************************************************************************/
1469 stb_parse_indefault(stb_parse
*stab
, char edge_option
, int source_phase
)
1471 default_locon(stab
,edge_option
,source_phase
,STB_P_ILOCD
);
1474 /*}}}************************************************************************/
1475 /*{{{ stb_parse_outdefault() */
1478 /****************************************************************************/
1480 stb_parse_outdefault(stb_parse
*stab
, char edge_option
, int source_phase
)
1482 default_locon(stab
,edge_option
,source_phase
,STB_P_OLOCD
);
1485 /*}}}************************************************************************/
1486 /*}}}************************************************************************/
1488 /****************************************************************************/
1489 /*{{{ stb_parse_stb_file() */
1492 /****************************************************************************/
1494 stb_parse_stb_file(stb_parse
*stab
)
1496 ttvsig_list
*ptttvsig
;
1497 stbfig_list
*parsedfig
= stab
->PARSEDFIG
;
1498 chain_list
*ptchain
;
1501 char edge
, phasenumber
;
1505 phasenumber
= parsedfig
->PHASENUMBER
;
1506 ptstbck
= stb_getclock(parsedfig
,phasenumber
- 1,NULL
,&edge
,NULL
);
1508 if (ptstbck
!= NULL
)
1510 if (edge
== STB_SLOPE_DN
)
1512 d
= ptstbck
->SDNMIN
;
1513 u
= ptstbck
->SDNMAX
;
1517 d
= ptstbck
->SUPMIN
;
1518 u
= ptstbck
->SUPMAX
;
1522 for (ptchain
= parsedfig
->CONNECTOR
; ptchain
; ptchain
= ptchain
->NEXT
)
1524 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
1525 if (contForNode(ptttvsig
,STB_P_ILOCD
))
1527 for (i
= 0; i
< 2; i
++)
1529 ptstbnode
= stb_getstbnode(ptttvsig
->NODE
+i
);
1530 if (chkCkForDefaultNode(ptstbnode
,STB_P_ILOCD
))
1533 copyIntervallsForDefaultNode(ptstbnode
,NULL
,0,phasenumber
-1,parsedfig
,
1534 STB_P_ILOCD
,0,d
,u
,STB_P_ADDPAIR
);
1537 stab
->PARSEDFIG
= NULL
; /* finished with it */
1540 /*}}}************************************************************************/
1541 /*{{{ stb_parse_name() */
1544 /****************************************************************************/
1546 stb_parse_name(stb_parse
*stab
, char *ident
, int doit
)
1553 // if (doit || !done)
1555 name
= namealloc(ident
);
1557 /* check that the STB figure exists */
1558 for (ptfig
= HEAD_STBFIG
; ptfig
&& !found
; ptfig
= ptfig
->NEXT
)
1560 if (ptfig
->FIG
->INFO
->FIGNAME
== name
)
1563 stab
->PARSEDFIG
= ptfig
;
1566 stb_error(ERR_NO_FIGURE
, NULL
, 0, STB_FATAL
);
1571 /*}}}************************************************************************/
1572 /*{{{ stb_parse_relative_phase() */
1575 /****************************************************************************/
1577 stb_parse_relative_phase(stb_parse
*stab
, stb_parse_doublet
*relative_phase
,
1578 char relative_type
, char *ident
, int edge_option
)
1580 ttvevent_list
*ptttvevent
;
1581 ttvevent_list
*ptttvck
;
1585 name
= namealloc(ident
);
1586 ptttvevent
= stb_getphase(stab
->PARSEDFIG
,name
,edge_option
);
1589 ptttvevent
= stb_getphase(stab
->PARSEDFIG
,name
,STB_SLOPE_ALL
);
1591 if ((ptttvevent
->TYPE
& TTV_NODE_UP
) == TTV_NODE_UP
)
1592 ptttvck
= ptttvevent
->ROOT
->NODE
;
1594 ptttvck
= ptttvevent
->ROOT
->NODE
+ 1 ;
1598 stb_error(ERR_UNKNOWN_PHASE
,name
,yylineno
,STB_FATAL
);
1602 ptttvck
= ptttvevent
;
1604 ptstbck
= stb_getstbnode(ptttvck
)->CK
;
1605 if ((ptttvck
->TYPE
& TTV_NODE_UP
) == TTV_NODE_UP
)
1607 relative_phase
->start
= ptstbck
->SUPMIN
;
1608 relative_phase
->end
= ptstbck
->SUPMAX
;
1612 relative_phase
->start
= ptstbck
->SDNMIN
;
1613 relative_phase
->end
= ptstbck
->SDNMAX
;
1616 if (relative_type
== STBYY_BEFORE
)
1618 relative_phase
->start
+= ptstbck
->PERIOD
;
1619 relative_phase
->end
+= ptstbck
->PERIOD
;
1620 relative_phase
->signe
= (long)-1;
1623 relative_phase
->signe
= (long)1;
1625 ptstbck
= stb_getstbnode(ptttvevent
)->CK
;
1626 stab
->DEFAULTPHASE
= ptstbck
->CKINDEX
;
1630 /*}}}************************************************************************/
1631 /*{{{ stb_parse_phase() */
1634 /****************************************************************************/
1636 stb_parse_phase(stb_parse
*stab
, char *ident
, int edge_option
)
1645 name
= namealloc(ident
);
1646 res
= (int)stb_getphaseindex(stab
->PARSEDFIG
,name
,edge_option
);
1647 if (res
== STB_NO_INDEX
)
1650 stb_error(ERR_UNKNOWN_PHASE
,name
,yylineno
,STB_FATAL
);
1657 /*}}}************************************************************************/
1658 /*{{{ stb_parse_stability() */
1661 /****************************************************************************/
1663 stb_parse_stability(stb_parse
*stab
, char stability_type
, long integer
,
1664 stb_parse_doublet
*relative_phase
, chain_list
*inschain
)
1671 stabtime
= integer
* relative_phase
->signe
+ relative_phase
->end
;
1672 res
= addchain(NULL
,(void *)stabtime
);
1677 if (stability_type
== STB_STABLE
)
1678 stab
->PTSTABLELIST
= append(stab
->PTSTABLELIST
,res
);
1680 stab
->PTUNSTABLELIST
= append(stab
->PTUNSTABLELIST
,res
);
1683 /*}}}************************************************************************/
1684 /*{{{ stb_parse_wenable() */
1687 /****************************************************************************/
1689 stb_parse_wenable(stb_parse
*stab
)
1691 ttvsig_list
*ptttvsig
;
1692 chain_list
*ptchain
;
1694 for (ptchain
= stab
->PARSEDFIG
->COMMAND
; ptchain
; ptchain
= ptchain
->NEXT
)
1696 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
1697 if (getptype(ptttvsig
->USER
, STB_WENABLE
) != NULL
)
1698 ptttvsig
->USER
= delptype(ptttvsig
->USER
, STB_WENABLE
);
1702 /*}}}************************************************************************/
1703 /*}}}************************************************************************/
1706 stb_parse_memory(stb_parse
*stab
, char *ident
, int state
)
1708 ttvsig_list
*ptttvsig
;
1709 chain_list
*ptchain
;
1710 char *name
= namealloc(ident
);
1712 chain_list
*cl
, *start
;
1715 if ((start
=getStartForNode_HT(stab
->PARSEDFIG
, name
, 0))==NULL
)
1716 start
=stab
->PARSEDFIG
->MEMORY
, tag
=0;
1718 cl
=addchain(NULL
, ident
);
1719 for (ptchain
= start
; ptchain
; ptchain
= ptchain
->NEXT
)
1721 ptttvsig
= (ttvsig_list
*)ptchain
->DATA
;
1722 if (tag
|| ttv_testnetnamemask(stab
->PARSEDFIG
->FIG
, ptttvsig
, cl
))
1724 n
=stb_getstbnode(ptttvsig
->NODE
);
1725 if (state
& INF_NOCHECK_SETUP
) n
->FLAG
|=STB_NODE_NOSETUP
;
1726 if (state
& INF_NOCHECK_HOLD
) n
->FLAG
|=STB_NODE_NOHOLD
;
1727 n
=stb_getstbnode(ptttvsig
->NODE
+1);
1728 if (state
& INF_NOCHECK_SETUP
) n
->FLAG
|=STB_NODE_NOSETUP
;
1729 if (state
& INF_NOCHECK_HOLD
) n
->FLAG
|=STB_NODE_NOHOLD
;
1730 if (!mbk_isregex_name(name
))
1734 if (tag
) freechain(start
);
1736 if (ptchain
== NULL
&& !mbk_isregex_name(name
))
1739 stb_error(ERR_NOT_FOUND_MEMORY
, name
, yylineno
, STB_FATAL
);