1 /****************************************************************************/
3 /* Chaine de CAO & VLSI Alliance */
5 /* Produit : TMA Version 1 */
6 /* Fichier : tma_blackbox.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) : Gilles AUGUSTINS */
14 /****************************************************************************/
45 #define API_USE_REAL_TYPES
49 float Compute_Delay (ttvfig_list
*fig
, float slope
, float load
, ttvpath_list
*path
, char *max
)
53 ttvsig_list
*start_sig
,
58 ttvpath_list
*pt_res_path
;
63 start_tran
= ttv_GetPathStartDirection (path
);
64 end_tran
= ttv_GetPathEndDirection (path
);
65 start_sig
= ttv_GetPathStartSignal (path
);
66 end_sig
= ttv_GetPathEndSignal (path
);
67 start_name
= ttv_GetSignalName (start_sig
);
68 end_name
= ttv_GetSignalName (end_sig
);
69 sprintf (tran
, "%c%c", start_tran
, end_tran
);
70 // no slope propagation prop = 0
71 // full slope propagation prop = 1
72 // 1-stage slope propagation prop = 2
74 res_path
= ttv_CharacPaths (fig
, slope
, start_name
, end_name
, tran
, 1, "critic", "path", max
, load
, prop
);
75 pt_res_path
= (ttvpath_list
*)res_path
->DATA
;
77 delay
= ttv_GetPathRefDelay (pt_res_path
);
80 /* -------------------------------------------------------------------------------------------------- */
81 /* -------------------------------------------------------------------------------------------------- */
82 /* -------------------------------------------------------------------------------------------------- */
84 chain_list
*Global_Prop (ttvfig_list
*fig
, float *slope_tab
, float *load_tab
, ttvpath_list
*path
, char *max
, int nb_slope
, int nb_load
)
89 for (i
= 0; i
< nb_slope
; i
++)
90 for (j
= 0; j
< nb_load
; j
++) {
91 delay
= Compute_Delay (fig
, slope_tab
[i
], load_tab
[j
], path
, max
);
92 fprintf (stdout
, "delay (%g, %g) = %g\n", slope_tab
[i
], load_tab
[j
], delay
);
97 /* -------------------------------------------------------------------------------------------------- */
98 /* -------------------------------------------------------------------------------------------------- */
99 /* -------------------------------------------------------------------------------------------------- */
101 chain_list
**extractSetupHold (float *slope_tab
, int nb_slope
, ttvfig_list
*fig
, char *clock
, char *pin
, char *mode
)
106 /* -------------------------------------------------------------------------------------------------- */
108 chain_list
**extractAccess (float *slope_tab
, float *load_tab
, int nb_slope
, int nb_load
, ttvfig_list
*fig
, char *clock
, char *pin
, char *mode
, char *minmax
)
113 /* -------------------------------------------------------------------------------------------------- */
115 chain_list
**extractPropDelay (float *slope_tab
, float *load_tab
, int nb_slope
, int nb_load
, ttvfig_list
*fig
, char *input
, char *output
, char *mode
, char *minmax
)
117 chain_list
*prop_rr
= NULL
,
121 chain_list
*prop_list
;
122 ttvpath_list
*pt_path
;
123 chain_list
*path
, *path_list
;
124 ttvsig_list
*start_sig
, *end_sig
;
125 char start_tran
, end_tran
;
126 chain_list
**clist
= (chain_list
**)malloc (4 * sizeof (chain_list
*));
128 if (!strcmp (minmax
, "max"))
129 path_list
= ttv_GetPaths (fig
, input
, output
, "??", 1000, "critic", "path", "max");
131 path_list
= ttv_GetPaths (fig
, input
, output
, "??", 1000, "critic", "path", "min");
133 for (path
= path_list
; path
; path
= path
->NEXT
) {
134 pt_path
= (ttvpath_list
*)path
->DATA
;
135 start_sig
= ttv_GetPathStartSignal (pt_path
);
136 end_sig
= ttv_GetPathEndSignal (pt_path
);
137 start_tran
= ttv_GetPathStartDirection (pt_path
);
138 end_tran
= ttv_GetPathEndDirection (pt_path
);
140 prop_list
= Global_Prop (fig
, slope_tab
, load_tab
, pt_path
, minmax
, nb_slope
, nb_load
);
142 if (start_tran
== 'u') {
143 if (end_tran
== 'u') prop_rr
= prop_list
;
144 if (end_tran
== 'd') prop_rf
= prop_list
;
145 } else if (start_tran
== 'd') {
146 if (end_tran
== 'u') prop_fr
= prop_list
;
147 if (end_tran
== 'd') prop_ff
= prop_list
;
159 /* -------------------------------------------------------------------------------------------------- */
160 /* -------------------------------------------------------------------------------------------------- */
161 /* -------------------------------------------------------------------------------------------------- */
163 void tma_addSetupHold (float *slope_tab
, int nb_slope
, ttvfig_list
*fig
, ttvfig_list
*bb
, char *clock
, char *input
, char *mode
)
165 chain_list
**clist
= NULL
;
166 chain_list
*su_rr
= NULL
,
175 fprintf (stdout
, "SETUP/HOLD %s -> %s\n", clock
, input
);
177 if ((clist
= extractSetupHold (slope_tab
, nb_slope
, fig
, clock
, input
, mode
))) {
188 if (su_rr
) freechain (su_rr
);
189 if (su_rf
) freechain (su_rf
);
190 if (ho_rr
) freechain (ho_rr
);
191 if (ho_rf
) freechain (ho_rf
);
192 if (su_fr
) freechain (su_fr
);
193 if (su_ff
) freechain (su_ff
);
194 if (ho_fr
) freechain (ho_fr
);
195 if (ho_ff
) freechain (ho_ff
);
197 if (clist
) free (clist
);
200 /* -------------------------------------------------------------------------------------------------- */
202 void tma_addPropDelay (float *slope_tab
, float *load_tab
, int nb_slope
, int nb_load
, ttvfig_list
*fig
, ttvfig_list
*bb
, char *input
, char *output
, char *mode
)
204 chain_list
**clist
= NULL
;
205 chain_list
*prop_rr_min
= NULL
,
209 chain_list
*prop_rr_max
= NULL
,
214 fprintf (stdout
, "PROP %s -> %s\n", input
, output
);
216 if ((clist
= extractPropDelay (slope_tab
, load_tab
, nb_slope
, nb_load
, fig
, input
, output
, mode
, "min"))) {
217 prop_rr_min
= clist
[0];
218 prop_rf_min
= clist
[1];
219 prop_fr_min
= clist
[2];
220 prop_ff_min
= clist
[3];
223 if ((clist
= extractPropDelay (slope_tab
, load_tab
, nb_slope
, nb_load
, fig
, input
, output
, mode
, "max"))) {
224 prop_rr_max
= clist
[0];
225 prop_rf_max
= clist
[1];
226 prop_fr_max
= clist
[2];
227 prop_ff_max
= clist
[3];
230 if (prop_rr_min
) freechain (prop_rr_min
);
231 if (prop_rf_min
) freechain (prop_rf_min
);
232 if (prop_fr_min
) freechain (prop_fr_min
);
233 if (prop_ff_min
) freechain (prop_ff_min
);
234 if (prop_rr_max
) freechain (prop_rr_max
);
235 if (prop_rf_max
) freechain (prop_rf_max
);
236 if (prop_fr_max
) freechain (prop_fr_max
);
237 if (prop_ff_max
) freechain (prop_ff_max
);
239 if (clist
) free (clist
);
242 /* -------------------------------------------------------------------------------------------------- */
244 void tma_addAccess (float *slope_tab
, float *load_tab
, int nb_slope
, int nb_load
, ttvfig_list
*fig
, ttvfig_list
*bb
, char *clock
, char *output
, char *mode
)
246 chain_list
**clist
= NULL
;
247 chain_list
*acs_rr_min
= NULL
,
251 chain_list
*acs_rr_max
= NULL
,
256 fprintf (stdout
, "ACCESS %s -> %s\n", clock
, output
);
258 if ((clist
= extractAccess (slope_tab
, load_tab
, nb_slope
, nb_load
, fig
, clock
, output
, mode
, "min"))) {
259 acs_rr_min
= clist
[0];
260 acs_rf_min
= clist
[1];
261 acs_fr_min
= clist
[2];
262 acs_ff_min
= clist
[3];
265 if ((clist
= extractAccess (slope_tab
, load_tab
, nb_slope
, nb_load
, fig
, clock
, output
, mode
, "max"))) {
266 acs_rr_max
= clist
[0];
267 acs_rf_max
= clist
[1];
268 acs_fr_max
= clist
[2];
269 acs_ff_max
= clist
[3];
272 if (acs_rr_min
) freechain (acs_rr_min
);
273 if (acs_rf_min
) freechain (acs_rf_min
);
274 if (acs_fr_min
) freechain (acs_fr_min
);
275 if (acs_ff_min
) freechain (acs_ff_min
);
276 if (acs_rr_max
) freechain (acs_rr_max
);
277 if (acs_rf_max
) freechain (acs_rf_max
);
278 if (acs_fr_max
) freechain (acs_fr_max
);
279 if (acs_ff_max
) freechain (acs_ff_max
);
281 if (clist
) free (clist
);
284 /* -------------------------------------------------------------------------------------------------- */
285 /* -------------------------------------------------------------------------------------------------- */
286 /* -------------------------------------------------------------------------------------------------- */
287 ttvfig_list
*tma_APIBlackBox (ttvfig_list
*fig
, char *suffix
)
289 int verbose
= V_BOOL_TAB
[__TMA_VERBOSE
].VALUE
;
290 stbfig_list
*stbfig
= NULL
;
292 char dir
, *name
, *figname
, *bbname
;
293 chain_list
*pin_list
, *pin
,
297 chain_list
*input
, *output
, *clock
;
298 float slope_unit
, cap_unit
;
300 float *slope_tab
, *load_tab
;
301 int nb_slope
, nb_load
;
302 ttvfig_list
*blackbox
;
304 /* CONFIG REQUIRED HERE */
309 slope_tab
= (float*)malloc (nb_slope
* sizeof (float));
310 load_tab
= (float*)malloc (nb_load
* sizeof (float));
311 load_tab
[0] = 10 * cap_unit
;
312 load_tab
[1] = 50 * cap_unit
;
313 load_tab
[2] = 100 * cap_unit
;
314 slope_tab
[0] = 100 * slope_unit
;
315 slope_tab
[1] = 200 * slope_unit
;
316 slope_tab
[2] = 300 * slope_unit
;
317 clock_list
= addchain (clock_list
, (void*)"ck");
319 if (!fig
) return NULL
;
321 stbfig
= stb_getstbfig(fig
);
323 figname
= fig
->INFO
->FIGNAME
;
325 avt_log( LOGTMA
, 1, "timing figure is %s\n", figname
);
328 sprintf (buf
, "%s_%s", figname
, suffix
);
329 bbname
= namealloc (buf
);
333 blackbox
= tma_DupTtvFigHeader (bbname
, fig
, "*");
334 stm_addcell (bbname
);
335 tma_DupConnectorList (blackbox
, fig
);
337 pin_list
= ttv_GetTimingSignalList (blackbox
, "connector", "interface");
338 for (pin
= pin_list
; pin
; pin
= pin
->NEXT
) {
339 pt_pin
= (ttvsig_list
*)(pin
->DATA
);
340 dir
= ttv_GetConnectorDirection (pt_pin
);
342 name
= ttv_GetSignalName (pt_pin
);
343 input_list
= addchain (input_list
, name
);
345 if (dir
== 'o' || dir
== 'b' || dir
== 't' || dir
== 'z') {
346 name
= ttv_GetSignalName (pt_pin
);
347 output_list
= addchain (output_list
, name
);
351 for (input
= input_list
; input
; input
= input
->NEXT
) {
352 for (clock
= clock_list
; clock
; clock
= clock
->NEXT
)
353 tma_addSetupHold (slope_tab
, nb_slope
, fig
, blackbox
, (char*)clock
->DATA
, (char*)input
->DATA
, "debug");
355 for (output
= output_list
; output
; output
= output
->NEXT
)
356 tma_addPropDelay (slope_tab
, load_tab
, nb_slope
, nb_load
, fig
, blackbox
, (char*)input
->DATA
, (char*)output
->DATA
, "debug");
359 for (output
= output_list
; output
; output
= output
->NEXT
)
360 for (clock
= clock_list
; clock
; clock
= clock
->NEXT
)
361 tma_addAccess (slope_tab
, load_tab
, nb_slope
, nb_load
, fig
, blackbox
, (char*)clock
->DATA
, (char*)output
->DATA
, "debug");
363 freechain (clock_list
);
364 freechain (input_list
);
365 freechain (output_list
);
372 void tma_SetMaxCapacitance(ttvfig_list
*bbox
, char *name
, double value
)
378 if ((cl
=ttv_GetMatchingSignal(bbox
, name
, "connector"))==NULL
)
379 avt_errmsg(TMA_API_ERRMSG
, "002", AVT_WARNING
, name
);
383 tvs
=(chain_list
*)cl
->DATA
;
384 if ((pt
=getptype(tvs
->USER
, LIB_MAX_CAPACITANCE
))==NULL
)
385 pt
=tvs
->USER
=addptype(tvs
->USER
, LIB_MAX_CAPACITANCE
, NULL
);
386 *(float *)&pt
->DATA
=value
;