⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cktfdev.c

📁 spice中支持多层次元件模型仿真的可单独运行的插件源码
💻 C
字号:
/**********Copyright 1990 Regents of the University of California.  All rights reserved.Author: 1985 Thomas L. Quarles**********/#include "spice.h"#include <stdio.h>#include "ifsim.h"#include "cktdefs.h"#include "util.h"#include "sperror.h"#include "suffix.h"intCKTfndDev(Ckt,type,fast,name,modfast,modname)    GENERIC *Ckt;    int *type;    GENERIC **fast;    IFuid name;    GENERIC *modfast;    IFuid modname;{    register CKTcircuit *ckt=(CKTcircuit *)Ckt;    register GENinstance *here;    register GENmodel *mods;    if((GENinstance **)fast != (GENinstance **)NULL &&             *(GENinstance **)fast != (GENinstance *)NULL) {        /* already have  fast, so nothing much to do */        /* just get & set type */        if(type) *type = (*((GENinstance**)fast))->GENmodPtr->GENmodType;        return(OK);    }     if(modfast) {        /* have model, just need device */        mods = (GENmodel*)modfast;        for(here = mods->GENinstances ; here != NULL;                 here = here->GENnextInstance) {            if (here->GENname == name) {                if(fast != NULL) *(GENinstance **)fast = here;                if(type) *type = mods->GENmodType;                return(OK);            }        }        return(E_NODEV);    }    if(*type >=0 && *type < DEVmaxnum) {        /* have device type, need to find model & device */        /* look through all models */        for(mods=(GENmodel *)ckt->CKThead[*type]; mods != NULL ;                 mods = mods->GENnextModel) {            /* and all instances */            if(modname == (char *)NULL || mods->GENmodName == modname) {                for(here = mods->GENinstances ; here != NULL;                         here = here->GENnextInstance) {                    if (here->GENname == name) {                        if(fast != 0) *(GENinstance **)fast = here;                        return(OK);                    }                }                if(mods->GENmodName == modname) {                    return(E_NODEV);                }            }        }        return(E_NOMOD);    } else if(*type == -1) {        /* look through all types (UGH - worst case - take forever) */         for(*type = 0;*type <DEVmaxnum;(*type)++) {            /* need to find model & device */            /* look through all models */            for(mods=(GENmodel *)ckt->CKThead[*type];mods!=NULL;                    mods = mods->GENnextModel) {                /* and all instances */                if(modname == (char *)NULL || mods->GENmodName == modname) {                    for(here = mods->GENinstances ; here != NULL;                             here = here->GENnextInstance) {                        if (here->GENname == name) {                            if(fast != 0) *(GENinstance **)fast = here;                            return(OK);                        }                    }                    if(mods->GENmodName == modname) {                        return(E_NODEV);                    }                }            }        }        *type = -1;        return(E_NODEV);    } else return(E_BADPARM);}

⌨️ 快捷键说明

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