10 lofig_list
*avt_GetNetlist(char *name
)
12 lofig_list
*fig
= getloadedlofig(name
);
13 float max_global_supply
;
16 avt_errmsg(AVT_API_ERRMSG
, "001", AVT_WARNING
, name
);
17 // fprintf (stdout, "ERROR: '%s' is not among the loaded netlists\n", name);
21 if (V_FLOAT_TAB
[__SIM_POWER_SUPPLY
].SET
==0 && mbk_GetPowerSupply (fig
, &max_global_supply
))
22 MCC_VDDmax
= V_FLOAT_TAB
[__SIM_POWER_SUPPLY
].VALUE
= V_FLOAT_TAB
[__SIM_POWER_SUPPLY
].VALUE
= elpGeneral
[elpGVDDMAX
] = max_global_supply
;
27 void avt_DriveNetlist(lofig_list
*lf
, char *filename
, char *format
)
34 if (strcasecmp(format
,"spice")==0)
36 if ((f
=mbkfopen(filename
,NULL
,WRITE_TEXT
))!=NULL
)
38 spicesavelofiginfile(lf
, f
, 0);
43 else if (strcasecmp(format
,"verilog")==0)
45 if ((f
=mbkfopen(filename
,NULL
,WRITE_TEXT
))!=NULL
)
52 else if (strcasecmp(format
,"vhdl")==0)
54 if ((f
=mbkfopen(filename
,NULL
,WRITE_TEXT
))!=NULL
)
61 else if (strcasecmp(format
,"spef")==0)
63 if ((f
=mbkfopen(filename
,NULL
,WRITE_TEXT
))!=NULL
)
71 avt_errmsg(AVT_API_ERRMSG
, "002", AVT_ERROR
, format
, filename
);
72 // avt_error("avtapi", 2, AVT_ERROR, "unknown file format '%s' for '%s'\n", format, filename);
75 avt_errmsg(AVT_API_ERRMSG
, "003", AVT_ERROR
, filename
);
76 // avt_error("avtapi", 2, AVT_ERROR, "could not create file '%s'\n", filename);
79 void avt_DriveSignalInfo( lofig_list
*lf
, char *nameregex
, char *filename
)
88 chain_list
*chnodename
;
91 char s1
[256], s2
[256] ;
100 ptf
= mbkfopen( filename
, NULL
, WRITE_TEXT
);
102 avt_errmsg(AVT_API_ERRMSG
, "003", AVT_ERROR
, filename
);
103 //avt_error("avtapi", 2, AVT_ERROR, "could not create file '%s'\n", filename);
107 for( losig
= lf
->LOSIG
; losig
; losig
= losig
->NEXT
) {
109 for( chain
= losig
->NAMECHAIN
; chain
; chain
= chain
->NEXT
) {
110 if( mbk_TestREGEX( (char*)chain
->DATA
, nameregex
) )
116 if( needsepar
== 'y' ) {
117 fprintf( ptf
, "\n-------------------------------------------------\n\n" );
121 fprintf( ptf
, "Signal %s\n\n", getsigname( losig
) );
123 ptl
= getptype( losig
->USER
, LOFIGCHAIN
);
125 fprintf( ptf
, "Connector list :\n\n" );
126 for( chlocon
= (chain_list
*)ptl
->DATA
; chlocon
; chlocon
= chlocon
->NEXT
) {
127 locon
= (locon_list
*)chlocon
->DATA
;
128 switch( locon
->TYPE
) {
130 fprintf( ptf
, "instance %s", ((loins_list
*)locon
->ROOT
)->INSNAME
);
133 fprintf( ptf
, "external" );
136 fprintf( ptf
, "transistor %s", ((lotrs_list
*)locon
->ROOT
)->TRNAME
);
139 fprintf( ptf
, "unknown" );
141 fprintf( ptf
, " -> %s\n", locon
->NAME
);
143 ptl
= getptype( locon
->USER
, PNODENAME
);
145 chnodename
= (chain_list
*)ptl
->DATA
;
149 for( node
= locon
->PNODE
; node
; node
= node
->NEXT
) {
151 name
= (char*)chnodename
->DATA
;
154 fprintf( ptf
, " %ld %s\n", node
->DATA
, name
);
156 chnodename
= chnodename
->NEXT
;
159 fprintf( ptf
, "\n" );
162 fprintf( ptf
, "No connector on this signal\n\n" );
167 for( wire
= losig
->PRCN
->PWIRE
; wire
; wire
= wire
->NEXT
) {
168 ptnode
= getlonode( losig
, wire
->NODE1
);
169 if( RCN_GETFLAG( ptnode
->FLAG
, RCN_FLAG_LOCON
) )
170 sprintf( s1
, "%4ld*", ptnode
->INDEX
);
172 sprintf( s1
, "%4ld ", ptnode
->INDEX
);
173 ptnode
= getlonode( losig
, wire
->NODE2
);
174 if( RCN_GETFLAG( ptnode
->FLAG
, RCN_FLAG_LOCON
) )
175 sprintf( s2
, "%4ld*", ptnode
->INDEX
);
177 sprintf( s2
, "%4ld ", ptnode
->INDEX
);
178 fprintf( ptf
, "w %s %s %g\n", s1
, s2
, wire
->RESI
);
180 fprintf( ptf
, "\n" );
182 for( chctc
= losig
->PRCN
->PCTC
; chctc
; chctc
= chctc
->NEXT
) {
183 ctc
= (loctc_list
*)chctc
->DATA
;
184 ptnode
= getlonode( losig
, rcn_ctcnode( ctc
, losig
) );
185 if( RCN_GETFLAG( ptnode
->FLAG
, RCN_FLAG_LOCON
) )
186 sprintf( s1
, "%4ld*", ptnode
->INDEX
);
188 sprintf( s1
, "%4ld ", ptnode
->INDEX
);
189 fprintf( ptf
, "c %s %g\n", s1
, ctc
->CAPA
);
198 void avt_RemoveCapacitances(lofig_list
*lf
, char *nameregex
)
203 if (lf
==NULL
) return;
205 for (ls
=lf
->LOSIG
; ls
!=NULL
; ls
=ls
->NEXT
)
207 if (ls
->PRCN
==NULL
) continue;
209 if (ls
->PRCN
->PCTC
==NULL
) continue;
211 for (cl
=ls
->NAMECHAIN
; cl
!=NULL
; cl
=cl
->NEXT
)
212 if (mbk_TestREGEX((char *)cl
->DATA
, nameregex
)) break;
216 while( ls
->PRCN
->PCTC
)
217 delloctc( (loctc_list
*)ls
->PRCN
->PCTC
->DATA
);
219 rcn_mergectclosig(ls
);
224 void avt_RemoveResistances(lofig_list
*lf
, char *nameregex
)
232 if (lf
==NULL
) return;
234 for (ls
=lf
->LOSIG
; ls
!=NULL
; ls
=ls
->NEXT
)
236 if (ls
->PRCN
==NULL
) continue;
237 if (ls
->PRCN
->PWIRE
==NULL
) { rcn_mergectclosig(ls
); continue; }
239 for (cl
=ls
->NAMECHAIN
; cl
!=NULL
; cl
=cl
->NEXT
)
240 if (mbk_TestREGEX((char *)cl
->DATA
, nameregex
)) break;
244 while( ls
->PRCN
->PWIRE
)
245 dellowire(ls
, ls
->PRCN
->PWIRE
->NODE1
, ls
->PRCN
->PWIRE
->NODE2
);
247 for (cl
=ls
->PRCN
->PCTC
; cl
!=NULL
; cl
=cl
->NEXT
)
249 lctc
=(loctc_list
*)cl
->DATA
;
256 if ((pt
=getptype(ls
->USER
, LOFIGCHAIN
))!=NULL
) cl
=(chain_list
*)pt
->DATA
;
261 for (ln
=((locon_list
*)cl
->DATA
)->PNODE
; ln
!=NULL
; ln
=ln
->NEXT
)
267 rcn_mergectclosig(ls
);
272 void avt_FlattenNetlist(lofig_list
*lf
, char *level
)
274 eqt_ctx
*mc_ctx
=NULL
;
275 if (lf
==NULL
) return;
276 flatten_parameters (lf
, NULL
, NULL
, 0, 0, 0, 0, 0, 0, &mc_ctx
);
277 if (mc_ctx
!=NULL
) eqt_term(mc_ctx
);
279 if (strcasecmp(level
,"transistors")==0 || strcasecmp(level
,"trs")==0)
280 rflattenlofig (lf
, YES
, NO
);
281 else if (strcasecmp(level
,"catalog")==0 || strcasecmp(level
,"catal")==0)
282 rflattenlofig (lf
, YES
, YES
);
283 else if (strcasecmp(level
,"blackbox")==0 || strcasecmp(level
,"bbox")==0)
284 flatOutsideList (lf
);
286 flattenlofig (lf
, level
, YES
);
289 void avt_ViewNetlist(char *name
)
292 if ((lf
=getloadedlofig(name
))!=NULL
)
296 void avt_ViewSignal(char *name
, char *signal
)
300 if ((lf
=getloadedlofig(name
))!=NULL
)
301 if ((ls
=mbk_quickly_getlosigbyname(lf
, signal
))!=NULL
)
303 rcn_flush_signal(lf
, ls
);
304 rcn_refresh_signal( lf
, ls
);
309 void avt_RemoveNetlist(char *name
)
312 if ((lf
=getloadedlofig(name
))!=NULL
)
317 void avt_SetBlackBoxes(chain_list
*cl
)
331 static chain_list
*disphier(lofig_list
*lf
, char *figname
, char *pad
, int count
, stat_result
*tot
, int maxdepth
, int depth
, char *insnamestr
)
340 chain_list
*lst
=NULL
, *cl
;
348 sr
.tot_trans
=sr
.tot_capa
=sr
.tot_resi
=sr
.tot_sig
=sr
.tot_inst
=0;
355 for (li
=lf
->LOINS
; li
!=NULL
&& gethtitem(tab
,li
->FIGNAME
)!=EMPTYHT
; li
=li
->NEXT
) ;
358 addhtitem(tab
, li
->FIGNAME
, 1);
365 if (li
->FIGNAME
==model
)
367 inslist
= addchain(inslist
, li
->INSNAME
);
368 len
+= strlen(li
->INSNAME
);
373 inslist
= reverse(inslist
);
374 newinsnamestr
= mbkalloc(len
+ cnti
+ 1);
375 newinsnamestr
[0] = 0;
376 for (ptchain
= inslist
; ptchain
; ptchain
= ptchain
->NEXT
)
378 strcat(newinsnamestr
, (char *)ptchain
->DATA
);
379 strcat(newinsnamestr
, ",");
381 newinsnamestr
[len
+cnti
-1] = 0;
384 lst
=append(disphier(getloadedlofig(model
), model
, pad
, cnti
, tot
, maxdepth
, depth
+1, newinsnamestr
), lst
);
385 mbkfree(newinsnamestr
);
386 sr
.tot_trans
+=tot
->tot_trans
*cnti
;
387 sr
.tot_capa
+=tot
->tot_capa
*cnti
;
388 sr
.tot_resi
+=tot
->tot_resi
*cnti
;
389 sr
.tot_sig
+=tot
->tot_sig
*cnti
;
390 sr
.tot_inst
+=tot
->tot_inst
*cnti
;
391 pad
[strlen(pad
)-2]='\0';
396 sr
.tot_trans
+=(lsr
.tot_trans
=countchain((chain_list
*)lf
->LOTRS
));
397 sr
.tot_sig
+=(lsr
.tot_sig
=countchain((chain_list
*)lf
->LOSIG
));
398 sr
.tot_inst
+=(lsr
.tot_inst
=countchain((chain_list
*)lf
->LOINS
));
400 lsr
.tot_resi
=lsr
.tot_capa
=0;
401 for (ls
=lf
->LOSIG
; ls
!=NULL
; ls
=ls
->NEXT
)
405 lsr
.tot_resi
+=countchain((chain_list
*)ls
->PRCN
->PWIRE
);
406 sr
.tot_resi
+=countchain((chain_list
*)ls
->PRCN
->PWIRE
);
407 if (ls
->PRCN
->PCTC
!=NULL
)
409 for (cl
=ls
->PRCN
->PCTC
; cl
!=NULL
; cl
=cl
->NEXT
)
411 lcl
=(loctc_list
*)cl
->DATA
;
412 if (lcl
->SIG1
<lcl
->SIG2
)
424 lsr
.tot_trans
=lsr
.tot_capa
=lsr
.tot_resi
=lsr
.tot_sig
=lsr
.tot_inst
=0;
427 memcpy(tot
, &sr
, sizeof(stat_result
));
428 if (depth
+1<=maxdepth
)
432 buf
= mbkalloc(strlen(insnamestr
) + 1024);
433 sprintf(buf
,"%s(%d) %s (%s) global(%d trs, %d ins, %d resi, %d capa, %d sig) local(%d trs, %d ins, %d resi, %d capa, %d sig)",pad
,count
,figname
, insnamestr
, sr
.tot_trans
, sr
.tot_inst
, sr
.tot_resi
, sr
.tot_capa
, sr
.tot_sig
, lsr
.tot_trans
, lsr
.tot_inst
, lsr
.tot_resi
, lsr
.tot_capa
, lsr
.tot_sig
);
437 buf
= mbkalloc(1024);
438 sprintf(buf
,"%s(%d) %s global(%d trs, %d ins, %d resi, %d capa, %d sig) local(%d trs, %d ins, %d resi, %d capa, %d sig)",pad
,count
,figname
, sr
.tot_trans
, sr
.tot_inst
, sr
.tot_resi
, sr
.tot_capa
, sr
.tot_sig
, lsr
.tot_trans
, lsr
.tot_inst
, lsr
.tot_resi
, lsr
.tot_capa
, lsr
.tot_sig
);
440 lst
=append(addchain(NULL
, strdup(buf
)), lst
);
447 void avt_DisplayNetlistHierarchy(FILE *f
, char *netlistname
, int maxdepth
)
454 if ((lf
=avt_GetNetlist(netlistname
))==NULL
) return;
457 if (maxdepth
<=0) maxdepth
=10000000;
458 lst
=disphier(lf
, lf
->NAME
, pad
, 1, &sr
, maxdepth
, 0, NULL
);
461 fprintf(f
, "%s\n", (char *)lst
->DATA
);
463 lst
=delchain(lst
, lst
);
467 #define COL_RESI_NAME 0
468 #define COL_RESI_VAL 1
469 #define COL_RESI_NODE 2
471 void avt_DisplayResistivePath(FILE *f
, lofig_list
*lf
, char *connector1
, char *connector2
)
474 chain_list
*phinterf
=NULL
, *realinterf
=NULL
, *cl
, *ch
;
478 char *con
[2], *net
[2]={NULL
, NULL
};
479 long num
[2]={-1, -1}, cnt
;
483 con
[0]=mbk_decodeanyvector(connector1
);
484 con
[1]=mbk_decodeanyvector(connector2
);
485 if ((pt
=getptype(lf
->USER
, PH_INTERF
))!=NULL
) phinterf
=(chain_list
*)pt
->DATA
;
486 if ((pt
=getptype(lf
->USER
, PH_REAL_INTERF
))!=NULL
) realinterf
=(chain_list
*)pt
->DATA
;
488 if (countchain(phinterf
)==countchain(realinterf
))
492 for (cl
=realinterf
, ch
=phinterf
; cl
!=NULL
&& cl
->DATA
!=con
[i
]; cl
=cl
->NEXT
, ch
=ch
->NEXT
) ;
496 for (cl
=phinterf
, cnt
=0; cl
!=ch
; cl
=cl
->NEXT
)
497 if (cl
->DATA
==net
[i
]) cnt
++;
499 for (lc
=lf
->LOCON
; lc
!=NULL
&& lc
->NAME
!=net
[i
]; lc
=lc
->NEXT
) ;
503 for (nm
=lc
->PNODE
; nm
!=NULL
&& cnt
>0; nm
=nm
->NEXT
, cnt
--) ;
512 avt_errmsg(AVT_API_ERRMSG
, "004", AVT_ERROR
, con
[i
]);
516 if (net
[0]!=NULL
&& num
[0]==-1)
517 avt_errmsg(AVT_API_ERRMSG
, "005", AVT_ERROR
, con
[0]);
518 if (net
[1]!=NULL
&& num
[1]==-1)
519 avt_errmsg(AVT_API_ERRMSG
, "005", AVT_ERROR
, con
[1]);
522 if (net
[0]==net
[1] && num
[0]!=-1 && num
[1]!=-1)
526 rcn_flush_signal(lf
, sig
);
527 rcn_refresh_signal( lf
, sig
);
528 cl
=rcn_get_a_r_way(sig
, num
[0], num
[1]);
532 b
=Board_CreateBoard();
533 Board_SetSize(b
, COL_RESI_NAME
, 20, 'l');
534 Board_SetSize(b
, COL_RESI_VAL
, 10, 'r');
535 Board_SetSize(b
, COL_RESI_NODE
, 10, 'l');
537 Board_SetValue(b
, COL_RESI_NAME
, "Resistor Name");
538 Board_SetValue(b
, COL_RESI_VAL
, "Value");
539 Board_SetValue(b
, COL_RESI_NODE
, "Node");
540 Board_NewSeparation(b
);
542 sprintf(buf
,"[%ld] %s", num
[0], con
[0]);
543 Board_SetValue(b
, COL_RESI_NODE
, buf
);
548 lw
=(lowire_list
*)cl
->DATA
;
549 if (lw
->NODE1
!=a
) nb
=lw
->NODE1
; else nb
=lw
->NODE2
;
553 if ((pt
=getptype(lw
->USER
, RESINAME
))!=NULL
)
554 Board_SetValue(b
, COL_RESI_NAME
, (char *)pt
->DATA
);
557 sprintf(buf
,"[%ld] %s", num
[1], con
[1]);
559 sprintf(buf
,"[%ld]", nb
);
561 Board_SetValue(b
, COL_RESI_NODE
, buf
);
562 sprintf(buf
,"%.1f", lw
->RESI
);
563 Board_SetValue(b
, COL_RESI_VAL
, buf
);
567 Board_NewSeparation(b
);
568 avt_fprintf(f
, " *** Resistive path beetween connector '%s' and '%s'\n\n", con
[0], con
[1]);
570 Board_Display(f
, b
, "");
573 avt_fprintf(f
, "\n");
579 fprintf(f
, " *** No resistive path found beetween connector '%s' and '%s'\n", con
[0], con
[1]);