swsetup.c

来自「支持数字元件仿真的SPICE插件」· C语言 代码 · 共 69 行

C
69
字号
/* * Copyright (c) 1985 Gordon Jacobs */#include "prefix.h"#include <stdio.h>#include "SMPdefs.h"#include "CKTdefs.h"#include "SWdefs.h"#include "SPerror.h"#include "suffix.h"RCSID("SWsetup.c $Revision: 1.1 $ on $Date: 90/10/11 12:46:26 $")intSWsetup(matrix,inModel,ckt,states)    register SMPmatrix *matrix;    GENmodel *inModel;    CKTcircuit *ckt;    int *states;        /* load the switch conductance with those pointers needed later          * for fast matrix loading          */{    register SWmodel *model = (SWmodel *)inModel;    register SWinstance *here;    /*  loop through all the current source models */    for( ; model != NULL; model = model->SWnextModel ) {        /* Default Value Processing for Switch Model */        if (!model->SWthreshGiven) {            model->SWvThreshold = 0;        }         if (!model->SWhystGiven) {            model->SWvHysteresis = 0;        }         if (!model->SWonGiven)  {            model->SWonConduct = SW_ON_CONDUCTANCE;            model->SWonResistance = 1.0/model->SWonConduct;        }         if (!model->SWoffGiven)  {            model->SWoffConduct = SW_OFF_CONDUCTANCE;            model->SWoffResistance = 1.0/model->SWoffConduct;        }        /* loop through all the instances of the model */        for (here = model->SWinstances; here != NULL ;                here=here->SWnextInstance) {            /* Default Value Processing for Switch Instance */                    /* none *//* macro to make elements with built in test for out of memory */#define TSTALLOC(ptr,first,second) \if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\    return(E_NOMEM);\}            TSTALLOC(SWposPosptr, SWposNode, SWposNode)            TSTALLOC(SWposNegptr, SWposNode, SWnegNode)            TSTALLOC(SWnegPosptr, SWnegNode, SWposNode)            TSTALLOC(SWnegNegptr, SWnegNode, SWnegNode)            here->SWstate = *states;            *states += SW_NUM_STATES;        }    }    return(OK);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?