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

📄 inp2dot.c

📁 支持数字元件仿真的SPICE插件
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 1988 Thomas L. Quarles */#include "prefix.h"#include <stdio.h>#include "IFsim.h"#include "INPdefs.h"#include "INPmacs.h"#ifndef CMS#include "FTEextern.h"#else  /* CMS */#include "FTEexter.h"#endif /* CMS */#include "util.h"#include "suffix.h"RCSID("INP2dot.c $Revision: 1.2 $ on $Date: 91/05/17 11:01:27 $")intINP2dot(ckt,tab,current,task,gnode)    GENERIC *ckt;    INPtables *tab;    card *current;    GENERIC *task;    GENERIC *gnode;{    /* .<something> Many possibilities */char *line; /* the part of the current line left to parse */char *name; /* the resistor's name */char *nname1;   /* the first node's name */char *nname2;   /* the second node's name */GENERIC *node1; /* the first node's node pointer */GENERIC *node2; /* the second node's node pointer */int error;      /* error code temporary */IFvalue ptemp;  /* a value structure to package resistance into */IFvalue *parm;  /* a pointer to a value struct for function returns */IFparm *prm;    /* pointer to parameter to search through array */char *token;    /* a token from the line */int which;      /* which analysis we are performing */int i;          /* generic loop variable */GENERIC *foo;   /* pointer to analysis */int length;     /* length of a name */char *steptype; /* ac analysis, type of stepping function */double dtemp;   /* random double precision temporary */char *word;     /* something to stick a word of input into */    line = current->line;    INPgetTok(&line,&token,1);    if(strcmp(token,".model")==0) {        /* don't have to do anything, since models were all done in         * pass 1          */        return(0);    } else if ( (strcmp(token,".width")==0) ||            (strcmp(token,".print")==0) ||            (strcmp(token,".plot")==0)  ){        /* obsolete - ignore */        LITERR(" Warning: obsolete control card - ignored \n")        return(0);    } else if ( (strcmp(token,".temp")==0)){        /* .temp temp1 temp2 temp3 temp4 ..... */        /* not yet implemented - warn & ignore */        LITERR(" Warning: .TEMP card obsolete - use .options TEMP and TNOM\n")        return(0);    } else if ( (strcmp(token,".op")==0)){        /* .op */        which = -1;        for(i=0;i<ft_sim->numAnalyses;i++) {            if(strcmp(ft_sim->analyses[i]->name,"DCOP")==0) {                which=i;                break;            }        }        if(which == -1) {            LITERR("DC operating point analysis unsupported\n")            return(0);        }        IFC(newAnalysis,(ckt,which,"operating point",&foo, task))        return(0);    } else if ( (strcmp(token,".nodeset")==0)){        /* .nodeset */        which = -1;        for(prm=ft_sim->nodeParms;                prm<ft_sim->nodeParms+ft_sim->numNodeParms;prm++) {            if(strcmp(prm->keyword,"nodeset")==0) {                which=prm->id;                break;            }        }        if(which == -1) {            LITERR("nodeset unknown to simulator. \n")            return(0);        }        for(;;) { /* loop until we run out of data */            INPgetTok(&line,&name,1);            /* check to see if in the form V(xxx) and grab the xxx */            if( *name == (char)NULL) break; /* end of line */            length = strlen(name);            if( (*name == 'V' || *(name) == 'v') && (length == 1)){                /* looks like V - must be V(xx) - get xx now*/                INPgetTok(&line,&name,1);                INPtermInsert(ckt,&name,tab,&node1);                ptemp.rValue = INPevaluate(&line,&error,1);                IFC(setNodeParm,(ckt,node1,which,&ptemp,(IFvalue*)NULL))                continue;            }            LITERR(" Error: .nodeset syntax error.\n")            break;        }        return(0);    } else if ( (strcmp(token,".disto")==0)){        /* .disto */        /* not implemented - warn & ignore */        LITERR("Warning: distortion analysis not implemented-ignored\n")        return(0);    } else if ( (strcmp(token,".noise")==0)){        /* .noise */        /* not implemented - warn & ignore */        LITERR("Warning: noise analysis not implemented -ignored\n")        return(0);    } else if ( (strcmp(token,".four")==0) || (strcmp(token,".fourier")==0) ){        /* .four */        /* not implemented - warn & ignore */        LITERR("Use fourier command to obtain fourier analysis\n")        return(0);    } else if ( (strcmp(token,".ic")==0)){        /* .ic */        which = -1;        for(prm=ft_sim->nodeParms;                prm<ft_sim->nodeParms+ft_sim->numNodeParms;prm++) {            if(strcmp(prm->keyword,"ic")==0) {                which=prm->id;                break;            }        }        if(which==-1) {            LITERR("ic unknown to simulator. \n")            return(0);        }        for(;;) { /* loop until we run out of data */            INPgetTok(&line,&name,1);            /* check to see if in the form V(xxx) and grab the xxx */            if( *name == (char)NULL) break; /* end of line */            length = strlen(name);            if( (*name == 'V' || *(name) == 'v') && (length == 1)){                /* looks like V - must be V(xx) - get xx now*/                INPgetTok(&line,&name,1);                INPtermInsert(ckt,&name,tab,&node1);                ptemp.rValue = INPevaluate(&line,&error,1);                IFC(setNodeParm,(ckt,node1,which,&ptemp,(IFvalue*)NULL))                continue;            }            LITERR(" Error: .ic syntax error.\n")            break;        }        return(0);    } else if ( (strcmp(token,".ac")==0)){        /* .ac {DEC OCT LIN} NP FSTART FSTOP */        which = -1;        for(i=0;i<ft_sim->numAnalyses;i++) {            if(strcmp(ft_sim->analyses[i]->name,"AC")==0) {                which=i;                break;            }        }        if(which == -1) {            LITERR("AC small signal analysis unsupported\n")            return(0);        }        IFC(newAnalysis,(ckt,which,"acan",&foo, task))        INPgetTok(&line,&steptype,1); /* get DEC, OCT, or LIN */        ptemp.iValue=1;        GCA(INPapName,(ckt,which,foo,steptype,&ptemp))        parm=INPgetValue(ckt,&line,IF_INTEGER,tab);/* number of points*/        GCA(INPapName,(ckt,which,foo,"numsteps",parm))        parm = INPgetValue(ckt,&line,IF_REAL,tab); /* fstart */        GCA(INPapName,(ckt,which,foo,"start",parm))        parm = INPgetValue(ckt,&line,IF_REAL,tab); /* fstop */        GCA(INPapName,(ckt,which,foo,"stop",parm))        return(0);    } else if ( (strcmp(token,".sens")==0)){        /* .sens {AC} {DC} {TRAN} [dev=nnn parm=nnn]* */        which = -1;        for(i=0;i<ft_sim->numAnalyses;i++) {            if(strcmp(ft_sim->analyses[i]->name,"SEN")==0) {                which=i;                break;            }        }        if(which == -1) {            LITERR("sensetivity analysis unsupported\n")            return(0);        }        IFC(newAnalysis,(ckt,which,"sens",&foo, task))        while(*line) { /* read the entire line */            INPgetTok(&line,&token,1);            for(i=0;i<ft_sim->analyses[which]->numParms;i++) {                /* find the parameter */                if(0==strcmp(token ,                        ft_sim->analyses[which]->analysisParms[i].                        keyword) ){                    /* found it, analysis which, parameter i */                    if(ft_sim->analyses[which]->analysisParms[i].                            dataType & IF_FLAG) {                        /* one of the keywords! */                        ptemp.iValue = 1;                        error = (*(ft_sim->setAnalysisParm))(ckt,

⌨️ 快捷键说明

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