2 * This file is part of the Alliance CAD System
3 * Copyright (C) Laboratoire LIP6 - Département ASIM
4 * Universite Pierre et Marie Curie
6 * Home page : http://www-asim.lip6.fr/alliance/
7 * E-mail support : mailto:alliance-support@asim.lip6.fr
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Library General Public License as published
11 * by the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * Alliance VLSI CAD System is distributed in the hope that it will be
15 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with the GNU C Library; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Purpose : acces functions to logical structures
27 * Author : Frederic Petrot <Frederic.Petrot@lip6.fr>
28 * Modified by Czo <Olivier.Sirol@lip6.fr> 1997,98
29 * Modified by <Gregoire.Avot@lip6.fr> 1997,98
32 #ident "$Id: mbk_lo.c,v 1.108 2009/05/20 12:22:03 fabrice Exp $"
50 //#define MBK_TRACE_BAD_PTYPE
52 /*******************************************************************************
53 * global variable for netlist view *
54 *******************************************************************************/
55 lofig_list
*HEAD_LOFIG
; /* physical figure list head */
57 voidt
*VT_MODNAMEINDEX
= NULL
;
58 ht
*HT_MODINDEXNAME
= NULL
;
59 char *TN_MODEL_NAME
= NULL
;
60 char *TP_MODEL_NAME
= NULL
;
64 void mbk_init_NewBKSIG(NewBKSIG
*bksig
)
70 void mbk_free_NewBKSIG(NewBKSIG
*bksig
)
72 if (bksig
->TAB
!=NULL
) FreeAdvancedTableAllocator((AdvancedTableAllocator
*)bksig
->TAB
);
76 losig_list
*mbk_NewBKSIG_getindex(lofig_list
*ptfig
, int index
)
79 AdvancedTableAllocator
*ata
;
81 if (ptfig
->BKSIG
.TAB
==NULL
)
83 sigsize
= getsigsize( ptfig
);
84 ptfig
->BKSIG
.TAB
=CreateAdvancedTableAllocator(sigsize
, sizeof(losig_list
));
85 ata
=(AdvancedTableAllocator
*)ptfig
->BKSIG
.TAB
;
88 else ata
=(AdvancedTableAllocator
*)ptfig
->BKSIG
.TAB
;
90 if (index
>ptfig
->BKSIG
.maxindex
) ptfig
->BKSIG
.maxindex
=index
;
91 return (losig_list
*)GetAdvancedTableElem(ata
, index
);
94 /*******************************************************************************
95 * function delalllofig() *
96 *******************************************************************************/
102 for( lofig
= HEAD_LOFIG
; lofig
; lofig
= next
) {
104 dellofig( lofig
->NAME
);
108 /*******************************************************************************
109 * function addlofig() *
110 *******************************************************************************/
111 lofig_list
*addlofig(name
)
116 if (HT_LOFIG
== NULL
) {
117 HT_LOFIG
= addht(50);
119 name
= namealloc(name
);
120 /* scan figure list */
121 ptfig
= (lofig_list
*)gethtitem(HT_LOFIG
, name
);
122 if (ptfig
== (lofig_list
*)EMPTYHT
) ptfig
= NULL
;
123 else if (ptfig
== (lofig_list
*)DELETEHT
) {
125 while (ptfig
!= NULL
&& ptfig
->NAME
!= name
)
129 if (ptfig
!= NULL
) /* figure exists */
130 avt_errmsg (MBK_ERRMSG
, "020", AVT_FATAL
, name
);
132 ptfig
= (lofig_list
*)mbkalloc(sizeof(lofig_list
));
135 ptfig
->MODELCHAIN
= NULL
;
140 mbk_init_NewBKSIG(&ptfig
->BKSIG
);
142 ptfig
->NEXT
= HEAD_LOFIG
;
145 if (TRACE_MODE
== 'Y')
146 (void)fprintf(stdout
, "--- mbk --- addlofig : %s\n", name
);
148 addhtitem(HT_LOFIG
, name
, (long)ptfig
);
152 /*******************************************************************************
153 * function addlomodel() *
154 * used by the parsers to construct a temporary model *
155 *******************************************************************************/
156 lofig_list
*addlomodel(model
, name
)
162 name
= namealloc(name
);
163 /* check to see if the model has already been loaded */
164 if(FAST_MODE
!= 'Y') {
165 for (fig
= model
; fig
&& fig
->NAME
!= name
; fig
= fig
->NEXT
);
167 if (fig
) /* figure exists */
168 avt_errmsg (MBK_ERRMSG
, "021", AVT_FATAL
, name
);
171 fig
= (lofig_list
*)mbkalloc(sizeof(lofig_list
));
174 fig
->MODELCHAIN
= NULL
;
179 mbk_init_NewBKSIG(&fig
->BKSIG
);
184 if (TRACE_MODE
== 'Y')
185 (void)fprintf(stdout
, "--- mbk --- addlomodel : %s\n", name
);
190 /*******************************************************************************
191 * function getloadedlofig() *
192 *******************************************************************************/
193 lofig_list
*getloadedlofig(figname
)
198 figname
= namealloc(figname
);
199 if (HT_LOFIG
== NULL
) {
200 HT_LOFIG
= addht(50);
203 /* scan figure list */
204 ptfig
= (lofig_list
*)gethtitem(HT_LOFIG
, figname
);
205 if (ptfig
== (lofig_list
*)EMPTYHT
) ptfig
= NULL
;
206 else if (ptfig
== (lofig_list
*)DELETEHT
) {
208 while (ptfig
!= NULL
&& ptfig
->NAME
!= figname
)
214 /*******************************************************************************
215 * function addlofigparam() *
216 *******************************************************************************/
218 addlofigparam(lofig_list
*ptlofig
, char *param
, float value
, char *expr
)
220 optparam_list
*newparam
;
223 ptuser
= getptype(ptlofig
->USER
, OPT_PARAMS
);
224 if (ptuser
== NULL
) {
225 newparam
= addoptparam(NULL
, param
, value
, expr
);
226 ptlofig
->USER
= addptype(ptlofig
->USER
, OPT_PARAMS
, newparam
);
229 newparam
= addoptparam((optparam_list
*)ptuser
->DATA
, param
, value
, expr
);
230 ptuser
->DATA
= newparam
;
234 /*******************************************************************************
235 * function getlofigparam() *
236 *******************************************************************************/
238 getlofigparam(lofig_list
*ptlofig
, void *param
, char **expr
, int *status
)
242 ptuser
= getptype(ptlofig
->USER
, OPT_PARAMS
);
243 if (ptuser
!= NULL
) {
244 return getoptparam((optparam_list
*)ptuser
->DATA
, param
, expr
, status
);
247 if (expr
) *expr
= NULL
;
248 if (status
) *status
= 0;
252 /*******************************************************************************
253 * function freelofigparams() *
254 *******************************************************************************/
256 freelofigparams(lofig_list
*ptlofig
)
260 ptuser
= getptype(ptlofig
->USER
, OPT_PARAMS
);
261 if (ptuser
!= NULL
) {
262 freeoptparams((optparam_list
*)ptuser
->DATA
);
263 ptlofig
->USER
= delptype(ptlofig
->USER
, OPT_PARAMS
);
267 /*******************************************************************************
268 * function addlotrs() *
269 *******************************************************************************/
270 lotrs_list
*addlotrs(ptfig
, type
, x
, y
, width
, length
, ps
, pd
, xs
, xd
, ptgrid
,
271 ptsource
, ptdrain
, ptbulk
, name
)
275 long width
, length
, ps
, pd
, xs
, xd
;
276 losig_list
*ptgrid
, *ptsource
, *ptdrain
, *ptbulk
;
282 if (name
!=NULL
) name
= namealloc( name
);
284 if (!MLO_IS_TRANSN(type
) && !MLO_IS_TRANSP(type
))
285 avt_errmsg (MBK_ERRMSG
, "022", AVT_FATAL
, (long)type
);
287 pttrs
= (lotrs_list
*)mbkalloc(sizeof(lotrs_list
));
290 pttrs
->WIDTH
= width
;
291 pttrs
->LENGTH
= length
;
292 pttrs
->MODINDEX
= EMPTYHT
;
298 pttrs
->NEXT
= ptfig
->LOTRS
;
299 ptfig
->LOTRS
= pttrs
;
302 ptcon
= (locon_list
*)mbkalloc(sizeof(locon_list
));
303 ptcon
->NAME
= namealloc("grid");
305 ptcon
->ROOT
= (void *)pttrs
;
307 ptcon
->DIRECTION
= 'I';
312 ptcon
= (locon_list
*)mbkalloc(sizeof(locon_list
));
313 ptcon
->NAME
= namealloc("drain");
314 ptcon
->SIG
= ptdrain
;
315 ptcon
->ROOT
= (void *)pttrs
;
317 ptcon
->DIRECTION
= 'I';
320 pttrs
->DRAIN
= ptcon
;
322 ptcon
= (locon_list
*)mbkalloc(sizeof(locon_list
));
323 ptcon
->NAME
= namealloc("source");
324 ptcon
->SIG
= ptsource
;
325 ptcon
->ROOT
= (void *)pttrs
;
327 ptcon
->DIRECTION
= 'I';
330 pttrs
->SOURCE
= ptcon
;
332 ptcon
= (locon_list
*)mbkalloc(sizeof(locon_list
));
333 ptcon
->NAME
= namealloc("bulk");
335 ptcon
->ROOT
= (void *)pttrs
;
337 ptcon
->DIRECTION
= 'I';
342 /* No check is done for transistor name */
343 pttrs
->TRNAME
= name
;
345 if ((TRACE_MODE
== 'Y'))
346 (void)fprintf(stdout
,
347 "--- mbk --- addlotrs : %s X=%ld, Y=%ld, W=%ld, L=%ld, PS = %ld, PD = %ld, XS = %ld, XD = %ld\n",
348 MLO_IS_TRANSN(type
) ? "TRANSN" : "TRANSP", x
, y
, width
, length
,
354 /*******************************************************************************
355 * function addlotrsparam() *
356 *******************************************************************************/
358 addlotrsparam(lotrs_list
*ptlotrs
, char *param
, float value
, char *expr
)
360 optparam_list
*newparam
;
363 newparam
= makelotrsparam(NULL
, param
, value
, expr
);
365 ptuser
= getptype(ptlotrs
->USER
, OPT_PARAMS
);
366 if (ptuser
== NULL
) {
367 ptlotrs
->USER
= addptype(ptlotrs
->USER
, OPT_PARAMS
, newparam
);
370 newparam
->NEXT
= ptuser
->DATA
;
371 ptuser
->DATA
= newparam
;
375 /*******************************************************************************
376 * function makelotrsparam() *
377 *******************************************************************************/
380 makelotrsparam(optparam_list
*ptheadparam
, char *param
, float value
, char *expr
)
382 optparam_list
*newparam
;
386 newparam
= (optparam_list
*)mbkalloc(sizeof(optparam_list
));
387 newparam
->TAG
= ' ' ;
388 newparam
->NEXT
= ptheadparam
;
389 if ((known
= getknowntrsparam(param
)) != NULL
) {
390 if (expr
!= NULL
) known
++;
391 newparam
->UNAME
.STANDARD
= known
;
394 newparam
->TAG
=expr
?'$':' ';
398 newparam
->UNAME
.SPECIAL
= namealloc(buf
);
400 if (expr
) newparam
->UDATA
.EXPR
= expr
;
401 else newparam
->UDATA
.VALUE
= value
;
403 newparam
->EQT_EXPR
=NULL
;
407 /*******************************************************************************
408 * function getlotrsparam() *
409 *******************************************************************************/
411 getlotrsparam(lotrs_list
*ptlotrs
, void *param
, char **expr
, int *status
)
415 optparam_list
*ptparamlist
;
420 ptuser
= getptype(ptlotrs
->USER
, OPT_PARAMS
);
421 if (ptuser
!= NULL
) {
422 if (isknowntrsparam(param
)) {
424 for (ptparamlist
= (optparam_list
*)ptuser
->DATA
; ptparamlist
; ptparamlist
= ptparamlist
->NEXT
) {
425 if (ptparamlist
->UNAME
.STANDARD
== testknown
) {
426 if (expr
) *expr
= NULL
;
427 if (status
) *status
= 1;
428 return ptparamlist
->UDATA
.VALUE
;
430 else if (ptparamlist
->UNAME
.STANDARD
== testknown
+1) {
431 if (expr
) *expr
= ptparamlist
->UDATA
.EXPR
;
432 if (status
) *status
= 2;
438 downstr((char *)param
, buf
);
439 testunknown
= namealloc(buf
);
440 for (ptparamlist
= (optparam_list
*)ptuser
->DATA
; ptparamlist
; ptparamlist
= ptparamlist
->NEXT
) {
441 if (ptparamlist
->TAG
==' ' && ptparamlist
->UNAME
.SPECIAL
== testunknown
) {
442 if (expr
) *expr
= NULL
;
443 if (status
) *status
= 1;
444 return ptparamlist
->UDATA
.VALUE
;
446 else if (ptparamlist
->TAG
=='$' && ptparamlist
->UNAME
.SPECIAL
== testunknown
) {
447 if (expr
) *expr
= ptparamlist
->UDATA
.EXPR
;
448 if (status
) *status
= 2;
456 if (expr
) *expr
= NULL
;
457 if (status
) *status
= 0;
461 /*******************************************************************************
462 * function freelotrsparams() *
463 *******************************************************************************/
465 freelotrsparams(lotrs_list
*ptlotrs
)
467 optparam_list
*ptparam
;
468 optparam_list
*ptnextparam
;
471 ptuser
= getptype(ptlotrs
->USER
, OPT_PARAMS
);
472 if (ptuser
!= NULL
) {
473 freeoptparams(ptuser
->DATA
);
475 for (ptparam = (optparam_list *)ptuser->DATA; ptparam; ptparam = ptnextparam) {
476 ptnextparam = ptparam->NEXT;
479 ptlotrs
->USER
= delptype(ptlotrs
->USER
, OPT_PARAMS
);
483 /*******************************************************************************
484 * function addlotrsmodel() *
485 *******************************************************************************/
486 short addlotrsmodel(lotrs
,model
)
493 if(VT_MODNAMEINDEX
== NULL
)
494 VT_MODNAMEINDEX
= addvt(10) ;
495 if(HT_MODINDEXNAME
== NULL
)
496 HT_MODINDEXNAME
= addht(10) ;
498 pt
= namealloc(model
) ;
499 index
= (short )gethtitem(HT_MODINDEXNAME
,pt
) ;
501 if((index
== (short)EMPTYHT
) || (index
== (short)DELETEHT
))
503 index
= (short)addvtitem(VT_MODNAMEINDEX
,pt
) ;
504 addhtitem(HT_MODINDEXNAME
,pt
,(long)index
) ;
506 if (lotrs
) lotrs
->MODINDEX
= index
;
510 /*******************************************************************************
511 * function getlotrsmodel() *
512 *******************************************************************************/
513 char *getlotrsmodel(lotrs
)
516 if((VT_MODNAMEINDEX
== NULL
) || (HT_MODINDEXNAME
== NULL
) ||
517 (lotrs
->MODINDEX
== EMPTYHT
))
519 if(TN_MODEL_NAME
== NULL
)
520 TN_MODEL_NAME
= namealloc("tn") ;
522 if(TP_MODEL_NAME
== NULL
)
523 TP_MODEL_NAME
= namealloc("tp") ;
525 return((MLO_IS_TRANSN(lotrs
->TYPE
)) ? TN_MODEL_NAME
: TP_MODEL_NAME
) ;
528 return((char *)getvtitem(VT_MODNAMEINDEX
,lotrs
->MODINDEX
)) ;
531 /*******************************************************************************
532 * function addloins() *
533 *******************************************************************************/
534 loins_list
*addloins(ptfig
, insname
, ptnewfig
, sigchain
)
537 lofig_list
*ptnewfig
;
538 chain_list
*sigchain
;
540 locon_list
*ptcon
= NULL
;
541 locon_list
*ptnewcon
= NULL
;
542 loins_list
*ptins
= NULL
;
546 insname
= namealloc(insname
);
547 figname
= ptnewfig
->NAME
;
549 /* check insname unicity */
550 if (strcmp(insname
, "*") && FAST_MODE
!= 'Y') {
551 for (ptins
= ptfig
->LOINS
; ptins
; ptins
= ptins
->NEXT
) {
552 if (ptins
->INSNAME
== insname
) {
553 avt_errmsg (MBK_ERRMSG
, "023", AVT_FATAL
, insname
, ptfig
->NAME
);
558 if (ptfig
->NAME
== figname
)
559 avt_errmsg (MBK_ERRMSG
, "024", AVT_FATAL
, figname
);
561 ptins
= (loins_list
*)mbkalloc(sizeof(loins_list
));
563 ptins
->INSNAME
= insname
;
564 ptins
->FIGNAME
= figname
;
567 ptins
->NEXT
= ptfig
->LOINS
;
568 ptfig
->LOINS
= ptins
;
570 /* update model list */
571 for (ptchain
= ptfig
->MODELCHAIN
; ptchain
; ptchain
= ptchain
->NEXT
)
572 if (ptchain
->DATA
== (void *)figname
)
576 ptfig
->MODELCHAIN
= addchain(ptfig
->MODELCHAIN
, (void *)figname
);
578 for (ptcon
= ptnewfig
->LOCON
; ptcon
; ptcon
= ptcon
->NEXT
) {
579 if (sigchain
== NULL
)
580 avt_errmsg (MBK_ERRMSG
, "025", AVT_FATAL
, ptnewfig
->NAME
, insname
, ptfig
->NAME
);
582 ptnewcon
= (locon_list
*)mbkalloc(sizeof(locon_list
));
583 ptnewcon
->NAME
= ptcon
->NAME
;
584 ptnewcon
->DIRECTION
= ptcon
->DIRECTION
;
585 ptnewcon
->TYPE
= 'I';
586 ptnewcon
->SIG
= (losig_list
*)sigchain
->DATA
;
587 ptnewcon
->ROOT
= (void *)ptins
;
588 ptnewcon
->USER
= NULL
;
589 ptnewcon
->PNODE
= NULL
;
590 ptnewcon
->NEXT
= ptins
->LOCON
;
591 ptins
->LOCON
= ptnewcon
;
592 sigchain
= sigchain
->NEXT
;
594 if (sigchain
!= NULL
)
595 avt_errmsg (MBK_ERRMSG
, "025", AVT_FATAL
, ptnewfig
->NAME
, insname
, ptfig
->NAME
);
597 ptins
->LOCON
= (locon_list
*)reverse((chain_list
*)ptins
->LOCON
);
599 if (TRACE_MODE
== 'Y')
600 (void)fprintf(stdout
, "--- mbk --- addloins : %s of figure %s\n",
605 /*******************************************************************************
606 * function addloinsparam() *
607 *******************************************************************************/
609 addloinsparam(loins_list
*ptloins
, char *param
, float value
, char *expr
)
611 optparam_list
*newparam
;
614 newparam
= (optparam_list
*)mbkalloc(sizeof(optparam_list
));
615 newparam
->NEXT
= NULL
;
617 newparam
->TAG
=expr
?'$':' ';
619 newparam
->UNAME
.SPECIAL
= namealloc(param
);
620 if (expr
) newparam
->UDATA
.EXPR
= expr
;
621 else newparam
->UDATA
.VALUE
= value
;
622 newparam
->EQT_EXPR
=NULL
;
623 ptuser
= getptype(ptloins
->USER
, OPT_PARAMS
);
624 if (ptuser
== NULL
) {
625 ptloins
->USER
= addptype(ptloins
->USER
, OPT_PARAMS
, newparam
);
628 newparam
->NEXT
= ptuser
->DATA
;
629 ptuser
->DATA
= newparam
;
633 /*******************************************************************************
634 * function getloinsparam() *
635 *******************************************************************************/
637 getloinsparam(loins_list
*ptloins
, void *param
, char **expr
, int *status
)
641 optparam_list
*ptparamlist
;
645 ptuser
= getptype(ptloins
->USER
, OPT_PARAMS
);
646 if (ptuser
!= NULL
) {
647 downstr((char *)param
, buf
);
648 testunknown
= namealloc(buf
);
649 for (ptparamlist
= (optparam_list
*)ptuser
->DATA
; ptparamlist
; ptparamlist
= ptparamlist
->NEXT
) {
650 if (ptparamlist
->TAG
==' ' && ptparamlist
->UNAME
.SPECIAL
== testunknown
) {
651 if (expr
) *expr
= NULL
;
652 if (status
) *status
= 1;
653 return ptparamlist
->UDATA
.VALUE
;
655 else if (ptparamlist
->TAG
=='$' && ptparamlist
->UNAME
.SPECIAL
== testunknown
) {
656 if (expr
) *expr
= ptparamlist
->UDATA
.EXPR
;
657 if (status
) *status
= 2;
663 if (expr
) *expr
= NULL
;
664 if (status
) *status
= 0;
668 /*******************************************************************************
669 * function freeloinsparams() *
670 *******************************************************************************/
672 freeloinsparams(loins_list
*ptloins
)
674 optparam_list
*ptparam
;
675 optparam_list
*ptnextparam
;
678 ptuser
= getptype(ptloins
->USER
, OPT_PARAMS
);
679 if (ptuser
!= NULL
) {
680 for (ptparam
= (optparam_list
*)ptuser
->DATA
; ptparam
; ptparam
= ptnextparam
) {
681 ptnextparam
= ptparam
->NEXT
;
684 ptloins
->USER
= delptype(ptloins
->USER
, OPT_PARAMS
);
688 /*******************************************************************************
689 * function addlocon() *
690 *******************************************************************************/
691 locon_list
*addlocon(ptfig
, name
, ptsig
, dir
)
699 name
= namealloc(name
);
701 /* check name unicity */
702 if (FAST_MODE
!= 'Y') {
703 for (ptcon
= ptfig
->LOCON
; ptcon
; ptcon
= ptcon
->NEXT
) {
704 if (ptcon
->NAME
== name
) {
705 avt_errmsg (MBK_ERRMSG
, "026", AVT_FATAL
, name
, ptfig
->NAME
);
708 if (dir
!= 'I' && dir
!= 'O' && dir
!= 'X' && dir
!= 'B'
709 && dir
!= 'Z' && dir
!= 'T' && dir
!= 'A') {
710 avt_errmsg (MBK_ERRMSG
, "027", AVT_FATAL
, dir
, ptfig
->NAME
);
714 ptcon
= (locon_list
*)mbkalloc(sizeof(locon_list
));
718 ptcon
->ROOT
= (void *)ptfig
;
719 ptcon
->DIRECTION
= dir
;
721 ptcon
->NEXT
= ptfig
->LOCON
;
723 ptfig
->LOCON
= ptcon
;
725 if (TRACE_MODE
== 'Y')
728 (void)fprintf(stdout
, "--- mbk --- addlocon : %s linked to %ld\n",
731 (void)fprintf(stdout
, "--- mbk --- addlocon : %s no signal\n", name
);
737 /*******************************************************************************
738 * function addlosig() *
739 *******************************************************************************/
741 losig_list
*addlosig(ptfig
, index
, namechain
, type
)
744 chain_list
*namechain
;
756 sigsize = getsigsize( ptfig );
758 low = (index % sigsize);
759 high = (index / sigsize);
760 for (pt = ptfig->BKSIG; pt; pt = pt->NEXT)
761 if (pt->TYPE == high)
764 pthead = (losig_list *)mbkalloc(sigsize * sizeof(losig_list));
766 for (i = 0; i < sigsize; i++) {
770 ptfig->BKSIG = (ptype_list *)addptype(ptfig->BKSIG,
771 (long)high, (void *)pthead);
774 ptsig = (losig_list *)(pt->DATA) + low;*/
776 ptsig
= mbk_NewBKSIG_getindex(ptfig
, index
);
778 /* check index unicity */
779 if (ptsig
->INDEX
!= 0L) {
780 avt_errmsg (MBK_ERRMSG
, "028", AVT_FATAL
, index
, ptfig
->NAME
);
782 for (ptchain
= namechain
; ptchain
; ptchain
= ptchain
->NEXT
)
783 ptchain
->DATA
= (void *)namealloc((char *)ptchain
->DATA
);
785 ptsig
->NAMECHAIN
= namechain
;
786 ptsig
->INDEX
= index
;
790 ptsig
->NEXT
= ptfig
->LOSIG
;
791 ptfig
->LOSIG
= ptsig
;
793 ptsig
->ALIMFLAGS
= 0;
795 if (TRACE_MODE
== 'Y') {
796 (void)fprintf(stdout
, "--- mbk --- addlosig : %ld ", index
);
797 if (ptsig
->NAMECHAIN
)
798 if (ptsig
->NAMECHAIN
->DATA
)
799 (void)fprintf(stdout
, "name : %s",
800 (char *)((chain_list
*)(ptsig
->NAMECHAIN
))->DATA
);
801 (void)fprintf(stdout
, "\n");
807 /*******************************************************************************
808 * function dellofig() *
809 *******************************************************************************/
810 int dellofig(char *name
)
816 name
= namealloc(name
);
817 for (ptfig
= HEAD_LOFIG
; ptfig
; ptfig
= ptfig
->NEXT
) {
818 if (ptfig
->NAME
== name
)
820 ptold
= (void *)ptfig
;
823 if (ptfig
== NULL
|| islofiglocked(ptfig
) )
826 if (ptfig
== HEAD_LOFIG
)
827 HEAD_LOFIG
= ptfig
->NEXT
;
829 ((lofig_list
*)ptold
)->NEXT
= ptfig
->NEXT
;
830 delhtitem(HT_LOFIG
, name
);
831 ret
=freelofig(ptfig
);
832 if (ret
&& TRACE_MODE
== 'Y')
833 (void)fprintf(stdout
, "--- mbk --- dellofig : %s\n", name
);
837 int freelofig(lofig_list
*ptfig
)
845 void *ptold
=NULL
,*ptt
; /* Nom sponsorise par France Telecon */
848 if( ptfig
&& islofiglocked(ptfig
) )
851 mbk_freeparallel(ptfig
);
853 rcn_disable_cache( ptfig
);
855 freectclist( ptfig
, NULL
);
856 for (ptsig
= ptfig
->LOSIG
; ptsig
; ptsig
= ptsig
->NEXT
)
858 freechain(ptsig
->NAMECHAIN
);
861 dellosiguser( ptsig
);
864 for (ptins
= ptfig
->LOINS
; ptins
; ptins
= (loins_list
*)ptold
) {
865 freeloinsparams (ptins
);
866 delloinsuser( ptins
);
867 for (ptcon
= ptins
->LOCON
; ptcon
; ptcon
= (locon_list
*)ptt
) {
868 ptt
= (void *)ptcon
->NEXT
;
869 delloconuser( ptcon
);
870 mbkfree((void *)ptcon
);
872 ptold
= (void *)ptins
->NEXT
;
873 mbkfree((void *)ptins
);
876 mbk_free_NewBKSIG(&ptfig
->BKSIG
);
877 /* for (pt = ptfig->BKSIG; pt; pt = pt->NEXT) {
878 mbkfree((void *)pt->DATA);
880 freeptype(ptfig->BKSIG);*/
881 for (ptcon
= ptfig
->LOCON
; ptcon
; ptcon
= (locon_list
*)ptold
) {
882 ptold
= (void *)ptcon
->NEXT
;
883 delloconuser( ptcon
);
884 mbkfree((void *)ptcon
);
888 for (pttrs
= ptfig
->LOTRS
; pttrs
; pttrs
= (lotrs_list
*)ptold
) {
889 delloconuser( pttrs
->GRID
);
890 delloconuser( pttrs
->SOURCE
);
891 delloconuser( pttrs
->DRAIN
);
892 if (pttrs
->BULK
!=NULL
)
894 delloconuser( pttrs
->BULK
);
895 mbkfree((void *)pttrs
->BULK
);
898 mbkfree((void *)pttrs
->GRID
);
899 mbkfree((void *)pttrs
->SOURCE
);
900 mbkfree((void *)pttrs
->DRAIN
);
901 // mbkfree((void *)pttrs->BULK);
902 ptold
= (void *)pttrs
->NEXT
;
903 freelotrsparams (pttrs
);
904 dellotrsuser( pttrs
);
905 mbkfree((void *)pttrs
);
907 dellofiguser( ptfig
);
908 freechain(ptfig
->MODELCHAIN
);
909 mbkfree((void *)ptfig
);
913 /*******************************************************************************
914 * function freelomodel() *
915 *******************************************************************************/
916 void freelomodel(ptmodel
)
923 if (!ptmodel
) /* nothing to be freed */
926 ptfig
= ptmodel
->NEXT
;
928 for (ptcon
= ptmodel
->LOCON
; ptcon
; ptcon
= ptc
) {
930 mbkfree((void *)ptcon
);
932 mbkfree((void *)ptmodel
);
939 if (TRACE_MODE
== 'Y')
940 (void)fprintf(stdout
, "--- mbk --- freelomodel\n");
943 /*******************************************************************************
944 * function dellosig() *
945 *******************************************************************************/
946 int dellosig(ptfig
, index
)
950 losig_list
*ptsav
=NULL
;
953 for (ptsig
= ptfig
->LOSIG
; ptsig
; ptsig
= ptsig
->NEXT
) {
954 if (ptsig
->INDEX
== index
)
961 else if (ptsig
== ptfig
->LOSIG
)
962 ptfig
->LOSIG
= ptsig
->NEXT
;
964 ptsav
->NEXT
= ptsig
->NEXT
;
967 freelorcnet( ptsig
);
970 freechain(ptsig
->NAMECHAIN
);
971 ptsig
->NAMECHAIN
=NULL
;
973 dellosiguser( ptsig
);
975 if (TRACE_MODE
== 'Y')
976 (void)fprintf(stdout
, "--- mbk --- dellosig : %ld\n", index
);
981 /*******************************************************************************
982 * function dellotrs() *
983 *******************************************************************************/
984 int dellotrs(ptfig
, pttrs
)
989 lotrs_list
*ptsav
=NULL
;
991 for (pt
= ptfig
->LOTRS
; pt
; pt
= pt
->NEXT
) {
998 else if (pt
== ptfig
->LOTRS
)
999 ptfig
->LOTRS
= pt
->NEXT
;
1001 ptsav
->NEXT
= pt
->NEXT
;
1003 if( pt
->GRID
->PNODE
)
1004 delrcnlocon( pt
->GRID
);
1005 delloconuser( pt
->GRID
);
1006 mbkfree((void *)pt
->GRID
);
1008 if( pt
->SOURCE
->PNODE
)
1009 delrcnlocon( pt
->SOURCE
);
1010 delloconuser( pt
->SOURCE
);
1011 mbkfree((void *)pt
->SOURCE
);
1013 if( pt
->DRAIN
->PNODE
)
1014 delrcnlocon( pt
->DRAIN
);
1015 delloconuser( pt
->DRAIN
);
1016 mbkfree((void *)pt
->DRAIN
);
1020 if( pt
->BULK
->PNODE
)
1021 delrcnlocon( pt
->BULK
);
1022 delloconuser( pt
->BULK
);
1023 mbkfree((void *)pt
->BULK
);
1026 freelotrsparams(pt
);
1028 mbkfree((void *)pt
);
1029 if (TRACE_MODE
== 'Y')
1030 (void)fprintf(stdout
, "--- mbk --- dellotrs : \n");
1034 int delflaggedlotrs(ptfig
, flagname
)
1038 lotrs_list
*pt
, *next
;
1039 lotrs_list
*ptsav
=NULL
;
1041 for (pt
= ptfig
->LOTRS
; pt
; pt
= next
) {
1043 if (pt
->TRNAME
==flagname
)
1045 if (ptsav
== NULL
) ptfig
->LOTRS
= pt
->NEXT
;
1046 else ptsav
->NEXT
= pt
->NEXT
;
1048 if( pt
->GRID
->PNODE
)
1049 delrcnlocon( pt
->GRID
);
1050 delloconuser( pt
->GRID
);
1051 mbkfree((void *)pt
->GRID
);
1053 if( pt
->SOURCE
->PNODE
)
1054 delrcnlocon( pt
->SOURCE
);
1055 delloconuser( pt
->SOURCE
);
1056 mbkfree((void *)pt
->SOURCE
);
1058 if( pt
->DRAIN
->PNODE
)
1059 delrcnlocon( pt
->DRAIN
);
1060 delloconuser( pt
->DRAIN
);
1061 mbkfree((void *)pt
->DRAIN
);
1065 if( pt
->BULK
->PNODE
)
1066 delrcnlocon( pt
->BULK
);
1067 delloconuser( pt
->BULK
);
1068 mbkfree((void *)pt
->BULK
);
1071 freelotrsparams(pt
);
1073 mbkfree((void *)pt
);
1080 /*******************************************************************************
1081 * function delloins() *
1082 *******************************************************************************/
1083 int delloins(ptfig
, insname
)
1089 chain_list
*ptchain
;
1090 chain_list
*pttmpchain
=NULL
;
1094 insname
= namealloc(insname
);
1095 for (ptins
= ptfig
->LOINS
; ptins
; ptins
= ptins
->NEXT
) {
1096 if (ptins
->INSNAME
== insname
)
1102 if (ptins
== ptfig
->LOINS
) {
1103 figname
= ptins
->FIGNAME
;
1104 ptfig
->LOINS
= ptins
->NEXT
;
1106 figname
= ptins
->FIGNAME
;
1107 ((loins_list
*)pt
)->NEXT
= ptins
->NEXT
;
1109 for (ptcon
= ptins
->LOCON
; ptcon
; ptcon
= (locon_list
*)pt
) {
1111 delrcnlocon( ptcon
);
1112 pt
= (void *)ptcon
->NEXT
;
1113 delloconuser( ptcon
);
1114 mbkfree((void *)ptcon
);
1117 delloinsuser( ptins
);
1118 mbkfree((void *)ptins
);
1120 for (ptins
= ptfig
->LOINS
; ptins
; ptins
= ptins
->NEXT
)
1121 if (ptins
->FIGNAME
== figname
)
1123 if (ptins
== NULL
) { /* if no more instance have this model, destroy */
1124 for (ptchain
= ptfig
->MODELCHAIN
; ptchain
; ptchain
= ptchain
->NEXT
) {
1125 if (ptchain
->DATA
== (void *)figname
)
1127 pttmpchain
= ptchain
;
1129 if (ptchain
== ptfig
->MODELCHAIN
&& ptchain
!= NULL
)
1130 ptfig
->MODELCHAIN
= ptchain
->NEXT
;
1132 pttmpchain
->NEXT
= ptchain
->NEXT
;
1136 ptchain
->NEXT
= NULL
;
1137 freechain( ptchain
);
1141 if (TRACE_MODE
== 'Y')
1142 (void)fprintf(stdout
, "--- mbk --- delloins : %s\n", insname
);
1146 int delflaggedloins(lofig_list
*ptfig
)
1149 locon_list
*ptcon
, *nextlocon
;
1150 chain_list
*newmodelchain
=NULL
;
1151 loins_list
*pt
=NULL
, *next
;
1155 tmodel
= addht(1000);
1157 for (ptins
= ptfig
->LOINS
; ptins
; ptins
= next
)
1160 if (ptins
->INSNAME
== NULL
)
1162 if (pt
== NULL
) ptfig
->LOINS
= ptins
->NEXT
;
1163 else pt
->NEXT
=ptins
->NEXT
;
1164 for (ptcon
= ptins
->LOCON
; ptcon
; ptcon
= nextlocon
)
1166 nextlocon
=ptcon
->NEXT
;
1167 if( ptcon
->PNODE
) delrcnlocon( ptcon
);
1168 delloconuser( ptcon
);
1169 mbkfree((void *)ptcon
);
1171 delloinsuser( ptins
);
1172 freeptype(ptins
->USER
);
1173 if (TRACE_MODE
== 'Y')
1174 (void)fprintf(stdout
, "--- mbk --- delloins\n");
1175 mbkfree((void *)ptins
);
1180 if( gethtitem( tmodel
, ptins
->FIGNAME
) == EMPTYHT
) {
1181 newmodelchain
=addchain(newmodelchain
, ptins
->FIGNAME
);
1182 addhtitem( tmodel
, ptins
->FIGNAME
, 1l );
1185 for (ptchain = newmodelchain; ptchain && ptchain->DATA!=ptins->FIGNAME; ptchain = ptchain->NEXT) ;
1186 if (ptchain==NULL) newmodelchain=addchain(newmodelchain, ptins->FIGNAME);
1193 freechain(ptfig
->MODELCHAIN
);
1194 ptfig
->MODELCHAIN
=newmodelchain
;
1198 /*******************************************************************************
1199 * function dellocon() *
1200 *******************************************************************************/
1201 int dellocon(ptfig
, name
)
1206 locon_list
*ptsav
=NULL
;
1208 name
= namealloc(name
);
1209 for (ptcon
= ptfig
->LOCON
; ptcon
; ptcon
= ptcon
->NEXT
) {
1210 if (ptcon
->NAME
== name
)
1216 else if (ptcon
== ptfig
->LOCON
)
1217 ptfig
->LOCON
= ptcon
->NEXT
;
1219 ptsav
->NEXT
= ptcon
->NEXT
;
1222 delrcnlocon( ptcon
);
1224 delloconuser( ptcon
);
1225 mbkfree((void *)ptcon
);
1226 if (TRACE_MODE
== 'Y')
1227 (void)fprintf(stdout
, "--- mbk --- dellocon : %s\n", name
);
1232 /*******************************************************************************
1233 * function getlomodel *
1234 * gives a pointer to a model or NULL if it doesn't exist *
1235 *******************************************************************************/
1236 lofig_list
*getlomodel(ptmodel
, name
)
1237 lofig_list
*ptmodel
;
1242 name
= namealloc(name
);
1243 for (ptfig
= ptmodel
; ptfig
; ptfig
= ptfig
->NEXT
)
1244 if (ptfig
->NAME
== name
)
1249 /*******************************************************************************
1250 * function getloins() *
1251 *******************************************************************************/
1252 loins_list
*getloins(ptfig
, name
)
1258 name
= namealloc(name
);
1260 for (ptins
= ptfig
->LOINS
; ptins
; ptins
= ptins
->NEXT
)
1261 if (ptins
->INSNAME
== name
)
1264 avt_errmsg (MBK_ERRMSG
, "029", AVT_FATAL
, name
, ptfig
->NAME
);
1265 return NULL
; /* never reached */
1268 /*******************************************************************************
1269 * function getlotrs() *
1270 *******************************************************************************/
1271 lotrs_list
*getlotrs(ptfig
, name
)
1277 name
= namealloc(name
);
1279 for (pttrs
= ptfig
->LOTRS
; pttrs
; pttrs
= pttrs
->NEXT
)
1280 if (pttrs
->TRNAME
== name
)
1283 avt_errmsg (MBK_ERRMSG
, "030", AVT_FATAL
, name
, ptfig
->NAME
);
1284 return NULL
; /* never reached */
1287 /*******************************************************************************
1288 * function getlocon() *
1289 *******************************************************************************/
1290 locon_list
*getlocon(ptfig
, name
)
1296 name
= namealloc(name
);
1298 for (ptcon
= ptfig
->LOCON
; ptcon
; ptcon
= ptcon
->NEXT
)
1299 if (ptcon
->NAME
== name
)
1302 avt_errmsg (MBK_ERRMSG
, "031", AVT_FATAL
, name
, ptfig
->NAME
);
1303 return NULL
; /* never reached */
1306 /*******************************************************************************
1307 * function getlosig() *
1308 *******************************************************************************/
1309 losig_list
*getlosig(lofig_list
*ptfig
, long index
)
1318 sigsize = getsigsize( ptfig );
1319 low = (index % sigsize);
1320 high = (index / sigsize);
1321 for (pt = ptfig->BKSIG; pt; pt = pt->NEXT)
1322 if (pt->TYPE == high) break;
1324 ptsig = (losig_list *)(pt->DATA) + low;
1325 if (ptsig->INDEX == index)
1329 if (index
<=ptfig
->BKSIG
.maxindex
)
1330 return mbk_NewBKSIG_getindex(ptfig
, index
);
1332 avt_errmsg (MBK_ERRMSG
, "032", AVT_FATAL
, index
, ptfig
->NAME
);
1333 return NULL
; /* never reached */
1336 /*******************************************************************************
1337 * function lofigchain_local() *
1338 * For each signal, construct the list of connectors associated *
1339 * with the signal.(Field USER of the "losig" structure with *
1340 * the code "LOFIGCHAIN_LOCAL") *
1341 * This provide the "dual" representation of the net-list *
1342 *******************************************************************************/
1344 void dellofigchain_local(ptfig
)
1347 losig_list
*ptsig
= NULL
;
1348 ptype_list
*ptype
= NULL
;
1350 if (ptfig
->MODE
== 'P')
1354 for (ptsig
= ptfig
->LOSIG
; ptsig
; ptsig
= ptsig
->NEXT
) {
1355 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
);
1356 if (ptype
!= (ptype_list
*)NULL
) {
1357 freechain((chain_list
*)ptype
->DATA
);
1358 ptype
->DATA
= (void *)NULL
;
1360 ptsig
->USER
= delptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
);
1364 void lofigchain_local(ptfig
)
1367 locon_list
*ptcon
= NULL
;
1368 losig_list
*ptsig
= NULL
;
1369 loins_list
*ptins
= NULL
;
1370 lotrs_list
*pttrs
= NULL
;
1371 ptype_list
*ptype
= NULL
;
1373 if (ptfig
->MODE
== 'P') {
1375 (void)fflush(stdout);
1376 (void)fprintf(stderr, "*** mbk error ***\nlofigchain impossible ");
1377 (void)fprintf(stderr, ": figure %s is interface only\n",
1385 for (ptsig
= ptfig
->LOSIG
; ptsig
; ptsig
= ptsig
->NEXT
) {
1386 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
);
1387 if (ptype
!= (ptype_list
*)NULL
) {
1388 freechain((chain_list
*)ptype
->DATA
);
1389 ptype
->DATA
= (void *)NULL
;
1391 ptsig
->USER
= addptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
, (void *)NULL
);
1394 /* scan connector list */
1395 for (ptcon
=ptfig
->LOCON
; ptcon
; ptcon
=ptcon
->NEXT
) {
1397 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
);
1398 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
, (void *)ptcon
);
1401 /* scan instance list */
1402 for (ptins
=ptfig
->LOINS
; ptins
; ptins
=ptins
->NEXT
) {
1403 for (ptcon
=ptins
->LOCON
; ptcon
; ptcon
=ptcon
->NEXT
) {
1405 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
);
1406 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1411 /* scan transistor list */
1412 for (pttrs
= ptfig
->LOTRS
; pttrs
; pttrs
= pttrs
->NEXT
) {
1413 ptsig
= pttrs
->GRID
->SIG
;
1414 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
);
1415 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1416 (void *)pttrs
->GRID
);
1417 ptsig
= pttrs
->SOURCE
->SIG
;
1418 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
);
1419 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1420 (void *)pttrs
->SOURCE
);
1421 ptsig
= pttrs
->DRAIN
->SIG
;
1422 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
);
1423 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1424 (void *)pttrs
->DRAIN
);
1425 if (pttrs
->BULK
!=NULL
)
1427 ptsig
= pttrs
->BULK
->SIG
;
1429 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN_LOCAL
);
1430 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1431 (void *)pttrs
->BULK
);
1435 if (DEBUG_MODE
== 'Y')
1436 (void)printf("--- mbk --- lofigchain_local %s\n", ptfig
->NAME
);
1439 /*******************************************************************************
1440 * function addoptparam() *
1441 *******************************************************************************/
1443 addoptparam(optparam_list
*ptheadparam
, char *param
, float value
, char *expr
)
1445 optparam_list
*newparam
;
1448 newparam
= (optparam_list
*)mbkalloc(sizeof(optparam_list
));
1449 newparam
->EQT_EXPR
=NULL
;
1450 newparam
->NEXT
= ptheadparam
;
1452 newparam
->TAG
=expr
?'$':' ';
1453 downstr(param
, buf
);
1454 newparam
->UNAME
.SPECIAL
= namealloc(buf
);
1455 if (expr
) newparam
->UDATA
.EXPR
= expr
;
1456 else newparam
->UDATA
.VALUE
= value
;
1461 /*******************************************************************************
1462 * function getoptparam() *
1463 *******************************************************************************/
1465 getoptparam(optparam_list
*ptheadparam
, void *param
, char **expr
, int *status
)
1468 optparam_list
*ptparamlist
;
1472 if (ptheadparam
!= NULL
) {
1473 downstr((char *)param
, buf
);
1474 testunknown
= namealloc(buf
);
1475 for (ptparamlist
= ptheadparam
; ptparamlist
; ptparamlist
= ptparamlist
->NEXT
) {
1476 if (ptparamlist
->TAG
==' ' && ptparamlist
->UNAME
.SPECIAL
== testunknown
) {
1477 if (expr
) *expr
= NULL
;
1478 if (status
) *status
= 1;
1479 return ptparamlist
->UDATA
.VALUE
;
1481 else if (ptparamlist
->TAG
=='$' && ptparamlist
->UNAME
.SPECIAL
== testunknown
) {
1482 if (expr
) *expr
= ptparamlist
->UDATA
.EXPR
;
1483 if (status
) *status
= 2;
1489 if (expr
) *expr
= NULL
;
1490 if (status
) *status
= 0;
1494 /*******************************************************************************
1495 * function freeoptparams() *
1496 *******************************************************************************/
1498 freeoptparams(optparam_list
*ptheadparam
)
1500 optparam_list
*ptparam
;
1501 optparam_list
*ptnextparam
;
1503 for (ptparam
= ptheadparam
; ptparam
; ptparam
= ptnextparam
) {
1504 ptnextparam
= ptparam
->NEXT
;
1505 if (ptparam
->EQT_EXPR
!=NULL
&& --((eqt_node
*)ptparam
->EQT_EXPR
)->REF_COUNT
==0)
1506 eqt_freenode(ptparam
->EQT_EXPR
);
1511 /*******************************************************************************
1512 * function lofigchain() *
1513 * For each signal, construct the list of connectors associated *
1514 * with the signal.(Field USER of the "losig" structure with *
1515 * the code "LOFIGCHAIN") *
1516 * This provide the "dual" representation of the net-list *
1517 *******************************************************************************/
1518 void lofigchain(ptfig
)
1521 locon_list
*ptcon
= NULL
;
1522 losig_list
*ptsig
= NULL
;
1523 loins_list
*ptins
= NULL
;
1524 lotrs_list
*pttrs
= NULL
;
1525 ptype_list
*ptype
= NULL
;
1527 if (ptfig
->MODE
== 'P') {
1529 (void)fflush(stdout);
1530 (void)fprintf(stderr, "*** mbk error ***\nlofigchain impossible ");
1531 (void)fprintf(stderr, ": figure %s is interface only\n",
1539 for (ptsig
= ptfig
->LOSIG
; ptsig
; ptsig
= ptsig
->NEXT
) {
1540 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN
);
1541 if (ptype
!= (ptype_list
*)NULL
) {
1542 freechain((chain_list
*)ptype
->DATA
);
1543 ptype
->DATA
= (void *)NULL
;
1545 ptsig
->USER
= addptype(ptsig
->USER
, (long)LOFIGCHAIN
, (void *)NULL
);
1548 /* scan connector list */
1549 for (ptcon
=ptfig
->LOCON
; ptcon
; ptcon
=ptcon
->NEXT
) {
1552 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN
);
1553 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
, (void *)ptcon
);
1557 /* scan instance list */
1558 for (ptins
=ptfig
->LOINS
; ptins
; ptins
=ptins
->NEXT
) {
1559 for (ptcon
=ptins
->LOCON
; ptcon
; ptcon
=ptcon
->NEXT
) {
1562 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN
);
1563 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1569 /* scan transistor list */
1570 for (pttrs
= ptfig
->LOTRS
; pttrs
; pttrs
= pttrs
->NEXT
) {
1571 ptsig
= pttrs
->GRID
->SIG
;
1572 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN
);
1573 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1574 (void *)pttrs
->GRID
);
1575 ptsig
= pttrs
->SOURCE
->SIG
;
1576 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN
);
1577 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1578 (void *)pttrs
->SOURCE
);
1579 ptsig
= pttrs
->DRAIN
->SIG
;
1580 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN
);
1581 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1582 (void *)pttrs
->DRAIN
);
1583 if (pttrs
->BULK
!=NULL
)
1585 ptsig
= pttrs
->BULK
->SIG
;
1587 ptype
= getptype(ptsig
->USER
, (long)LOFIGCHAIN
);
1588 ptype
->DATA
= (void *)addchain((chain_list
*)ptype
->DATA
,
1589 (void *)pttrs
->BULK
);
1593 if (DEBUG_MODE
== 'Y')
1594 (void)printf("--- mbk --- lofigchain %s\n", ptfig
->NAME
);
1597 /*******************************************************************************
1598 * function getsigname() *
1599 * choose the least concatened signal name *
1600 *******************************************************************************/
1601 char *getsigname(ptsig
)
1607 char *result
= NULL
, *newc
;
1608 register int nseparmin
= 1000;
1614 for (ptscan
= ptsig
->NAMECHAIN
; ptscan
; ptscan
= ptscan
->NEXT
) {
1615 register int nsepar
= 0;
1616 newc
=(char *)ptscan
->DATA
;
1618 for (ptchar
= newc
; *ptchar
!= '\0'; ptchar
++)
1619 if (*ptchar
== SEPAR
)
1621 if (nsepar
< nseparmin
) {
1625 else if (nsepar
== nseparmin
) {
1626 if ((l0
=strlen(newc
)) < (l1
=strlen(result
)) || (l0
==l1
&& mbk_casestrcmp(newc
,result
)<0)) {
1633 (void)sprintf(buffer
, "mbk_%ld", ptsig
->INDEX
);
1634 result
= namealloc(buffer
);
1639 /*******************************************************************************
1640 * function mbkisgnalname() *
1641 * Return 1 if signal is named 'name', 0 else. name must be nameallocated. *
1642 *******************************************************************************/
1643 int mbkissignalname( losig_list
*losig
, char *name
)
1650 for( chain
= losig
->NAMECHAIN
; chain
; chain
= chain
->NEXT
) {
1651 if( (char*)chain
->DATA
== name
)
1658 /*******************************************************************************
1659 * function viewlo() *
1660 * display on screen the content of all logical figures *
1661 *******************************************************************************/
1666 if (HEAD_LOFIG
== NULL
) {
1667 avt_errmsg (MBK_ERRMSG
, "033", AVT_ERROR
);
1669 } else for (ptfig
= HEAD_LOFIG
; ptfig
; ptfig
= ptfig
->NEXT
)
1673 /*******************************************************************************
1674 * function viewlofig() *
1675 * display on screen the content of logical figure ptfig *
1676 *******************************************************************************/
1677 void viewlofig(ptfig
)
1684 chain_list
*scanchain
;
1687 if (ptfig
->NAME
== NULL
)
1688 (void)printf("!!! figure without name !!! /n");
1690 (void)printf("\nfigure : %-20s mode : %c\n", ptfig
->NAME
, ptfig
->MODE
);
1692 if (ptfig
->LOCON
== NULL
)
1693 (void)printf(" |---empty connector list\n");
1696 for (ptcon
= ptfig
->LOCON
; ptcon
; ptcon
= ptcon
->NEXT
)
1697 viewlofigcon(ptcon
);
1699 pt
= getptype( ptfig
->USER
, PH_INTERF
);
1702 (void)printf(" |---connector list physical order\n");
1703 for( scanchain
= (chain_list
*)(pt
->DATA
); scanchain
; scanchain
= scanchain
->NEXT
)
1704 (void)printf(" | |---%s\n",(char*)(scanchain
->DATA
) );
1705 (void)printf(" |\n");
1709 if (ptfig
->LOSIG
== NULL
)
1710 (void)printf(" |---empty signal list\n");
1711 else for (ptsig
= ptfig
->LOSIG
; ptsig
; ptsig
= ptsig
->NEXT
)
1714 if (ptfig
->LOINS
== NULL
)
1715 (void)printf(" |---empty instance list\n");
1716 else for (ptins
= ptfig
->LOINS
; ptins
; ptins
= ptins
->NEXT
)
1719 if (ptfig
->LOTRS
== NULL
)
1720 (void)printf(" |---empty transistor list\n");
1721 else for (pttrs
= ptfig
->LOTRS
; pttrs
; pttrs
= pttrs
->NEXT
)
1724 if (ptfig
->USER
!= NULL
)
1726 (void)printf(" |---USER field\n");
1727 for( pt
= ptfig
->USER
; pt
; pt
= pt
->NEXT
)
1728 (void)printf(" | |-- %ld\n",pt
->TYPE
);
1731 (void)printf(" |---empty USER field\n");
1733 (void)printf(" | \n");
1736 /*******************************************************************************
1737 * function viewlofigcon() *
1738 *******************************************************************************/
1739 void viewlofigcon(ptcon
)
1743 ptype_list
*scanptype
;
1744 chain_list
*scanchain
;
1746 if (ptcon
->NAME
== NULL
)
1747 (void)printf(" |--- !!! connector without name !!!\n");
1749 (void)printf(" |---connector : \"%s\"\n", ptcon
->NAME
);
1750 (void)printf(" | |---direction : %c\n", ptcon
->DIRECTION
);
1751 if (ptcon
->SIG
== NULL
)
1752 (void)printf(" | |---no signal\n");
1754 (void)printf(" | |---signal : %ld\n", ptcon
->SIG
->INDEX
);
1755 if (ptcon
->ROOT
== NULL
)
1756 (void)printf(" |---no root\n");
1758 (void)printf(" | |---root : %s\n",
1759 ((char *)(((lofig_list
*)(ptcon
->ROOT
))->NAME
)));
1760 (void)printf(" | |---type : %c \n", ptcon
->TYPE
);
1762 (void)printf(" | |---USER list\n");
1763 for( scanptype
= ptcon
->USER
; scanptype
; scanptype
= scanptype
->NEXT
)
1765 switch( scanptype
->TYPE
)
1768 (void)printf(" | | |---PNODENAME\n");
1769 for( scanchain
= (chain_list
*)(scanptype
->DATA
);
1771 scanchain
= scanchain
->NEXT
)
1772 (void)printf(" | | | |---%s\n", (char*)(scanchain
->DATA
)?(char*)(scanchain
->DATA
):"NULL" );
1775 (void)printf(" | | | |---%ld\n",scanptype
->TYPE
);
1779 if(ptcon
->PNODE
== NULL
)
1780 (void)printf(" | |---no node\n");
1782 (void)printf(" | |---node\n");
1783 for(scannum
= ptcon
->PNODE
; scannum
; scannum
= scannum
->NEXT
)
1784 (void)printf(" | | |---%ld\n",scannum
->DATA
);
1788 (void)printf(" |\n");
1791 /*******************************************************************************
1792 * function viewlosig() *
1793 *******************************************************************************/
1794 void viewlosig_sub(losig_list
*ptsig
, int resume
)
1796 chain_list
*ptchain
;
1797 lowire_list
*scanwire
;
1798 chain_list
*scanctc
;
1801 ptype_list
*ptptype
;
1804 (void)printf(" |---signal : %ld \n" , ptsig
->INDEX
);
1805 if (ptsig
->NAMECHAIN
== NULL
)
1806 (void)printf(" | |---no alias names\n");
1807 else for (ptchain
= ptsig
->NAMECHAIN
; ptchain
; ptchain
= ptchain
->NEXT
) {
1808 if (ptchain
->DATA
== NULL
)
1809 (void)printf(" | |--- !!! empty name !!!\n");
1811 (void)printf(" | |---alias : \"%s\"\n", (char *)ptchain
->DATA
);
1813 (void)printf(" | |---type : %c\n" , ptsig
->TYPE
);
1815 levelrc
= rclevel( ptsig
);
1817 if( levelrc
== MBK_RC_A
)
1818 (void)printf(" | |---no parasitic data\n");
1820 (void)printf(" | |---parasitic data\n");
1821 (void)printf(" | | |---capacitance : %g\n" , rcn_getcapa(NULL
, ptsig
));
1822 if( levelrc
== MBK_RC_C
|| levelrc
== MBK_RC_E
) {
1823 (void)printf(" | | |---wire list\n");
1824 for( scanwire
= ptsig
->PRCN
->PWIRE
; scanwire
!= NULL
; scanwire
= scanwire
->NEXT
)
1825 (void)printf(" | | | |-n1=%3ld n2=%3ld r=%g c=%g\n",
1832 (void)printf(" | | |---no wire\n");
1833 if( levelrc
== MBK_RC_D
|| levelrc
== MBK_RC_E
) {
1834 (void)printf(" | | |---crosstalk capacitance list\n");
1835 for( scanctc
= ptsig
->PRCN
->PCTC
; scanctc
!= NULL
; scanctc
= scanctc
->NEXT
) {
1836 ptctc
= (loctc_list
*)scanctc
->DATA
;
1837 (void)printf(" | | | |-S1=%3ld N1=%3ld S2=%3ld N2=%3ld Capa=%g.\n",
1847 (void)printf(" | | |---no crosstalk capacitance\n");
1848 (void)printf(" | | |---%ld node\n",ptsig
->PRCN
->NBNODE
);
1850 (void)printf(" | |---USER list\n");
1851 for( ptptype
= ptsig
->USER
; ptptype
; ptptype
= ptptype
->NEXT
)
1853 switch( ptptype
->TYPE
)
1856 printf( " | | |-LOFIGCHAIN\n" );
1857 for( ptchain
= (chain_list
*)ptptype
->DATA
; ptchain
; ptchain
= ptchain
->NEXT
)
1859 printf( " | | | |-%s ",((locon_list
*)ptchain
->DATA
)->NAME
);
1860 switch( ((locon_list
*)ptchain
->DATA
)->TYPE
)
1863 printf( "(T%c : %s) ",MLO_IS_TRANSN(((lotrs_list
*)((locon_list
*)ptchain
->DATA
)->ROOT
)->TYPE
)?'N':'P',((lotrs_list
*)((locon_list
*)ptchain
->DATA
)->ROOT
)->TRNAME
? ((lotrs_list
*)((locon_list
*)ptchain
->DATA
)->ROOT
)->TRNAME
: "No name" );
1866 printf( "(I : %s) ",((loins_list
*)((locon_list
*)ptchain
->DATA
)->ROOT
)->INSNAME
? ((loins_list
*)((locon_list
*)ptchain
->DATA
)->ROOT
)->INSNAME
: "No name" );
1869 printf( "(Figure) " );
1872 printf( "Not a valid type('%c') ", ((locon_list
*)ptchain
->DATA
)->TYPE
);
1876 for( scannum
= ((locon_list
*)ptchain
->DATA
)->PNODE
; scannum
; scannum
= scannum
->NEXT
)
1877 printf( "%ld ", scannum
->DATA
);
1888 (void)printf(" | \n");
1891 void viewlosig(losig_list
*ptsig
)
1893 viewlosig_sub(ptsig
, 0);
1896 /*******************************************************************************
1897 * function viewloins() *
1898 *******************************************************************************/
1899 void viewloins(ptins
)
1903 chain_list
*scanchain
;
1906 if (ptins
->INSNAME
== NULL
)
1907 (void)printf(" |--- !!! no instance name !!!\n");
1909 (void)printf(" |---instance : %s\n", ptins
->INSNAME
);
1910 if (ptins
->FIGNAME
== NULL
)
1911 (void)printf(" | |--- !!! no instance model !!!\n");
1913 (void)printf(" | |---model : %s \n" , ptins
->FIGNAME
);
1914 if (ptins
->LOCON
== NULL
)
1915 (void)printf(" | |---empty list of connectors\n");
1918 for (ptcon
= ptins
->LOCON
; ptcon
!= NULL
; ptcon
= ptcon
->NEXT
)
1919 viewloinscon(ptcon
);
1920 pt
= getptype( ptins
->USER
, PH_INTERF
);
1923 (void)printf(" | |---connector list physical order\n");
1924 for( scanchain
= (chain_list
*)(pt
->DATA
); scanchain
; scanchain
= scanchain
->NEXT
)
1925 (void)printf(" | | |---%s\n",(char*)(scanchain
->DATA
) );
1926 (void)printf(" | |\n");
1929 if (ptins
->USER
!= NULL
)
1930 (void)printf(" | |---non empty USER field\n");
1931 (void)printf(" | \n");
1934 /*******************************************************************************
1935 * function viewlotrs() *
1936 *******************************************************************************/
1937 void viewlotrs(pttrs
)
1940 (void)printf(" |---transistor\n");
1941 if (MLO_IS_TRANSN(pttrs
->TYPE
))
1942 (void)printf(" | |---type : TRANSN \n");
1943 else if (MLO_IS_TRANSP(pttrs
->TYPE
))
1944 (void)printf(" | |---type : TRANSP \n");
1946 (void)printf(" | |---illegal type\n");
1947 if (pttrs
->TRNAME
!= NULL
)
1948 (void)printf(" | |---name : %s\n", pttrs
->TRNAME
);
1950 (void)printf(" | |---no name\n" );
1952 if (pttrs
->SOURCE
== NULL
)
1953 (void)printf(" | |--- !!! no signal on source !!! \n");
1955 viewloinscon( pttrs
->SOURCE
);
1957 if (pttrs
->GRID
== NULL
)
1958 (void)printf(" | |--- !!! no signal on grid !!!\n");
1960 viewloinscon( pttrs
->GRID
);
1962 if (pttrs
->DRAIN
== NULL
)
1963 (void)printf(" | |--- !!! no signal on drain !!!\n");
1965 viewloinscon( pttrs
->DRAIN
);
1967 if (pttrs
->BULK
== NULL
)
1968 (void)printf(" | |--- !!! no signal on bulk !!!\n");
1970 viewloinscon( pttrs
->BULK
);
1972 (void)printf(" | |---x : %ld\n", pttrs
->X
);
1973 (void)printf(" | |---y : %ld\n", pttrs
->Y
);
1974 (void)printf(" | |---width : %ld\n", pttrs
->WIDTH
);
1975 (void)printf(" | |---length : %ld\n", pttrs
->LENGTH
);
1976 (void)printf(" | |---ps : %ld\n", pttrs
->PS
);
1977 (void)printf(" | |---pd : %ld\n", pttrs
->PD
);
1978 (void)printf(" | |---xs : %ld\n", pttrs
->XS
);
1979 (void)printf(" | |---xd : %ld\n", pttrs
->XD
);
1980 if (pttrs
->USER
!= NULL
)
1981 (void)printf(" | |---non empty USER field\n");
1982 (void)printf(" |\n");
1985 /*******************************************************************************
1986 * function viewloinscon() *
1987 *******************************************************************************/
1988 void viewloinscon(ptcon
)
1992 ptype_list
*scanptype
;
1993 chain_list
*scanchain
;
1995 if (ptcon
->NAME
== NULL
)
1996 (void)printf(" | |---no connector name\n");
1998 (void)printf(" | |---connector : \"%s\"\n" , ptcon
->NAME
);
1999 (void)printf(" | | |---direction : %c\n" , ptcon
->DIRECTION
);
2000 if (ptcon
->SIG
== NULL
)
2001 (void)printf(" | | |---no signal\n");
2003 (void)printf(" | | |---signal : %ld\n" , ptcon
->SIG
->INDEX
);
2004 if ((ptcon
->ROOT
) == NULL
)
2005 (void)printf(" | | |---no root\n");
2007 switch( ptcon
->TYPE
)
2010 (void)printf(" | | |---root : %s\n" , ((char*)(((loins_list
*)(ptcon
->ROOT
))->INSNAME
)));
2013 (void)printf(" | | |---root : %s\n" ,
2014 ((lotrs_list
*)(ptcon
->ROOT
))->TRNAME
?((lotrs_list
*)(ptcon
->ROOT
))->TRNAME
:"no transistor name" );
2017 (void)printf(" | | |---root : *** BAD TYPE ***\n" );
2019 (void)printf(" | | |---type : %c\n" , ptcon
->TYPE
);
2020 if(ptcon
->PNODE
== NULL
)
2021 (void)printf(" | | |---no node\n");
2023 (void)printf(" | | |---node\n");
2024 for(scannum
= ptcon
->PNODE
; scannum
; scannum
= scannum
->NEXT
)
2025 (void)printf(" | | | |---%ld\n",scannum
->DATA
);
2027 (void)printf(" | | |---USER list\n");
2028 for( scanptype
= ptcon
->USER
; scanptype
; scanptype
= scanptype
->NEXT
)
2030 switch( scanptype
->TYPE
)
2033 (void)printf(" | | | |---PNODENAME\n");
2034 for( scanchain
= (chain_list
*)(scanptype
->DATA
);
2036 scanchain
= scanchain
->NEXT
)
2037 (void)printf(" | | | | |---%s\n", (char*)(scanchain
->DATA
)?(char*)(scanchain
->DATA
):"NULL" );
2040 (void)printf(" | | | |---%ld\n",scanptype
->TYPE
);
2043 (void)printf(" | | \n");
2046 /*******************************************************************************
2047 * function getsigsize() *
2048 *******************************************************************************/
2050 int getsigsize( ptfig
)
2055 ptl
= getptype( ptfig
->USER
, PTSIGSIZE
);
2057 return( (int)((long)(ptl
->DATA
)) );
2062 /*******************************************************************************
2063 * function setsigsize() *
2064 *******************************************************************************/
2066 void setsigsize( ptfig
, nb
)
2072 if( ptfig
->BKSIG
.TAB
)
2074 avt_errmsg (MBK_ERRMSG
, "034", AVT_FATAL
);
2077 ptl
= getptype( ptfig
->USER
, PTSIGSIZE
);
2079 ptfig
->USER
= addptype( ptfig
->USER
, PTSIGSIZE
, (void*)((long)nb
) );
2081 ptl
->DATA
= (void*)((long)nb
);
2085 int getnumberoflosig( ptfig
)
2096 if (!ptfig
->BKSIG
.TAB
) return 0;
2097 return ptfig
->BKSIG
.maxindex
;
2099 sz = getsigsize( ptfig );
2107 for( ptl = ptfig->BKSIG ; ptl ; ptl = ptl->NEXT ) {
2108 if( ptl->TYPE > bkmax && ptl->TYPE < bkmaxmax ) {
2113 if( bkmax == -1 ) break;
2117 for( i = 0 ; i<sz ; i++ ) {
2118 if( blk[i].INDEX > max )
2129 /*******************************************************************************
2130 * function for cleaning USER field of structures. *
2131 *******************************************************************************/
2133 void delloconuser( ptlocon
)
2134 locon_list
*ptlocon
;
2136 ptype_list
*scanptype
;
2142 for( scanptype
= ptlocon
->USER
; scanptype
; scanptype
= next
)
2144 next
= scanptype
->NEXT
;
2147 switch( scanptype
->TYPE
)
2150 freechain( scanptype
->DATA
);
2154 #ifdef MBK_TRACE_BAD_PTYPE
2155 fprintf( stderr
, "WARNING in delloconuser() : unknown ptype %08X\n",
2156 (unsigned int)scanptype
->TYPE
2165 ptlocon->USER = next;
2168 scanptype->NEXT = NULL;
2169 freeptype( scanptype );
2175 freeptype(ptlocon
->USER
); ptlocon
->USER
=NULL
;
2178 //typedef struct eqt_param eqt_param;
2179 //extern void eqt_free_param (eqt_param *param);
2181 void dellofiguser( ptlofig
)
2182 lofig_list
*ptlofig
;
2184 ptype_list
*scanptype
;
2190 for( scanptype
= ptlofig
->USER
; scanptype
; scanptype
= next
)
2192 next
= scanptype
->NEXT
;
2195 switch( scanptype
->TYPE
)
2198 eqt_free_param((eqt_param
*)scanptype
->DATA
);
2201 freeoptparams(scanptype
->DATA
);
2203 case PH_REAL_INTERF
:
2205 freechain( scanptype
->DATA
);
2212 case LOFIG_QUICK_SIG_HT
:
2213 case LOFIG_QUICK_INS_HT
:
2214 case LOFIG_QUICK_TRS_HT
:
2215 delht_v2((ht_v2
*)scanptype
->DATA
);
2219 mbkfree(scanptype
->DATA
);
2221 case 0x00079350: // SPEF_INDEX
2222 delit((it
*)scanptype
->DATA
);
2225 #ifdef MBK_TRACE_BAD_PTYPE
2226 fprintf( stderr
, "WARNING in dellofiguser() : unknown ptype %08X\n",
2227 (unsigned int)scanptype
->TYPE
2236 ptlofig->USER = next;
2239 scanptype->NEXT = NULL;
2240 freeptype( scanptype );
2246 freeptype(ptlofig
->USER
); ptlofig
->USER
=NULL
;
2249 void delloinsuser( ptloins
)
2250 loins_list
*ptloins
;
2252 ptype_list
*scanptype
;
2258 for( scanptype
= ptloins
->USER
; scanptype
; scanptype
= next
)
2260 next
= scanptype
->NEXT
;
2263 switch( scanptype
->TYPE
)
2266 eqt_free_param((eqt_param
*)scanptype
->DATA
);
2269 case PH_REAL_INTERF
: // should not happen for now, perhaps later
2270 freechain( scanptype
->DATA
);
2274 #ifdef MBK_TRACE_BAD_PTYPE
2275 fprintf( stderr
, "WARNING in delloinsuser() : unknown ptype %08X\n",
2276 (unsigned int)scanptype
->TYPE
2285 ptloins->USER = next;
2288 scanptype->NEXT = NULL;
2289 freeptype( scanptype );
2295 freeptype(ptloins
->USER
); ptloins
->USER
=NULL
;
2298 void dellotrsuser( ptlotrs
)
2299 lotrs_list
*ptlotrs
;
2301 ptype_list
*scanptype
;
2307 for( scanptype
= ptlotrs
->USER
; scanptype
; scanptype
= next
)
2309 next
= scanptype
->NEXT
;
2312 switch( scanptype
->TYPE
)
2315 eqt_free_param((eqt_param
*)scanptype
->DATA
);
2318 freeoptparams((optparam_list
*)scanptype
->DATA
);
2320 case MCC_COMPUTED_KEY
:
2321 freechain((chain_list
*)scanptype
->DATA
);
2324 #ifdef MBK_TRACE_BAD_PTYPE
2325 fprintf( stderr
, "WARNING in dellotrsuser() : unknown ptype %08X\n",
2326 (unsigned int)scanptype
->TYPE
2335 ptlotrs->USER = next;
2338 scanptype->NEXT = NULL;
2339 freeptype( scanptype );
2345 freeptype(ptlotrs
->USER
); ptlotrs
->USER
=NULL
;
2348 void dellosiguser( ptlosig
)
2349 losig_list
*ptlosig
;
2351 ptype_list
*scanptype
;
2358 for( scanptype
= ptlosig
->USER
; scanptype
; scanptype
= next
)
2360 next
= scanptype
->NEXT
;
2363 switch( scanptype
->TYPE
)
2369 case LOFIGCHAIN_LOCAL
:
2370 freechain( scanptype
->DATA
);
2373 case MBK_VCARD_NODES
:
2374 for (cl
=(chain_list
*)scanptype
->DATA
; cl
!=NULL
; cl
=cl
->NEXT
)
2376 freechain((chain_list
*)scanptype
->DATA
);
2379 #ifdef MBK_TRACE_BAD_PTYPE
2380 fprintf( stderr
, "WARNING in dellosiguser() : unknown ptype %08X\n",
2381 (unsigned int)scanptype
->TYPE
2390 ptlosig->USER = next;
2393 scanptype->NEXT = NULL;
2394 freeptype( scanptype );
2400 freeptype(ptlosig
->USER
); ptlosig
->USER
=NULL
;
2403 void locklofig( lofig_list
*ptfig
)
2405 if( !getptype( ptfig
->USER
, LOFIG_LOCK
) )
2406 ptfig
->USER
= addptype( ptfig
->USER
, LOFIG_LOCK
, NULL
);
2409 void unlocklofig( lofig_list
*ptfig
)
2411 if( getptype( ptfig
->USER
, LOFIG_LOCK
) )
2412 ptfig
->USER
= delptype( ptfig
->USER
, LOFIG_LOCK
);
2415 int islofiglocked( lofig_list
*ptfig
)
2417 if( getptype( ptfig
->USER
, LOFIG_LOCK
) ) return 1;
2421 losig_list
* mbk_getlosigbyname( lofig_list
*lofig
, char *name
)
2426 name
= namealloc( name
);
2428 for( losig
= lofig
->LOSIG
; losig
; losig
= losig
->NEXT
) {
2429 for( scan
= losig
->NAMECHAIN
; scan
; scan
= scan
->NEXT
) {
2430 if( scan
->DATA
== name
)
2438 losig_list
* mbk_quickly_getlosigbyname( lofig_list
*lofig
, char *name
)
2446 if ((name
= namefind( name
))==NULL
) return NULL
;
2448 if ((p
=getptype(lofig
->USER
, LOFIG_QUICK_SIG_HT
))==NULL
)
2450 l
=(countchain((chain_list
*)lofig
->LOSIG
)+19)/20;
2452 for( losig
= lofig
->LOSIG
; losig
; losig
= losig
->NEXT
) {
2453 for( scan
= losig
->NAMECHAIN
; scan
; scan
= scan
->NEXT
) {
2454 addhtitem_v2(h
, scan
->DATA
, (long)losig
);
2457 p
=lofig
->USER
=addptype(lofig
->USER
, LOFIG_QUICK_SIG_HT
, h
);
2460 if ((l
=gethtitem_v2((ht_v2
*)p
->DATA
, name
))==EMPTYHT
) return NULL
;
2461 return (losig_list
*)l
;
2464 // for this one name must be nameallocated
2465 loins_list
* mbk_quickly_getloinsbyname( lofig_list
*lofig
, char *name
)
2472 if ((p
=getptype(lofig
->USER
, LOFIG_QUICK_INS_HT
))==NULL
)
2474 l
=(countchain((chain_list
*)lofig
->LOINS
)+19)/20;
2476 for( li
= lofig
->LOINS
; li
; li
= li
->NEXT
) {
2477 addhtitem_v2(h
, li
->INSNAME
, (long)li
);
2479 p
=lofig
->USER
=addptype(lofig
->USER
, LOFIG_QUICK_INS_HT
, h
);
2482 if ((l
=gethtitem_v2((ht_v2
*)p
->DATA
, name
))==EMPTYHT
) return NULL
;
2483 return (loins_list
*)l
;
2486 // for this one name must be nameallocated
2487 lotrs_list
* mbk_quickly_getlotrsbyname( lofig_list
*lofig
, char *name
)
2489 lotrs_list
*ptlotrs
;
2494 if ((ptuser
=getptype(lofig
->USER
, LOFIG_QUICK_TRS_HT
))==NULL
)
2496 l
=(countchain((chain_list
*)lofig
->LOTRS
)+19)/20;
2498 for( ptlotrs
= lofig
->LOTRS
; ptlotrs
; ptlotrs
= ptlotrs
->NEXT
) {
2499 addhtitem_v2(h
, ptlotrs
->TRNAME
, (long)ptlotrs
);
2501 ptuser
=lofig
->USER
=addptype(lofig
->USER
, LOFIG_QUICK_TRS_HT
, h
);
2504 if ((l
=gethtitem_v2((ht_v2
*)ptuser
->DATA
, name
))==EMPTYHT
) return NULL
;
2505 return (lotrs_list
*)l
;
2508 int mbk_istranscrypt(char *name
)
2510 chain_list
*ptchain
;
2512 // name = namealloc(name);
2513 for (ptchain
= CRYPTMOS
; ptchain
; ptchain
= ptchain
->NEXT
) {
2514 if (ptchain
->DATA
== name
) return 1;
2519 int mbk_istransn(char *name
)
2521 chain_list
*ptchain
;
2523 // name = namealloc(name);
2524 for (ptchain
= TNMOS
; ptchain
; ptchain
= ptchain
->NEXT
) {
2525 if (ptchain
->DATA
== name
) return 1;
2530 int mbk_istransp(char *name
)
2532 chain_list
*ptchain
;
2534 // name = namealloc(name);
2535 for (ptchain
= TPMOS
; ptchain
; ptchain
= ptchain
->NEXT
) {
2536 if (ptchain
->DATA
== name
) return 1;
2541 char mbk_gettranstype(char *type
)
2543 if (mbk_istransn(type
))
2545 else if (mbk_istransp(type
))
2551 int mbk_isdioden(char *name
)
2553 chain_list
*ptchain
;
2555 name
= namealloc(name
);
2556 for (ptchain
= DNMOS
; ptchain
; ptchain
= ptchain
->NEXT
) {
2557 if (ptchain
->DATA
== name
) return 1;
2562 int mbk_isdiodep(char *name
)
2564 chain_list
*ptchain
;
2566 name
= namealloc(name
);
2567 for (ptchain
= DPMOS
; ptchain
; ptchain
= ptchain
->NEXT
) {
2568 if (ptchain
->DATA
== name
) return 1;
2573 char mbk_getdiodetype(char *type
)
2575 if (mbk_isdioden(type
))
2577 else if (mbk_isdiodep(type
))
2583 int mbk_isjfetn(char *name
)
2585 chain_list
*ptchain
;
2587 name
= namealloc(name
);
2588 for (ptchain
= JFETN
; ptchain
; ptchain
= ptchain
->NEXT
) {
2589 if (ptchain
->DATA
== name
) return 1;
2594 int mbk_isjfetp(char *name
)
2596 chain_list
*ptchain
;
2598 name
= namealloc(name
);
2599 for (ptchain
= JFETP
; ptchain
; ptchain
= ptchain
->NEXT
) {
2600 if (ptchain
->DATA
== name
) return 1;
2605 char mbk_getjfettype(char *type
)
2607 if (mbk_isjfetn(type
))
2609 else if (mbk_isjfetp(type
))
2615 /*******************************************************************************
2617 Fonction de positionnement d'un offset pour l'acces direct dans des fichiers
2620 *******************************************************************************/
2622 void mbk_losig_setfilepos( lofig_list
*lofig
,
2625 MBK_OFFSET_MAX
*pos
,
2634 MBK_OFFSET_STD offset_std
;
2635 MBK_OFFSET_LFS offset_lfs
;
2636 MBK_OFFSET_LFS
*ptoffset_lfs
;
2639 ptl
= getptype( lofig
->USER
, flagtab
);
2642 lofig
->USER
= addptype( lofig
->USER
, flagtab
, look
);
2645 look
= (it
*)ptl
->DATA
;
2648 if( mbk_getfileacces( file
) == MBK_FILE_STD
) {
2649 offset_std
= *(MBK_OFFSET_STD
*)pos
;
2650 setititem( look
, losig
->INDEX
, (long)offset_std
);
2652 else { //MBK_FILE_LFS
2654 offset_lfs
= *(MBK_OFFSET_LFS
*)pos
;
2655 ptl
= getptype( lofig
->USER
, flagheap
);
2657 heap
= mbkalloc( sizeof(HeapAlloc
) );
2658 CreateHeap( sizeof(MBK_OFFSET_LFS
), 32, heap
);
2659 lofig
->USER
= addptype( lofig
->USER
, flagheap
, heap
);
2662 ptl
= getptype( lofig
->USER
, flagheap
);
2663 heap
= (HeapAlloc
*)ptl
->DATA
;
2666 ptoffset_lfs
= (MBK_OFFSET_LFS
*) getititem( look
, losig
->INDEX
);
2667 if( ptoffset_lfs
== (MBK_OFFSET_LFS
*)EMPTYHT
) {
2668 ptoffset_lfs
= AddHeapItem( heap
);
2669 setititem( look
, losig
->INDEX
, (long)ptoffset_lfs
);
2671 *ptoffset_lfs
= offset_lfs
;
2675 char mbk_losig_getfilepos( lofig_list
*lofig
,
2678 MBK_OFFSET_MAX
*pos
,
2684 MBK_OFFSET_LFS
*offset_lfs
;
2685 MBK_OFFSET_STD offset_std
;
2688 ptl
= getptype( lofig
->USER
, flagtab
);
2691 lofig
->USER
= addptype( lofig
->USER
, flagtab
, look
);
2694 look
= (it
*)ptl
->DATA
;
2697 if( mbk_getfileacces( file
) == MBK_FILE_STD
) {
2698 offset_std
= (MBK_OFFSET_STD
)getititem( look
, losig
->INDEX
);
2699 if( offset_std
== (MBK_OFFSET_STD
)EMPTYHT
||
2700 offset_std
== (MBK_OFFSET_STD
)DELETEHT
){
2701 *(MBK_OFFSET_STD
*)pos
= (MBK_OFFSET_STD
)0;
2704 *(MBK_OFFSET_STD
*)pos
= offset_std
;
2709 offset_lfs
= (MBK_OFFSET_LFS
*)getititem( look
, losig
->INDEX
);
2710 if( offset_lfs
== (MBK_OFFSET_LFS
*)EMPTYHT
||
2711 offset_lfs
== (MBK_OFFSET_LFS
*)DELETEHT
){
2712 *(MBK_OFFSET_LFS
*)pos
= (MBK_OFFSET_LFS
)0;
2715 *(MBK_OFFSET_LFS
*)pos
= *offset_lfs
;
2721 void mbk_losig_clearfilepos( lofig_list
*lofig
,
2729 ptl
= getptype( lofig
->USER
, flagtab
);
2731 delit( (it
*)ptl
->DATA
);
2732 lofig
->USER
= delptype( lofig
->USER
, flagtab
);
2735 ptl
= getptype( lofig
->USER
, flagheap
);
2737 DeleteHeap( (HeapAlloc
*)ptl
->DATA
);
2738 mbkfree( ptl
->DATA
);
2739 lofig
->USER
= delptype( lofig
->USER
, flagheap
);
2742 file
=NULL
; //unused parameter.
2745 void mbkSwitchContext(mbkContext
*ctx
)
2748 lofig_list
*temphead
;
2750 temphead
=HEAD_LOFIG
;
2751 HT_LOFIG
=ctx
->HT_LOFIG
;
2752 HEAD_LOFIG
=ctx
->HEAD_LOFIG
;
2753 ctx
->HT_LOFIG
=tempht
;
2754 ctx
->HEAD_LOFIG
=temphead
;
2757 mbkContext
*mbkCreateContext()
2759 mbkContext
*ctx
=(mbkContext
*)mbkalloc(sizeof(mbkContext
));
2760 ctx
->HT_LOFIG
=addht(100);
2761 ctx
->HEAD_LOFIG
=NULL
;
2765 void mbkFreeContext(mbkContext
*ctx
)
2770 void mbkFreeAndSwitchContext(mbkContext
*ctx
)
2772 mbkSwitchContext(ctx
);
2773 delht(ctx
->HT_LOFIG
);
2777 /*******************************************************************************
2778 * Power Supply Marking Functions *
2779 *******************************************************************************/
2781 int mbk_MarkAlim(losig_list
*ls
)
2787 if (getlosigalim(ls
, &value
))
2789 if ((long)(value
*SCALE_ALIM
+ 0.5) > VDD_VSS_THRESHOLD
) flags
|=MBK_ALIM_VDD_FLAG
;
2790 else flags
|=MBK_ALIM_VSS_FLAG
;
2793 for (ch
=ls
->NAMECHAIN
; ch
!=NULL
; ch
=ch
->NEXT
)
2796 if (ls
->TYPE
=='D') flags
|=MBK_ALIM_VDD_FLAG
;
2797 else if (ls
->TYPE
=='S') flags
|=MBK_ALIM_VSS_FLAG
;
2799 if (isvss((char *)ch
->DATA
)) flags
|=MBK_ALIM_VSS_FLAG
;
2800 if (isvdd((char *)ch
->DATA
)) flags
|=MBK_ALIM_VDD_FLAG
;
2801 if (isglobalvss((char *)ch
->DATA
)) flags
|=MBK_ALIM_VSS_FLAG
|MBK_HAS_GLOBAL_NODE_FLAG
;
2802 if (isglobalvdd((char *)ch
->DATA
)) flags
|=MBK_ALIM_VDD_FLAG
|MBK_HAS_GLOBAL_NODE_FLAG
;
2805 ls
->ALIMFLAGS
&=~(MBK_ALIM_VSS_FLAG
|MBK_ALIM_VDD_FLAG
);
2806 ls
->ALIMFLAGS
|=flags
|MBK_SIGNAL_ALIM_DONE_FLAG
;
2811 void mbk_MarkLofig(lofig_list
*lf
)
2814 for (ls
=lf
->LOSIG
; ls
!=NULL
; ls
=ls
->NEXT
)
2818 int mbk_GetAlimFlags(losig_list
*ls
)
2820 if ((ls
->ALIMFLAGS
& MBK_SIGNAL_ALIM_DONE_FLAG
)==0)
2822 return ls
->ALIMFLAGS
;
2825 int mbk_LosigIsVDD(losig_list
*ls
)
2827 if ((ls
->ALIMFLAGS
& MBK_SIGNAL_ALIM_DONE_FLAG
)==0)
2829 return (ls
->ALIMFLAGS
& MBK_ALIM_VDD_FLAG
)!=0;
2832 int mbk_LosigIsVSS(losig_list
*ls
)
2834 if ((ls
->ALIMFLAGS
& MBK_SIGNAL_ALIM_DONE_FLAG
)==0)
2836 return (ls
->ALIMFLAGS
& MBK_ALIM_VSS_FLAG
)!=0;
2839 int mbk_LosigIsGlobal(losig_list
*ls
)
2841 return (ls
->ALIMFLAGS
& MBK_HAS_GLOBAL_NODE_FLAG
)!=0;
2844 void mbk_SetLosigVDD(losig_list
*ls
)
2846 ls
->ALIMFLAGS
&=~(MBK_ALIM_VSS_FLAG
|MBK_ALIM_VDD_FLAG
);
2847 ls
->ALIMFLAGS
|= (MBK_ALIM_VDD_FLAG
|MBK_SIGNAL_ALIM_DONE_FLAG
);
2850 void mbk_SetLosigVSS(losig_list
*ls
)
2852 ls
->ALIMFLAGS
&=~(MBK_ALIM_VSS_FLAG
|MBK_ALIM_VDD_FLAG
);
2853 ls
->ALIMFLAGS
|= (MBK_ALIM_VSS_FLAG
|MBK_SIGNAL_ALIM_DONE_FLAG
);
2856 /*##------------------------------------------------------------------##*/
2857 /* Function : duplosigalim() */
2858 /*##------------------------------------------------------------------##*/
2860 void duplosigalim (losig_ptr
, losig_rpt
)
2861 losig_list
*losig_ptr
;
2862 losig_list
*losig_rpt
;
2867 expr
=getlosigalim_expr(losig_ptr
);
2868 if (getlosigalim (losig_ptr
, &alim
) || expr
!=NULL
)
2869 addlosigalim (losig_rpt
, alim
, expr
);
2872 void mbk_copylosiginfo(losig_list
*source
, losig_list
*dest
)
2874 duplosigalim (source
, dest
);
2875 dest
->ALIMFLAGS
=source
->ALIMFLAGS
;
2878 /*******************************************************************************
2879 * function addlosigalim *
2880 *******************************************************************************/
2881 void addlosigalim(losig_list
*losig
, float alim
, char *expr
)
2889 if((ptype
= getptype(losig
->USER
,LOSIGALIM_EXPR
)) == NULL
)
2890 losig
->USER
= addptype(losig
->USER
,LOSIGALIM_EXPR
,expr
) ;
2893 avt_errmsg (MBK_ERRMSG
, "035", AVT_WARNING
, getsigname(losig
));
2899 lalim
= (long)(SCALE_ALIM
* alim
+ 0.5) ;
2901 if((ptype
= getptype(losig
->USER
,LOSIGALIM
)) == NULL
)
2902 losig
->USER
= addptype(losig
->USER
,LOSIGALIM
,(void *)lalim
) ;
2905 avt_errmsg (MBK_ERRMSG
, "035", AVT_WARNING
, getsigname(losig
));
2906 ptype
->DATA
= (void *)lalim
;
2908 /* Add the Supply Marks */
2909 mbk_MarkAlim(losig
);
2913 /*******************************************************************************
2914 * function dellosigalim *
2915 *******************************************************************************/
2916 int dellosigalim(losig_list
*losig
)
2918 if(getptype(losig
->USER
,LOSIGALIM
) != NULL
)
2920 losig
->USER
= delptype(losig
->USER
,LOSIGALIM
) ;
2926 void dellosigalim_expr(losig_list
*losig
)
2928 if(getptype(losig
->USER
,LOSIGALIM_EXPR
) != NULL
)
2930 losig
->USER
= delptype(losig
->USER
,LOSIGALIM_EXPR
) ;
2934 /*******************************************************************************
2935 * function getlosigalim *
2936 *******************************************************************************/
2937 int getlosigalim(losig_list
*losig
, float *alim
)
2942 if((ptype
= getptype(losig
->USER
,LOSIGALIM
)) != NULL
)
2944 lalim
= (long)ptype
->DATA
;
2946 *alim
= (float)lalim
/ SCALE_ALIM
;
2952 char *getlosigalim_expr(losig_list
*losig
)
2956 if((ptype
= getptype(losig
->USER
,LOSIGALIM_EXPR
)) != NULL
)
2957 return (char *)ptype
->DATA
;
2962 lofiginfo
*mbk_getlofiginfo(lofig_list
*lf
, int create
)
2966 pt
=getptype(lf
->USER
, LOFIG_INFO
);
2969 if (!create
) return NULL
;
2971 else return (lofiginfo
*)pt
->DATA
;
2972 lfif
=mbkalloc(sizeof(lofiginfo
));
2976 lf
->USER
=addptype(lf
->USER
, LOFIG_INFO
, lfif
);
2980 int mbk_can_cross_transistor_to(losig_list
*ls
, lotrs_list
*tr
, char dir
)
2982 locon_list
*from
, *to
;
2983 long flagfrom
, flagto
, testfrom
, testto
;
2985 if (ls
==tr
->SOURCE
->SIG
) from
=tr
->SOURCE
, to
=tr
->DRAIN
;
2986 else to
=tr
->SOURCE
, from
=tr
->DRAIN
;
2987 if ((pt
=getptype(from
->USER
, LOCON_INFORMATION
))==NULL
) flagfrom
=0;
2988 else flagfrom
=(long)pt
->DATA
;
2989 if ((pt
=getptype(to
->USER
, LOCON_INFORMATION
))==NULL
) flagto
=0;
2990 else flagto
=(long)pt
->DATA
;
2992 if (dir
=='i') testfrom
=LOCON_INFORMATION_OUTPUT
, testto
=LOCON_INFORMATION_INPUT
;
2993 else testfrom
=LOCON_INFORMATION_INPUT
, testto
=LOCON_INFORMATION_OUTPUT
;
2995 if (flagfrom
!=0 && (flagfrom
& testfrom
)==0) return 0;
2996 if (flagto
!=0 && (flagto
& testto
)==0) return 0;
3000 void mbk_debug_losig( char *label
, lofig_list
*lofig
)
3004 if ((name
=getenv("MBK_DEBUG_LOSIG"))!=NULL
)
3006 ls
= mbk_quickly_getlosigbyname( lofig
,namealloc(name
) );
3007 printf("debug_losig (%s) %s:\n", label
, name
);
3009 viewlosig_sub(ls
,1);
3011 printf("signal not found\n");