New Binding Method extended to NUMOS device
This commit is contained in:
parent
cec742b0fa
commit
d343f4c57b
|
|
@ -24,6 +24,17 @@ libnumos_la_SOURCES = \
|
|||
nummtrun.c
|
||||
|
||||
|
||||
if KLU_WANTED
|
||||
libnumos_la_SOURCES += numosbindCSC.c
|
||||
endif
|
||||
|
||||
if SuperLU_WANTED
|
||||
libnumos_la_SOURCES += numosbindCSC.c
|
||||
endif
|
||||
|
||||
if UMFPACK_WANTED
|
||||
libnumos_la_SOURCES += numosbindCSC.c
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include
|
||||
AM_CFLAGS = $(STATIC)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,309 @@
|
|||
/**********
|
||||
Author: 2013 Francesco Lannutti
|
||||
**********/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
#include "ngspice/cktdefs.h"
|
||||
#include "numosdef.h"
|
||||
#include "ngspice/sperror.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static
|
||||
int
|
||||
BindCompare (const void *a, const void *b)
|
||||
{
|
||||
BindElement *A, *B ;
|
||||
A = (BindElement *)a ;
|
||||
B = (BindElement *)b ;
|
||||
|
||||
return ((int)(A->Sparse - B->Sparse)) ;
|
||||
}
|
||||
|
||||
int
|
||||
NUMOSbindCSC (GENmodel *inModel, CKTcircuit *ckt)
|
||||
{
|
||||
NUMOSmodel *model = (NUMOSmodel *)inModel ;
|
||||
NUMOSinstance *here ;
|
||||
double *i ;
|
||||
BindElement *matched, *BindStruct ;
|
||||
size_t nz ;
|
||||
|
||||
BindStruct = ckt->CKTmatrix->CKTbindStruct ;
|
||||
nz = (size_t)ckt->CKTmatrix->CKTklunz ;
|
||||
|
||||
/* loop through all the NUMOS models */
|
||||
for ( ; model != NULL ; model = model->NUMOSnextModel)
|
||||
{
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->NUMOSinstances ; here != NULL ; here = here->NUMOSnextInstance)
|
||||
{
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
{
|
||||
i = here->NUMOSdrainDrainPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSdrainDrainStructPtr = matched ;
|
||||
here->NUMOSdrainDrainPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
{
|
||||
i = here->NUMOSdrainSourcePtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSdrainSourceStructPtr = matched ;
|
||||
here->NUMOSdrainSourcePtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
{
|
||||
i = here->NUMOSdrainGatePtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSdrainGateStructPtr = matched ;
|
||||
here->NUMOSdrainGatePtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
{
|
||||
i = here->NUMOSdrainBulkPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSdrainBulkStructPtr = matched ;
|
||||
here->NUMOSdrainBulkPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
{
|
||||
i = here->NUMOSsourceDrainPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSsourceDrainStructPtr = matched ;
|
||||
here->NUMOSsourceDrainPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
{
|
||||
i = here->NUMOSsourceSourcePtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSsourceSourceStructPtr = matched ;
|
||||
here->NUMOSsourceSourcePtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
{
|
||||
i = here->NUMOSsourceGatePtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSsourceGateStructPtr = matched ;
|
||||
here->NUMOSsourceGatePtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
{
|
||||
i = here->NUMOSsourceBulkPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSsourceBulkStructPtr = matched ;
|
||||
here->NUMOSsourceBulkPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
{
|
||||
i = here->NUMOSgateDrainPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSgateDrainStructPtr = matched ;
|
||||
here->NUMOSgateDrainPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
{
|
||||
i = here->NUMOSgateSourcePtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSgateSourceStructPtr = matched ;
|
||||
here->NUMOSgateSourcePtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
{
|
||||
i = here->NUMOSgateGatePtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSgateGateStructPtr = matched ;
|
||||
here->NUMOSgateGatePtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
{
|
||||
i = here->NUMOSgateBulkPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSgateBulkStructPtr = matched ;
|
||||
here->NUMOSgateBulkPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
{
|
||||
i = here->NUMOSbulkDrainPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSbulkDrainStructPtr = matched ;
|
||||
here->NUMOSbulkDrainPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
{
|
||||
i = here->NUMOSbulkSourcePtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSbulkSourceStructPtr = matched ;
|
||||
here->NUMOSbulkSourcePtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
{
|
||||
i = here->NUMOSbulkGatePtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSbulkGateStructPtr = matched ;
|
||||
here->NUMOSbulkGatePtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
{
|
||||
i = here->NUMOSbulkBulkPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMOSbulkBulkStructPtr = matched ;
|
||||
here->NUMOSbulkBulkPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (OK) ;
|
||||
}
|
||||
|
||||
int
|
||||
NUMOSbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
|
||||
{
|
||||
NUMOSmodel *model = (NUMOSmodel *)inModel ;
|
||||
NUMOSinstance *here ;
|
||||
|
||||
NG_IGNORE (ckt) ;
|
||||
|
||||
/* loop through all the NUMOS models */
|
||||
for ( ; model != NULL ; model = model->NUMOSnextModel)
|
||||
{
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->NUMOSinstances ; here != NULL ; here = here->NUMOSnextInstance)
|
||||
{
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
here->NUMOSdrainDrainPtr = here->NUMOSdrainDrainStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
here->NUMOSdrainSourcePtr = here->NUMOSdrainSourceStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
here->NUMOSdrainGatePtr = here->NUMOSdrainGateStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
here->NUMOSdrainBulkPtr = here->NUMOSdrainBulkStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
here->NUMOSsourceDrainPtr = here->NUMOSsourceDrainStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
here->NUMOSsourceSourcePtr = here->NUMOSsourceSourceStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
here->NUMOSsourceGatePtr = here->NUMOSsourceGateStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
here->NUMOSsourceBulkPtr = here->NUMOSsourceBulkStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
here->NUMOSgateDrainPtr = here->NUMOSgateDrainStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
here->NUMOSgateSourcePtr = here->NUMOSgateSourceStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
here->NUMOSgateGatePtr = here->NUMOSgateGateStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
here->NUMOSgateBulkPtr = here->NUMOSgateBulkStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
here->NUMOSbulkDrainPtr = here->NUMOSbulkDrainStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
here->NUMOSbulkSourcePtr = here->NUMOSbulkSourceStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
here->NUMOSbulkGatePtr = here->NUMOSbulkGateStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
here->NUMOSbulkBulkPtr = here->NUMOSbulkBulkStructPtr->CSC_Complex ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (OK) ;
|
||||
}
|
||||
|
||||
int
|
||||
NUMOSbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
|
||||
{
|
||||
NUMOSmodel *model = (NUMOSmodel *)inModel ;
|
||||
NUMOSinstance *here ;
|
||||
|
||||
NG_IGNORE (ckt) ;
|
||||
|
||||
/* loop through all the NUMOS models */
|
||||
for ( ; model != NULL ; model = model->NUMOSnextModel)
|
||||
{
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->NUMOSinstances ; here != NULL ; here = here->NUMOSnextInstance)
|
||||
{
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
here->NUMOSdrainDrainPtr = here->NUMOSdrainDrainStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
here->NUMOSdrainSourcePtr = here->NUMOSdrainSourceStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
here->NUMOSdrainGatePtr = here->NUMOSdrainGateStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
here->NUMOSdrainBulkPtr = here->NUMOSdrainBulkStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
here->NUMOSsourceDrainPtr = here->NUMOSsourceDrainStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
here->NUMOSsourceSourcePtr = here->NUMOSsourceSourceStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
here->NUMOSsourceGatePtr = here->NUMOSsourceGateStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
here->NUMOSsourceBulkPtr = here->NUMOSsourceBulkStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
here->NUMOSgateDrainPtr = here->NUMOSgateDrainStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
here->NUMOSgateSourcePtr = here->NUMOSgateSourceStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
here->NUMOSgateGatePtr = here->NUMOSgateGateStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSgateNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
here->NUMOSgateBulkPtr = here->NUMOSgateBulkStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSdrainNode != 0))
|
||||
here->NUMOSbulkDrainPtr = here->NUMOSbulkDrainStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSsourceNode != 0))
|
||||
here->NUMOSbulkSourcePtr = here->NUMOSbulkSourceStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSgateNode != 0))
|
||||
here->NUMOSbulkGatePtr = here->NUMOSbulkGateStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSbulkNode != 0))
|
||||
here->NUMOSbulkBulkPtr = here->NUMOSbulkBulkStructPtr->CSC ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (OK) ;
|
||||
}
|
||||
|
|
@ -114,6 +114,26 @@ typedef struct sNUMOSinstance {
|
|||
unsigned NUMOSicFileGiven:1; /* flag to indicate init. cond. file given */
|
||||
unsigned NUMOSprintGiven:1; /* flag to indicate print was given */
|
||||
unsigned NUMOStempGiven:1; /* flag to indicate temp was given */
|
||||
|
||||
#ifdef KLU
|
||||
BindElement *NUMOSdrainDrainStructPtr ;
|
||||
BindElement *NUMOSdrainSourceStructPtr ;
|
||||
BindElement *NUMOSdrainGateStructPtr ;
|
||||
BindElement *NUMOSdrainBulkStructPtr ;
|
||||
BindElement *NUMOSsourceDrainStructPtr ;
|
||||
BindElement *NUMOSsourceSourceStructPtr ;
|
||||
BindElement *NUMOSsourceGateStructPtr ;
|
||||
BindElement *NUMOSsourceBulkStructPtr ;
|
||||
BindElement *NUMOSgateDrainStructPtr ;
|
||||
BindElement *NUMOSgateSourceStructPtr ;
|
||||
BindElement *NUMOSgateGateStructPtr ;
|
||||
BindElement *NUMOSgateBulkStructPtr ;
|
||||
BindElement *NUMOSbulkDrainStructPtr ;
|
||||
BindElement *NUMOSbulkSourceStructPtr ;
|
||||
BindElement *NUMOSbulkGateStructPtr ;
|
||||
BindElement *NUMOSbulkBulkStructPtr ;
|
||||
#endif
|
||||
|
||||
} NUMOSinstance;
|
||||
|
||||
/* per model data */
|
||||
|
|
|
|||
Loading…
Reference in New Issue