1 /****************************************************************************/
3 /* Chaine de CAO & VLSI Alliance */
5 /* Produit : ROUTER Version 1 */
6 /* Fichier : router.c */
8 /* (c) copyright 1997-1998 Laboratoire LIP6 equipe ASIM */
9 /* Tous droits reserves */
10 /* Support : e-mail alliance-support@asim.lip6.fr */
12 /* Auteur(s) : Karim DIOURY */
14 /****************************************************************************/
22 typedef struct router_data
{
30 static int router_seed
=-1;
32 void avt_SetSEED(int val
)
36 /****************************************************************************/
40 /****************************************************************************/
42 initRouter(router_dt
*rte
)
44 if (router_seed
!=-1) srand(router_seed
);
46 rte
->MAXCAPA
= 10000.0;
48 rte
->MAXRES
= 10000.0;
52 long max( long a
, long b
)
59 float route_rand(float min
, float max
)
63 a
= (int)(max
*100000.0);
64 b
= (int)(min
*100000.0);
65 c
= b
+ rand()%(a
-b
+1);
66 return ((float)c
/100000.0);
69 float route_capa(router_dt
*rte
)
71 return ((float)route_rand(rte
->MINCAPA
*1e15
,rte
->MAXCAPA
*1e15
))*1e-3 ;
74 float route_resis(router_dt
*rte
)
76 return ((float)route_rand(rte
->MINRES
,rte
->MAXRES
)/100.0) ;
79 /*}}}************************************************************************/
80 /*{{{ route_treelosig */
83 /****************************************************************************/
85 route_treelosig(losig_list
*losig
, long node
, int nbcon
,
86 num_list
**loconlist
, router_dt
*rte
)
94 nbwirelist
= route_rand(0,rte
->MAXWIRE
) ;
96 for (i
= 1; i
< nbwirelist
; i
++, node
++)
97 addlowire(losig
,0,route_resis(rte
),route_capa(rte
),node
,node
+1) ;
102 *loconlist
= (*loconlist
)->NEXT
;
104 addlowire(losig
,0,route_resis(rte
),route_capa(rte
),node
,ptnum
->DATA
) ;
110 nbbranch
= route_rand(1,nbcon
-1) ;
112 addlowire(losig
,0,route_resis(rte
),route_capa(rte
),node
,node
+1) ;
115 node
= route_treelosig(losig
,node
+1,nbbranch
,loconlist
,rte
) ;
117 addlowire(losig
,0,route_resis(rte
),route_capa(rte
),nodex
,node
+1) ;
119 node
= route_treelosig(losig
,node
+1,nbcon
-nbbranch
,loconlist
,rte
) ;
124 /*}}}************************************************************************/
128 /****************************************************************************/
130 route_losig(losig_list
*losig
, router_dt
*rte
)
132 locon_list
*locon
= NULL
;
135 num_list
*ptnum
= NULL
;
138 ptype
= getptype(losig
->USER
,LOFIGCHAIN
) ;
140 if (losig
->PRCN
!= NULL
)
144 for (chain
= ptype
->DATA
, nbcon
= 0; chain
; chain
= chain
->NEXT
, nbcon
++)
146 locon
= (locon_list
*)chain
->DATA
;
147 setloconnode(locon
,nbcon
+1) ;
148 if(chain
->NEXT
!= NULL
)
149 ptnum
= addnum(ptnum
,locon
->PNODE
->DATA
) ;
152 if (locon
&& nbcon
!= 1)
153 route_treelosig(losig
,locon
->PNODE
->DATA
,nbcon
-1,&ptnum
,rte
) ;
156 /*}}}************************************************************************/
160 /****************************************************************************/
162 routeCC(lofig_list
*lofig
, router_dt
*rte
)
165 losig_list
**tabsig
;
172 for (losig
= lofig
->LOSIG
, nbsig
= 0; losig
; losig
= losig
->NEXT
)
173 if (!(mbk_LosigIsVDD(losig
) || mbk_LosigIsVSS(losig
)))
176 tabsig
= (losig_list
**)mbkalloc(nbsig
* sizeof(losig_list
*)) ;
178 for (losig
= lofig
->LOSIG
, nbsig
= 0; losig
; losig
= losig
->NEXT
)
179 if (!(mbk_LosigIsVDD(losig
) || mbk_LosigIsVSS(losig
)))
180 tabsig
[nbsig
++] = losig
;
182 for (i
= 0; i
< nbsig
; i
++)
183 for (j
= 1; j
< tabsig
[i
]->PRCN
->NBNODE
; j
++)
186 k
= route_rand(0,nbsig
-1) ;
187 a
= route_rand(1,max(1,tabsig
[k
]->PRCN
->NBNODE
-1));
189 addloctc(tabsig
[i
],j
,tabsig
[k
],a
,route_capa(rte
));
195 /*}}}************************************************************************/
199 /****************************************************************************/
201 routeRC(lofig_list
*lofig
,router_dt
*rte
)
205 for(losig
= lofig
->LOSIG
; losig
; losig
= losig
->NEXT
)
206 if (!(mbk_LosigIsVDD(losig
) || mbk_LosigIsVSS(losig
)))
207 route_losig(losig
,rte
);
210 /*}}}************************************************************************/
214 /****************************************************************************/
215 void avt_AddRC(lofig_list
*lofig
, int maxwire
,
216 double minc
, double maxc
, double minr
, double maxr
)
220 // for debugging purpose
222 //printf("MC:%f mC:%f MR:%f mR:%f MW:%d\n",maxc,minc,maxr,minr,maxwire);
228 if (minc
>= 0) rte
.MINCAPA
= minc
;
229 if (maxc
>= 0) rte
.MAXCAPA
= maxc
;
230 if (minr
>= 0) rte
.MINRES
= (int)(100.0*minr
);
231 if (maxr
>= 0) rte
.MAXRES
= (int)(100.0*maxr
);
232 if (maxwire
>= 0) rte
.MAXWIRE
= maxwire
;
234 if(rte
.MINCAPA
> rte
.MAXCAPA
) rte
.MINCAPA
= rte
.MAXCAPA
;
235 if(rte
.MINRES
> rte
.MAXRES
) rte
.MINRES
= rte
.MAXRES
;
241 /*}}}************************************************************************/
245 /****************************************************************************/
247 avt_AddCC(lofig_list
*lofig
, double minc
, double maxc
)
255 if (minc
>= 0) rte
.MINCAPA
= minc
;
256 if (maxc
>= 0) rte
.MAXCAPA
= maxc
;
258 if (rte
.MINCAPA
> rte
.MAXCAPA
) rte
.MINCAPA
= rte
.MAXCAPA
;
264 /*}}}************************************************************************/