1 /****************************************************************************/
3 /* Chaine de CAO & VLSI AVERTEC */
5 /* Produit : BEHVECT Version 1.00 */
6 /* Fichier : beh_dup.c */
8 /* (c) copyright 2003 AVERTEC */
9 /* Tous droits reserves */
11 /* Auteur(s) : Antony PINTO */
13 /****************************************************************************/
20 #define XOU(a,b) (!(a) && (b)) || ((a) && !(b))
22 static chain_list
*BEH_EXP_LIST
= NULL
;
23 static ht
*BEH_EXP_TABLE
= NULL
;
25 //static vectbiabl_list *beh_explodeVectBiabl (vectbiabl_list *vbiabl,char *name);
26 //static vectbiabl_list *beh_explodeVect (vectbiabl_list *vbiabl,char *name);
27 biabl_list
*beh_explodeBiabl (biabl_list
*biabl
,int index
, char *name
,int left
, int right
,void (*func
)(char*,int,biabl_list
*));
28 static void beh_explodeLoopInt (eqt_ctx
*ctx
, loop_list
*loop
, biabl_list
*biabl
, char *name
,void (*func
)(char*,int,biabl_list
*));
29 void beh_explodeLoop (loop_list
*loop
, biabl_list
*biabl
,char *name
,void (*func
)(char*,int,biabl_list
*));
30 static chain_list
*beh_explodeLoopAbl (eqt_ctx
*ctx
, chain_list
*abl
);
32 befig_list
*beh_duplicate (befig_list
*befig
);
34 static bereg_list
*beh_dupreg (bereg_list
*reg
);
35 static bevectreg_list
*beh_dupvreg (bevectreg_list
*vreg
);
36 static bebus_list
*beh_dupbus (bebus_list
*bus
);
37 static bevectbus_list
*beh_dupvbus (bevectbus_list
*vbus
);
38 static bebux_list
*beh_dupbux (bebux_list
*bux
);
39 static bevectbux_list
*beh_dupvbux (bevectbux_list
*vbux
);
40 static beaux_list
*beh_dupaux (beaux_list
*aux
);
41 static bevectaux_list
*beh_dupvaux (bevectaux_list
*vaux
);
42 static beout_list
*beh_dupout (beout_list
*out
);
43 static bevectout_list
*beh_dupvout (bevectout_list
*vout
);
44 static bepor_list
*beh_duppor (bepor_list
*por
);
45 static bevectpor_list
*beh_dupvpor (bevectpor_list
*vpor
);
46 static berin_list
*beh_duprin (berin_list
*rin
);
47 static bemsg_list
*beh_dupmsg (bemsg_list
*msg
);
49 static vectbiabl_list
*beh_dupvbiabl (vectbiabl_list
*vbiabl
);
50 static loop_list
*beh_duploop (loop_list
*loop
);
52 static berin_list
*beh_bitrzrin (berin_list
*rin
);
53 static bereg_list
*beh_bitrzreg (bereg_list
*reg
);
54 static bebux_list
*beh_bitrzbux (bebux_list
*bux
);
55 static bebus_list
*beh_bitrzbus (bebus_list
*bus
);
56 static bemsg_list
*beh_bitrzmsg (bemsg_list
*msg
);
57 static bereg_list
*beh_bitrzvreg (bevectreg_list
*vreg
,bereg_list
*reg
);
58 static bebux_list
*beh_bitrzvbux (bevectbux_list
*vbux
,bebux_list
*bux
);
59 static bebus_list
*beh_bitrzvbus (bevectbus_list
*vbus
,bebus_list
*bus
);
60 static beaux_list
*beh_bitrzvaux (bevectaux_list
*vaux
,beaux_list
*aux
);
61 static beout_list
*beh_bitrzvout (bevectout_list
*vout
,beout_list
*out
);
62 static bepor_list
*beh_bitrzvpor (bevectpor_list
*vpor
,bepor_list
*por
);
64 static int beh_explodews(biabl_list
*biabl
);
65 static chain_list
*beh_bitrzcndws(chain_list
*cnd
, char *bitstr
);
66 static void beh_bitrzcnd(chain_list
*cnd
);
67 static void beh_explodec(biabl_list
*biabl
);
69 static void beh_resolvingfunc(char *name
,int index
,biabl_list
*biabl
);
71 static bereg_list
*beh_addloopreg(bereg_list
*reg
);
72 static bebus_list
*beh_addloopbus(bebus_list
*bus
);
73 static bebux_list
*beh_addloopbux(bebux_list
*bux
);
74 static biabl_list
*beh_expgetbiabl(chain_list
*list
);
76 /****************************************************************************/
77 /*{{{ Biterize functions */
78 /****************************************************************************/
79 /*{{{ beh_biterize() */
81 /* suppress vectorisation, loop and with select */
83 /****************************************************************************/
84 void beh_biterize(befig_list
*befig
)
86 BEH_EXP_TABLE
= addht(100);
88 befig
->BEREG
= beh_bitrzreg (befig
->BEREG
);
89 befig
->BEBUX
= beh_bitrzbux (befig
->BEBUX
);
90 befig
->BEBUS
= beh_bitrzbus (befig
->BEBUS
);
91 befig
->BEAUX
= befig
->BEAUX
;
92 befig
->BEOUT
= befig
->BEOUT
;
93 befig
->BEPOR
= befig
->BEPOR
;
95 befig
->BEREG
= beh_bitrzvreg (befig
->BEVECTREG
,befig
->BEREG
);
96 befig
->BEVECTREG
= beh_delbevectreg (befig
->BEVECTREG
,befig
->BEVECTREG
,'Y');
97 befig
->BEBUX
= beh_bitrzvbux (befig
->BEVECTBUX
,befig
->BEBUX
);
98 befig
->BEVECTBUX
= beh_delbevectbux (befig
->BEVECTBUX
,befig
->BEVECTBUX
,'Y');
99 befig
->BEBUS
= beh_bitrzvbus (befig
->BEVECTBUS
,befig
->BEBUS
);
100 befig
->BEVECTBUS
= beh_delbevectbus (befig
->BEVECTBUS
,befig
->BEVECTBUS
,'Y');
101 befig
->BEAUX
= beh_bitrzvaux (befig
->BEVECTAUX
,befig
->BEAUX
);
102 befig
->BEVECTAUX
= beh_delbevectaux (befig
->BEVECTAUX
,befig
->BEVECTAUX
,'Y');
103 befig
->BEOUT
= beh_bitrzvout (befig
->BEVECTOUT
,befig
->BEOUT
);
104 befig
->BEVECTOUT
= beh_delbevectout (befig
->BEVECTOUT
,befig
->BEVECTOUT
,'Y');
105 befig
->BEPOR
= beh_bitrzvpor (befig
->BEVECTPOR
,befig
->BEPOR
);
106 befig
->BEVECTPOR
= beh_delbevectpor (befig
->BEVECTPOR
,befig
->BEVECTPOR
);
108 befig
->BERIN
= beh_bitrzrin (befig
->BERIN
);
109 befig
->BEMSG
= beh_bitrzmsg (befig
->BEMSG
);
111 delht(BEH_EXP_TABLE
);
112 BEH_EXP_TABLE
= NULL
;
115 /*}}}************************************************************************/
116 /*{{{ beh_bitrzrin() */
119 /****************************************************************************/
120 static berin_list
*beh_bitrzrin(berin_list
*rin
)
127 rin
->NEXT
= beh_bitrzrin(rin
->NEXT
);
128 min
= (rin
->LEFT
>= rin
->RIGHT
) ? rin
->RIGHT
: rin
->LEFT
;
129 max
= (rin
->LEFT
>= rin
->RIGHT
) ? rin
->LEFT
: rin
->RIGHT
;
130 for (i
= min
; i
<= max
; i
++ )
132 sprintf(buf
,"%s %d",rin
->NAME
,i
);
133 rin
->NEXT
= beh_addberin(rin
->NEXT
,namealloc(buf
));
136 return beh_delberin(rin
,rin
);
142 /*}}}************************************************************************/
143 /*{{{ beh_bitrzmsg() */
146 /****************************************************************************/
147 static bemsg_list
*beh_bitrzmsg(bemsg_list
*msg
)
153 msg
->NEXT
= beh_bitrzmsg(msg
->NEXT
);
154 max
= verifyVectAbl(msg
->ABL
);
155 for (i
= 0; i
< max
; i
++ )
156 msg
->NEXT
= beh_addbemsg(msg
->NEXT
,msg
->LABEL
,msg
->LEVEL
,msg
->MESSAGE
,
157 getAblAtPos(msg
->ABL
,i
),NULL
);
159 return beh_delbemsg(msg
,msg
,'Y');
165 /*}}}************************************************************************/
166 /*{{{ beh_bitrzvpor() */
169 /****************************************************************************/
170 static bepor_list
*beh_bitrzvpor(bevectpor_list
*vpor
,bepor_list
*por
)
177 way
= (vpor
->LEFT
> vpor
->RIGHT
);
178 por
= beh_bitrzvpor(vpor
->NEXT
,por
);
179 vpor
->NEXT
= beh_delbevectpor(vpor
->NEXT
,vpor
->NEXT
);
180 for (i
= vpor
->LEFT
; XOU(way
, i
<= vpor
->RIGHT
-way
); (way
) ? i
-- : i
++ )
182 sprintf(buf
,"%s %d",vpor
->NAME
,i
);
183 por
= beh_addbepor(por
,namealloc(buf
),vpor
->DIRECTION
,vpor
->TYPE
);
191 /*}}}************************************************************************/
192 /*{{{ beh_bitrzreg() */
195 /****************************************************************************/
196 static bereg_list
*beh_bitrzreg(bereg_list
*reg
)
200 beh_bitrzreg(reg
->NEXT
);
201 beh_explodec(reg
->BIABL
);
205 /*}}}************************************************************************/
206 /*{{{ beh_bitrzbux() */
209 /****************************************************************************/
210 static bebux_list
*beh_bitrzbux(bebux_list
*bux
)
214 beh_bitrzbux(bux
->NEXT
);
215 if (!beh_explodews(bux
->BIABL
))
216 beh_explodec(bux
->BIABL
);
221 /*}}}************************************************************************/
222 /*{{{ beh_bitrzbus() */
225 /****************************************************************************/
226 static bebus_list
*beh_bitrzbus(bebus_list
*bus
)
230 beh_bitrzbus(bus
->NEXT
);
231 if (!beh_explodews(bus
->BIABL
))
232 beh_explodec(bus
->BIABL
);
237 /*}}}************************************************************************/
238 /*{{{ beh_bitrzvreg() */
241 /****************************************************************************/
242 static bereg_list
*beh_bitrzvreg(bevectreg_list
*vreg
,bereg_list
*reg
)
246 vectbiabl_list
*vbiablx
;
251 reg
= beh_bitrzvreg(vreg
->NEXT
,reg
);
252 vreg
->NEXT
= beh_delbevectreg(vreg
->NEXT
,vreg
->NEXT
,'Y');
253 while ( vreg
->VECTBIABL
)
255 vbiablx
= vreg
->VECTBIABL
;
256 cnddone
= beh_explodews(vbiablx
->BIABL
);
257 way
= (vbiablx
->LEFT
> vbiablx
->RIGHT
);
258 for ( i
= vbiablx
->LEFT
; XOU(way
, i
<= vbiablx
->RIGHT
-way
);
259 (way
) ? i
-- : i
++ )
261 biablx
= beh_explodeBiabl(vbiablx
->BIABL
,i
,vreg
->NAME
,vbiablx
->LEFT
,
262 vbiablx
->RIGHT
,beh_resolvingfunc
);
265 sprintf(buf
,"%s %d",vreg
->NAME
,i
);
266 reg
= beh_addbereg(reg
,namealloc(buf
),biablx
,NULL
,vreg
->FLAGS
);
268 beh_explodec(reg
->BIABL
);
272 reg
= beh_addloopreg(reg
);
276 vreg
->VECTBIABL
= beh_delvectbiabl(vbiablx
,vbiablx
,'Y');
284 /*}}}************************************************************************/
285 /*{{{ beh_bitrzvbus() */
288 /****************************************************************************/
289 static bebus_list
*beh_bitrzvbus(bevectbus_list
*vbus
,bebus_list
*bus
)
293 vectbiabl_list
*vbiablx
;
298 bus
= beh_bitrzvbus(vbus
->NEXT
,bus
);
299 vbus
->NEXT
= beh_delbevectbus(vbus
->NEXT
,vbus
->NEXT
,'Y');
300 while ( vbus
->VECTBIABL
)
302 vbiablx
= vbus
->VECTBIABL
;
303 cnddone
= beh_explodews(vbiablx
->BIABL
);
304 way
= (vbiablx
->LEFT
> vbiablx
->RIGHT
);
305 for ( i
= vbiablx
->LEFT
; XOU(way
, i
<= vbiablx
->RIGHT
-way
);
306 (way
) ? i
-- : i
++ )
308 biablx
= beh_explodeBiabl(vbiablx
->BIABL
,i
,vbus
->NAME
,vbiablx
->LEFT
,
309 vbiablx
->RIGHT
,beh_resolvingfunc
);
312 sprintf(buf
,"%s %d",vbus
->NAME
,i
);
313 bus
= beh_addbebus(bus
,namealloc(buf
),biablx
,NULL
,0,vbus
->FLAGS
);
315 beh_explodec(bus
->BIABL
);
319 bus
= beh_addloopbus(bus
);
323 vbus
->VECTBIABL
= beh_delvectbiabl(vbiablx
,vbiablx
,'Y');
331 /*}}}************************************************************************/
332 /*{{{ beh_bitrzvbux() */
335 /****************************************************************************/
336 static bebux_list
*beh_bitrzvbux(bevectbux_list
*vbux
,bebux_list
*bux
)
340 vectbiabl_list
*vbiablx
;
345 bux
= beh_bitrzvbux(vbux
->NEXT
,bux
);
346 vbux
->NEXT
= beh_delbevectbux(vbux
->NEXT
,vbux
->NEXT
,'Y');
347 while ( vbux
->VECTBIABL
)
349 vbiablx
= vbux
->VECTBIABL
;
350 cnddone
= beh_explodews(vbiablx
->BIABL
);
351 way
= (vbiablx
->LEFT
> vbiablx
->RIGHT
);
352 for ( i
= vbiablx
->LEFT
; XOU(way
, i
<= vbiablx
->RIGHT
-way
);
353 (way
) ? i
-- : i
++ )
355 biablx
= beh_explodeBiabl(vbiablx
->BIABL
,i
,vbux
->NAME
,vbiablx
->LEFT
,
356 vbiablx
->RIGHT
,beh_resolvingfunc
);
359 sprintf(buf
,"%s %d",vbux
->NAME
,i
);
360 bux
= beh_addbebux(bux
,namealloc(buf
),biablx
,NULL
,0,vbux
->FLAGS
);
362 beh_explodec(bux
->BIABL
);
366 bux
= beh_addloopbux(bux
);
370 vbux
->VECTBIABL
= beh_delvectbiabl(vbiablx
,vbiablx
,'Y');
378 /*}}}************************************************************************/
379 /*{{{ beh_bitrzvaux() */
382 /****************************************************************************/
383 static beaux_list
*beh_bitrzvaux(bevectaux_list
*vaux
,beaux_list
*aux
)
391 way
= (vaux
->LEFT
> vaux
->RIGHT
);
392 aux
= beh_bitrzvaux(vaux
->NEXT
,aux
);
393 vaux
->NEXT
= beh_delbevectaux(vaux
->NEXT
,vaux
->NEXT
,'Y');
394 for (i
= vaux
->LEFT
; XOU(way
, i
<= vaux
->RIGHT
-way
); (way
) ? i
-- : i
++ )
396 sprintf(buf
,"%s %d",vaux
->NAME
,i
);
397 abl
= getAblAtIndex(vaux
->ABL
,vaux
->LEFT
,vaux
->RIGHT
,i
);
398 aux
= beh_addbeaux(aux
,namealloc(buf
),abl
,NULL
,aux
->FLAGS
);
399 aux
->TIME
= vaux
->TIME
;
400 aux
->TIMEVAR
= vaux
->TIMEVAR
;
407 /*}}}************************************************************************/
408 /*{{{ beh_bitrzvout() */
411 /****************************************************************************/
412 static beout_list
*beh_bitrzvout(bevectout_list
*vout
,beout_list
*out
)
420 way
= (vout
->LEFT
> vout
->RIGHT
);
421 out
= beh_bitrzvout(vout
->NEXT
,out
);
422 vout
->NEXT
= beh_delbevectout(vout
->NEXT
,vout
->NEXT
,'Y');
423 for (i
= vout
->LEFT
; XOU(way
, i
<= vout
->RIGHT
-way
); (way
) ? i
-- : i
++ )
425 sprintf(buf
,"%s %d",vout
->NAME
,i
);
426 abl
= getAblAtIndex(vout
->ABL
,vout
->LEFT
,vout
->RIGHT
,i
);
427 out
= beh_addbeout(out
,namealloc(buf
),abl
,NULL
,out
->FLAGS
);
428 out
->TIME
= vout
->TIME
;
429 out
->TIMEVAR
= vout
->TIMEVAR
;
436 /*}}}************************************************************************/
437 /*{{{ beh_explodews() */
439 /* destroy with select */
441 /****************************************************************************/
442 static int beh_explodews(biabl_list
*biabl
)
444 if (biabl
&& biabl
->FLAG
& BEH_CND_SELECT
)
450 for (biablx
= biabl
; biablx
; biablx
= biablx
->NEXT
)
452 if (biablx
->FLAG
& BEH_CND_SELECT
)
454 abl
= beh_bitrzcndws(biablx
->CNDABL
,beh_getcndvectfbiabl(biablx
));
455 flag
= (biablx
->FLAG
| BEH_CND_PRECEDE
) & ~BEH_CND_SELECT
;
457 else if (biablx
->FLAG
& BEH_CND_SEL_OTHERS
)
459 abl
= createBitStr("1");
460 flag
= (biablx
->FLAG
| BEH_CND_PRECEDE
) & ~BEH_CND_SEL_OTHERS
;
463 beh_toolbug(20,"beh_explodews",NULL
,0);
464 beh_delcndvectfbiabl(biabl
);
465 biablx
->CNDABL
= abl
;
474 /*}}}************************************************************************/
475 /*{{{ beh_explodec() */
477 /* destroy vectorized conditions */
479 /****************************************************************************/
480 static void beh_explodec(biabl_list
*biabl
)
486 for (biablx
= biabl
; biablx
; biablx
= biablx
->NEXT
)
487 beh_bitrzcnd(biablx
->CNDABL
);
491 /*}}}************************************************************************/
492 /*{{{ beh_bitrzcnd() */
495 /****************************************************************************/
496 static void beh_bitrzcnd(chain_list
*cnd
)
506 while ((cnd
= CDR(cnd
)))
507 beh_bitrzcnd(CAR(cnd
));
511 /*}}}************************************************************************/
512 /*{{{ beh_bitrzcndws() */
515 /****************************************************************************/
516 static chain_list
*beh_bitrzcndws(chain_list
*cnd
, char *bitstr
)
519 chain_list
*res
, *tmp
;
521 res
= createExpr(AND
);
522 max
= verifyVectAbl(cnd
);
523 for (i
= 0; i
< max
; i
++)
525 tmp
= getAblAtPos(cnd
,i
);
527 switch (*(bitstr
+1+i
))
542 /*}}}************************************************************************/
543 /*}}}************************************************************************/
544 /*{{{ Duplication functions */
545 /****************************************************************************/
546 /*{{{ beh_duplicate() */
549 /****************************************************************************/
550 befig_list
*beh_duplicate(befig_list
*befig
)
554 res
= beh_addbefig(NULL
,befig
->NAME
);
555 res
->BEREG
= beh_dupreg (befig
->BEREG
);
556 res
->BEBUX
= beh_dupbux (befig
->BEBUX
);
557 res
->BEBUS
= beh_dupbus (befig
->BEBUS
);
558 res
->BEAUX
= beh_dupaux (befig
->BEAUX
);
559 res
->BEOUT
= beh_dupout (befig
->BEOUT
);
560 res
->BEPOR
= beh_duppor (befig
->BEPOR
);
561 res
->BEVECTREG
= beh_dupvreg (befig
->BEVECTREG
);
562 res
->BEVECTBUX
= beh_dupvbux (befig
->BEVECTBUX
);
563 res
->BEVECTBUS
= beh_dupvbus (befig
->BEVECTBUS
);
564 res
->BEVECTAUX
= beh_dupvaux (befig
->BEVECTAUX
);
565 res
->BEVECTOUT
= beh_dupvout (befig
->BEVECTOUT
);
566 res
->BEVECTPOR
= beh_dupvpor (befig
->BEVECTPOR
);
568 res
->BERIN
= beh_duprin (befig
->BERIN
);
569 res
->BEMSG
= beh_dupmsg (befig
->BEMSG
);
574 /*}}}************************************************************************/
575 /*{{{ beh_dupbiabl() */
578 /****************************************************************************/
579 biabl_list
*beh_dupbiabl(biabl_list
*biabl
)
585 new = beh_addbiabl(NULL
,biabl
->LABEL
,NULL
,NULL
);
586 new->TIME
= biabl
->TIME
;
587 new->TIMER
= biabl
->TIMER
;
588 new->TIMEF
= biabl
->TIMEF
;
589 new->TIMEVAR
= biabl
->TIMEVAR
;
590 new->FLAG
= biabl
->FLAG
;
591 new->CNDABL
= copyExpr (biabl
->CNDABL
);
592 new->VALABL
= copyExpr (biabl
->VALABL
);
593 new->LOOP
= beh_duploop (biabl
->LOOP
);
594 new->NEXT
= beh_dupbiabl(biabl
->NEXT
);
595 new->USER
= dupptypelst (biabl
->USER
);
603 /*}}}************************************************************************/
604 /*{{{ beh_dupvbiabl() */
607 /****************************************************************************/
608 vectbiabl_list
*beh_dupvbiabl(vectbiabl_list
*vbiabl
)
614 new = beh_addvectbiabl(NULL
,vbiabl
->LEFT
,vbiabl
->RIGHT
,NULL
);
615 new->BIABL
= beh_dupbiabl (vbiabl
->BIABL
);
616 new->NEXT
= beh_dupvbiabl (vbiabl
->NEXT
);
624 /*}}}************************************************************************/
625 /*{{{ beh_duploop() */
628 /****************************************************************************/
629 loop_list
*beh_duploop(loop_list
*loop
)
635 res
= beh_duploop(loop
->NEXT
);
636 res
= beh_newloop(res
,loop
->VARNAME
,loop
->INDEX
,loop
->LEFT
,loop
->RIGHT
);
644 /*}}}************************************************************************/
645 /*{{{ beh_dupreg() */
648 /****************************************************************************/
649 static bereg_list
*beh_dupreg(bereg_list
*reg
)
652 return beh_addbereg(beh_dupreg(reg
->NEXT
),reg
->NAME
,
653 beh_dupbiabl(reg
->BIABL
),NULL
,reg
->FLAGS
);
658 /*}}}************************************************************************/
659 /*{{{ beh_dupvreg() */
662 /****************************************************************************/
663 static bevectreg_list
*beh_dupvreg(bevectreg_list
*vreg
)
666 return beh_addbevectreg(beh_dupvreg(vreg
->NEXT
),vreg
->NAME
,
667 beh_dupvbiabl(vreg
->VECTBIABL
),
668 vreg
->LEFT
,vreg
->RIGHT
,vreg
->FLAGS
);
673 /*}}}************************************************************************/
674 /*{{{ beh_dupbus() */
677 /****************************************************************************/
678 static bebus_list
*beh_dupbus(bebus_list
*bus
)
681 return beh_addbebus(beh_dupbus(bus
->NEXT
),bus
->NAME
,
682 beh_dupbiabl(bus
->BIABL
),NULL
,bus
->TYPE
,bus
->FLAGS
);
687 /*}}}************************************************************************/
688 /*{{{ beh_dupvbus() */
691 /****************************************************************************/
692 static bevectbus_list
*beh_dupvbus(bevectbus_list
*vbus
)
695 return beh_addbevectbus(beh_dupvbus(vbus
->NEXT
),vbus
->NAME
,
696 beh_dupvbiabl(vbus
->VECTBIABL
),
697 vbus
->LEFT
,vbus
->RIGHT
,vbus
->TYPE
,vbus
->FLAGS
);
702 /*}}}************************************************************************/
703 /*{{{ beh_dupbux() */
706 /****************************************************************************/
707 static bebux_list
*beh_dupbux(bebux_list
*bux
)
710 return beh_addbebux(beh_dupbux(bux
->NEXT
),bux
->NAME
,
711 beh_dupbiabl(bux
->BIABL
),NULL
,bux
->TYPE
,bux
->FLAGS
);
716 /*}}}************************************************************************/
717 /*{{{ beh_dupvbux() */
720 /****************************************************************************/
721 static bevectbux_list
*beh_dupvbux(bevectbux_list
*vbux
)
724 return beh_addbevectbux(beh_dupvbux(vbux
->NEXT
),vbux
->NAME
,
725 beh_dupvbiabl(vbux
->VECTBIABL
),
726 vbux
->LEFT
,vbux
->RIGHT
,vbux
->TYPE
,vbux
->FLAGS
);
731 /*}}}************************************************************************/
732 /*{{{ beh_dupaux() */
735 /****************************************************************************/
736 static beaux_list
*beh_dupaux(beaux_list
*aux
)
742 res
= beh_addbeaux(beh_dupaux(aux
->NEXT
),aux
->NAME
,
743 copyExpr(aux
->ABL
),NULL
,aux
->FLAGS
);
744 res
->TIME
= aux
->TIME
;
745 res
->TIMER
= aux
->TIMER
;
746 res
->TIMEF
= aux
->TIMEF
;
747 res
->TIMEVAR
= aux
->TIMEVAR
;
755 /*}}}************************************************************************/
756 /*{{{ beh_dupvaux() */
759 /****************************************************************************/
760 static bevectaux_list
*beh_dupvaux(bevectaux_list
*vaux
)
766 res
= beh_addbevectaux(beh_dupvaux(vaux
->NEXT
),vaux
->NAME
,
767 copyExpr(vaux
->ABL
),vaux
->LEFT
,
768 vaux
->RIGHT
, vaux
->FLAGS
);
769 res
->TIME
= vaux
->TIME
;
770 res
->TIMEVAR
= vaux
->TIMEVAR
;
778 /*}}}************************************************************************/
779 /*{{{ beh_dupout() */
782 /****************************************************************************/
783 static beout_list
*beh_dupout(beout_list
*out
)
789 res
= beh_addbeout(beh_dupout(out
->NEXT
),out
->NAME
,
790 copyExpr(out
->ABL
),NULL
,out
->FLAGS
);
791 res
->TIME
= out
->TIME
;
792 res
->TIMER
= out
->TIMER
;
793 res
->TIMEF
= out
->TIMEF
;
794 res
->TIMEVAR
= out
->TIMEVAR
;
802 /*}}}************************************************************************/
803 /*{{{ beh_dupvout() */
806 /****************************************************************************/
807 static bevectout_list
*beh_dupvout(bevectout_list
*vout
)
813 res
= beh_addbevectout(beh_dupvout(vout
->NEXT
),vout
->NAME
,
814 copyExpr(vout
->ABL
),vout
->LEFT
,
815 vout
->RIGHT
, vout
->FLAGS
);
816 res
->TIME
= vout
->TIME
;
817 res
->TIMEVAR
= vout
->TIMEVAR
;
825 /*}}}************************************************************************/
826 /*{{{ beh_duppor() */
829 /****************************************************************************/
830 static bepor_list
*beh_duppor(bepor_list
*por
)
833 return beh_addbepor(beh_duppor(por
->NEXT
),por
->NAME
,por
->DIRECTION
,
839 /*}}}************************************************************************/
840 /*{{{ beh_dupvpor() */
843 /****************************************************************************/
844 static bevectpor_list
*beh_dupvpor(bevectpor_list
*vpor
)
847 return beh_addbevectpor( beh_dupvpor(vpor
->NEXT
),vpor
->NAME
,
848 vpor
->DIRECTION
,vpor
->TYPE
,
849 vpor
->LEFT
,vpor
->RIGHT
);
854 /*}}}************************************************************************/
855 /*{{{ beh_duprin() */
858 /****************************************************************************/
859 static berin_list
*beh_duprin(berin_list
*rin
)
865 res
= beh_duprin(rin
->NEXT
);
866 if (!(rin
->OUT_REF
|| rin
->OUT_VEC
|| rin
->BUS_REF
|| rin
->BUS_VEC
||
867 rin
->AUX_REF
|| rin
->AUX_VEC
|| rin
->REG_REF
|| rin
->REG_VEC
||
868 rin
->BUX_REF
|| rin
->BUX_VEC
))
870 res
= beh_addberin(res
,rin
->NAME
);
871 res
->LEFT
= rin
->LEFT
;
872 res
->RIGHT
= rin
->RIGHT
;
881 /*}}}************************************************************************/
882 /*{{{ beh_dupmsg() */
885 /****************************************************************************/
886 static bemsg_list
*beh_dupmsg(bemsg_list
*msg
)
889 return beh_addbemsg(beh_dupmsg(msg
->NEXT
),msg
->LABEL
,msg
->LEVEL
,
890 msg
->MESSAGE
,copyExpr(msg
->ABL
),NULL
);
895 /*}}}************************************************************************/
896 /*}}}************************************************************************/
897 /*{{{ Explosion functions */
898 /****************************************************************************/
899 ///*{{{ beh_bitrzbiabl() */
902 ///****************************************************************************/
903 //biabl_list *beh_bitrzbiabl(biabl_list *biabl, int index)
910 // res = beh_explodeBiabl(biabl->NEXT,index,name,func);
911 // if ((loop = beh_getloop(biabl)))
915 // beh_explodeLoop(loop,biabl,name,func);
923 // res = beh_addbiabl(res,biabl->LABEL,biabl->CNDABL,NULL);
924 // res->VALABL = getAblAtPos(biabl->VALABL,index);
925 // res->TIME = biabl->TIME;
926 // res->FLAG = biabl->FLAG;
927 // res->USER = dupptypelst(biabl->USER);
935 ///*}}}************************************************************************/
936 /*{{{ beh_resolvingfunc() */
939 /****************************************************************************/
940 static void beh_resolvingfunc(char *name
,int index
,biabl_list
*biabl
)
942 char buf
[1024], *vname
;
945 sprintf(buf
,"%s %d",name
, index
);
946 vname
= namealloc(buf
);
947 explist
= (chain_list
*)gethtitem(BEH_EXP_TABLE
,vname
);
948 if ((long)explist
== EMPTYHT
)
951 BEH_EXP_LIST
= addchain(BEH_EXP_LIST
,vname
);
953 addhtitem(BEH_EXP_TABLE
,vname
,(long)addchain(explist
,biabl
));
956 /*}}}************************************************************************/
957 /*{{{ beh_addloopreg() */
960 /****************************************************************************/
961 static bereg_list
*beh_addloopreg(bereg_list
*reg
)
963 chain_list
*loopreg
, *chainx
;
965 for (chainx
= BEH_EXP_LIST
; chainx
; chainx
= delchain(chainx
,chainx
))
967 loopreg
= (chain_list
*)gethtitem(BEH_EXP_TABLE
,chainx
->DATA
);
968 reg
= beh_addbereg(reg
,chainx
->DATA
,beh_expgetbiabl(loopreg
),NULL
,0);
977 /*}}}************************************************************************/
978 /*{{{ beh_addloopbus() */
981 /****************************************************************************/
982 static bebus_list
*beh_addloopbus(bebus_list
*bus
)
984 chain_list
*loopbus
, *chainx
;
986 for (chainx
= BEH_EXP_LIST
; chainx
; chainx
= delchain(chainx
,chainx
))
988 loopbus
= (chain_list
*)gethtitem(BEH_EXP_TABLE
,chainx
->DATA
);
989 bus
= beh_addbebus(bus
,chainx
->DATA
,beh_expgetbiabl(loopbus
),NULL
,0,0);
998 /*}}}************************************************************************/
999 /*{{{ beh_addloopbux() */
1002 /****************************************************************************/
1003 static bebux_list
*beh_addloopbux(bebux_list
*bux
)
1005 chain_list
*loopbux
, *chainx
;
1007 for (chainx
= BEH_EXP_LIST
; chainx
; chainx
= delchain(chainx
,chainx
))
1009 loopbux
= (chain_list
*)gethtitem(BEH_EXP_TABLE
,chainx
->DATA
);
1010 bux
= beh_addbebux(bux
,chainx
->DATA
,beh_expgetbiabl(loopbux
),NULL
,0,0);
1014 BEH_EXP_LIST
= NULL
;
1019 /*}}}************************************************************************/
1020 /*{{{ beh_expgetbiabl() */
1023 /****************************************************************************/
1024 static biabl_list
*beh_expgetbiabl(chain_list
*list
)
1028 ((biabl_list
*)(list
->DATA
))->NEXT
= beh_expgetbiabl(list
->NEXT
);
1035 /*}}}************************************************************************/
1036 ///*{{{ beh_explodeVect() */
1039 ///****************************************************************************/
1040 //static vectbiabl_list *beh_explodeVect(vectbiabl_list *vbiabl, char *name)
1044 // vbiabl->NEXT = beh_explodeVect(vbiabl->NEXT,name);
1045 // return beh_explodeVectBiabl(vbiabl,name);
1051 ///*}}}************************************************************************/
1052 ///*{{{ beh_explodeVectBiabl() */
1055 ///****************************************************************************/
1056 //static vectbiabl_list *beh_explodeVectBiabl(vectbiabl_list *vbiabl, char *name)
1058 // vectbiabl_list *next = vbiabl->NEXT;
1059 // biabl_list *biabl = vbiabl->BIABL;
1060 // int left = vbiabl->LEFT;
1061 // int right = vbiabl->RIGHT;
1063 // vectbiabl_list *vbiablx;
1067 // if (left == right)
1071 // way = (left - right) / abs(left - right);
1072 // vbiabl->RIGHT = left;
1073 // for ( i = left - way ; way*(i - right) >= 0; i -= way )
1076 // vbiablx = vbiabl;
1078 // vbiablx = beh_addvectbiabl(vbiablx,i,i,NULL);
1079 // if (( new = beh_explodeBiabl(biabl,abs(i-left),name,NULL) ))
1080 // vbiablx->BIABL = new;
1086 ///*}}}************************************************************************/
1087 /*{{{ beh_explodeBiabl() */
1090 /****************************************************************************/
1091 biabl_list
*beh_explodeBiabl(biabl_list
*biabl
,int index
, char *name
,int left
,
1092 int right
,void (*func
)(char*,int,biabl_list
*))
1099 res
= beh_explodeBiabl(biabl
->NEXT
,index
,name
,left
,right
,func
);
1100 if ((loop
= beh_getloop(biabl
)))
1104 beh_explodeLoop(loop
,biabl
,name
,func
);
1110 res
= beh_addbiabl(res
,biabl
->LABEL
,NULL
,NULL
);
1111 res
->CNDABL
= copyExpr(biabl
->CNDABL
);
1112 res
->VALABL
= getAblAtIndex(biabl
->VALABL
,left
,right
,index
);
1113 res
->TIME
= biabl
->TIME
;
1114 res
->TIMEVAR
= biabl
->TIMEVAR
;
1115 res
->FLAG
= biabl
->FLAG
;
1116 res
->USER
= dupptypelst(biabl
->USER
);
1124 /*}}}************************************************************************/
1125 /*{{{ beh_explodeLoop() */
1128 /****************************************************************************/
1129 void beh_explodeLoop(loop_list
*loop
, biabl_list
*biabl
,char *name
,
1130 void (*func
)(char*,int,biabl_list
*))
1132 eqt_ctx
*ctx
= eqt_init(3);
1133 beh_explodeLoopInt(ctx
,loop
,biabl
,name
,func
);
1137 /*}}}************************************************************************/
1138 /*{{{ beh_explodeLoopInt() */
1141 /****************************************************************************/
1142 static void beh_explodeLoopInt(eqt_ctx
*ctx
,loop_list
*loop
,biabl_list
*biabl
,char *name
,
1143 void (*func
)(char*,int,biabl_list
*))
1145 static char ind
[255];
1151 way
= (loop
->LEFT
- loop
->RIGHT
) / abs(loop
->LEFT
- loop
->RIGHT
);
1152 for (i
= loop
->LEFT
; way
*(i
- (int)loop
->RIGHT
) >= 0; i
-= way
)
1154 eqt_addvar(ctx
,loop
->VARNAME
,i
);
1155 sprintf(ind
,"%s",loop
->INDEX
);
1156 beh_explodeLoopInt(ctx
,loop
->NEXT
,biabl
,name
,func
);
1166 eqtres
= eqt_getEvaluedEquation(ctx
,ind
);
1167 index
= atoi(eqtres
);
1169 new = beh_addbiabl(NULL
,biabl
->LABEL
,NULL
,NULL
);
1170 new->VALABL
= beh_explodeLoopAbl(ctx
,copyExpr(biabl
->VALABL
));
1171 new->CNDABL
= beh_explodeLoopAbl(ctx
,copyExpr(biabl
->CNDABL
));
1172 new->TIME
= biabl
->TIME
;
1173 new->TIMEVAR
= biabl
->TIMEVAR
;
1174 new->FLAG
= biabl
->FLAG
& ~BEH_CND_LOOP
;
1175 for ( ptx
= biabl
->USER
; ptx
; ptx
= ptx
->NEXT
)
1176 if (ptx
->TYPE
!= BEH_TYPE_LOOP
)
1177 new->USER
= addptype(new->USER
,ptx
->TYPE
,ptx
->DATA
);
1179 (*func
) (name
,index
,new);
1183 /*}}}************************************************************************/
1184 /*{{{ beh_explodeLoopAbl() */
1186 /* eqt variables positionned */
1188 /****************************************************************************/
1189 static chain_list
*beh_explodeLoopAbl(eqt_ctx
*ctx
,chain_list
*abl
)
1193 char name
[256], index
[256];
1196 switch (sscanf(VALUE_ATOM(abl
),"%s %s",name
,index
))
1199 eqtres
= eqt_getEvaluedEquation(ctx
,index
);
1200 sprintf(name
,"%s %s",name
,eqtres
);
1201 abl
->DATA
= namealloc(name
);
1209 chain_list
*ablx
= abl
;
1211 while ((ablx
= CDR(ablx
)))
1212 CAR(ablx
) = beh_explodeLoopAbl(ctx
,CAR(ablx
));
1217 /*}}}************************************************************************/
1218 /*}}}************************************************************************/