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

📄 outinterface.c

📁 支持数字元件仿真的SPICE插件
💻 C
📖 第 1 页 / 共 3 页
字号:
/* RCS Info: $Revision: 1.7 $ on $Date: 92/08/06 14:39:20 $ *           $Source: //carob/xspice/src/sim/FTE/RCS/OUTinterface.c,v $ * Copyright (c) 1988 Wayne A. Christopher, U. C. Berkeley CAD Group  *   faustus@cad.berkeley.edu, ucbvax!faustus * * This module replaces the old "writedata" routines in nutmeg. * Unlike the writedata routines, the OUT routines are only called by * the simulator routines, and only call routines in nutmeg.  The rest * of nutmeg doesn't deal with OUT at all. */#include "prefix.h"#include "CPdefs.h"#include "FTEdefs.h"#include "FTEdata.h"#include "INPdefs.h"        /* for INPtables */#include "IFsim.h"#ifndef CMS#include "IFerrmsgs.h"#else  /* CMS */#include "IFerrmsg.h"#endif /* CMS */#include "version.h"/* gtri - add - wbk - 12/19/90 - Add IPC stuff */#include "IPCtiein.h"#include "MIF.h"/* gtri - end - wbk - 12/19/90 */#include "suffix.h"/******************     These have to go somewhgere else    */bool ft_intrpt = false;     /* Set by the (void) signal handlers. */bool ft_setflag = false;    /* Don't abort after an interrupt. */static bool shouldstop = false; /* Tell simulator to stop next time it asks. */static bool printinfo = false;	/* Print informational "error messages". */extern void gr_end_iplot();#define DOUBLE_PRECISION    15typedef struct dataDesc {    char *name;     /* The name of the vector. */    int type;       /* The type. */    bool regular;       /* Is this given to us? */    int outIndex;       /* If regular then the index. */    char *specName;     /* The device name if special. */    char *specParamName;    /* The parameter name if special. */    int specIndex;      /* For sensitivity, if special. */    int specType;    GENERIC *specFast;    int refIndex;       /* The index of our ref vector. */    struct dvec *vec;/* gtri - add - wbk - 4/15/91 - Add member for returning currents to Mspice */    double specModType;/* gtri - end - wbk - 4/15/91 - Add member for returning currents to Mspice */} dataDesc;typedef struct runDesc {    GENERIC *analysis;    GENERIC *circuit;    char *name;    char *type;    int numData;    int refIndex;    dataDesc *data;    bool writeOut;    bool windowed;    bool binary;    struct plot *runPlot;    FILE *fp;    long pointPos;          /* where to write pointCount */    int pointCount;    int isComplex;    int windowCount;} runDesc;static int beginPlot();static int addDataDesc();static int addSpecialDesc();static void fileInit();static void fileStartPoint();static void fileAddRealValue();static void fileAddComplexValue();static void fileEndPoint();static void fileEnd();static void plotInit();static void plotAddRealValue();static void plotAddComplexValue();static void plotEnd();static bool parseSpecial();static bool name_eq();static bool getSpecial();static void freeRun();/* gtri - add - 4/15/91 - wbk - Add prototypes for new functions */static void addIspecials();static void addCLDQJMspecials();/* gtri - add - 4/15/91 - wbk - Add prototypes for new functions *//* The two "begin plot" routines share all their internals... */intOUTpBeginPlot(circuitPtr, analysisPtr, analName, refName, refType,        numNames, dataNames, dataType, plotPtr)    GENERIC *circuitPtr;    GENERIC *analysisPtr;    IFuid analName;    IFuid refName;    int refType;    int numNames;    IFuid *dataNames;    int dataType;    GENERIC **plotPtr;{    char *name;    if (ft_curckt->ci_ckt == circuitPtr)      name = ft_curckt->ci_name;    else      name = "circuit name";    return (beginPlot(analysisPtr, circuitPtr, name,            (char *) analName, (char *) refName, refType, numNames,            (char **) dataNames, dataType, false,            (runDesc **) plotPtr));}intOUTwBeginPlot(circuitPtr, analysisPtr, analName, refName, refType,        numNames, dataNames, dataType, plotPtr)    GENERIC *circuitPtr;    GENERIC *analysisPtr;    IFuid analName;    IFuid refName;    int refType;    int numNames;    IFuid *dataNames;    int dataType;    GENERIC **plotPtr;{    return (beginPlot(analysisPtr, circuitPtr, "circuit name",            (char *) analName, (char *) refName, refType, numNames,            (char **) dataNames, dataType, true,            (runDesc **) plotPtr));}static intbeginPlot(analysisPtr, circuitPtr, cktName, analName, refName, refType,        numNames, dataNames, dataType, windowed, runp)    GENERIC *analysisPtr;    GENERIC *circuitPtr;    char *cktName;    char *analName;    char *refName;    int refType;    int numNames;    char **dataNames;    int dataType;    bool windowed;    runDesc **runp;{    runDesc *run;    char **saves;    bool *savesused;    int numsaves;    int i, j, depind;    char namebuf[BSIZE], parambuf[BSIZE], depbuf[BSIZE];    bool saveall = true;/* gtri - add - wbk - 12/19/90 - Add IPC stuff */    char    ipc_mapped_name[BSIZE];/* gtri - end - wbk - 12/19/90 - Add IPC stuff */    /* Check to see if we want to print informational data. */    if (cp_getvar("printinfo", VT_BOOL, (char *) &printinfo))	fprintf(cp_err, "(debug printing enabled)\n");    *runp = run = alloc(runDesc);    /* First fill in some general stuff. */    run->analysis = analysisPtr;    run->circuit = circuitPtr;    run->name = copy(cktName);    run->type = copy(analName);    run->windowed = windowed;/* gtri - add - wbk - 12/19/90 - Add IPC stuff */    /* Execute this code in lieu of original code if ipc is enabled */    if(g_ipc.enabled) {        /* Add the voltage/currents available in the matrix */        /* to the runDesc structure */        /* Access in reverse order to make voltage sources come */        /* out in correct order.  The voltage sources names are */        /* in an order backwards from the input deck because of */        /* the way CKTcrtElt adds new instances in the linked   */        /* lists.  They must be output in the proper order      */        /* so that the vtrans stuff is correctly received by Mspice */        for(i = (numNames-1); i >= 0; i--) {            /* Only send selected items, and map according to #VTRANS */            if(ipc_screen_name(dataNames[i], ipc_mapped_name))                addDataDesc(run, ipc_mapped_name, dataType, i);        }        /* Add other device currents to the runDesc structure if not AC */        if(g_ipc.anal_type != IPC_ANAL_AC) {            /* Current sources */            addIspecials(run);            /* Do other devices if returni is enabled */            if(g_ipc.returni)                addCLDQJMspecials(run);        }        /* Do the stuff that the original routine does at the end */        run->writeOut = ft_getOutReq(&run->fp, &run->runPlot, &run->binary,            run->type, run->name);        if (run->writeOut)            fileInit(run);        else            plotInit(run);        return (OK);    }/* gtri - end - wbk - 12/19/90 */    /* Now let's see which of these things we need.  First toss in the     * reference vector.  Then toss in anything that getSaves() tells     * us to save that we can find in the name list.  Finally unpack     * the remaining saves into parameters.     */    numsaves = ft_getSaves(&saves);    if (numsaves) {        savesused = (bool *) tmalloc(sizeof (bool) * numsaves);        saveall = false;        for (i = 0; i < numsaves; i++)            if (cieq(saves[i], "all")) {                saveall = true;                break;            }    }    /* Pass 0. */    if (refName) {        addDataDesc(run, refName, refType, -1);        for (i = 0; i < numsaves; i++)            if (name_eq(saves[i], refName)) {                savesused[i] = true;            }    } else        run->refIndex = -1;    /* Pass 1. */    if (numsaves && !saveall) {        for (i = 0; i < numsaves; i++) {            for (j = 0; j < numNames; j++)                if (name_eq(saves[i], dataNames[j])) {                    addDataDesc(run, dataNames[j],                            dataType, j);                    savesused[i] = true;                    break;                }        }    } else {        for (i = 0; i < numNames; i++)            if (!refName || !name_eq(dataNames[i], refName)) {                addDataDesc(run, dataNames[i], dataType, i);            }    }    /* Pass 2. */    for (i = 0; i < numsaves; i++) {        if (savesused[i])            continue;        if (!parseSpecial(saves[i], namebuf, parambuf, depbuf)) {            fprintf(cp_err, "Warning: can't parse '%s': ignored\n",                    saves[i]);            continue;        }        /* Now, if there's a dep variable, do we already have it? */        if (*depbuf) {            for (j = 0; j < run->numData; j++)                if (name_eq(depbuf, run->data[j].name))                    break;            if (j == run->numData) {                /* Better add it. */                for (j = 0; j < numNames; j++)                    if (name_eq(depbuf, dataNames[j]))                        break;                if (j == numNames) {                    fprintf(cp_err,            "Warning: can't find '%s': value '%s' ignored\n",                        depbuf, saves[i]);                    continue;                }                addDataDesc(run, dataNames[j], dataType, j);                savesused[i] = true;                depind = j;            } else                depind = run->data[j].outIndex;        }/* gtri - modify - wbk - 4/15/91 - Modify param list for returning currents to Mspice */        /* addSpecialDesc(run, saves[i], namebuf, parambuf, depind); */        addSpecialDesc(run, saves[i], namebuf, parambuf, depind, 1.0);/* gtri - modify - wbk - 4/15/91 - Modify param list for returning currents to Mspice */    }    if (numsaves)        free(savesused);        /* Now that we have our own data structures built up, let's see what     * nutmeg wants us to do.     */    run->writeOut = ft_getOutReq(&run->fp, &run->runPlot, &run->binary,            run->type, run->name);    if (run->writeOut)        fileInit(run);    else        plotInit(run);    return (OK);}static intaddDataDesc(run, name, type, ind)    runDesc *run;    char *name;    int type;    int ind;{    dataDesc *data;    if (!run->numData)        run->data = (dataDesc *) tmalloc(sizeof (dataDesc));    else        run->data = (dataDesc *) trealloc((char *) run->data,                sizeof (dataDesc) * (run->numData + 1));    data = &run->data[run->numData];    /* so freeRun will get nice NULL pointers for the fields we don't set */    bzero(data, sizeof(dataDesc));    data->name = copy(name);    data->type = type;    data->regular = true;    data->outIndex = ind;    if (ind == -1) {        /* It's the reference vector. */        run->refIndex = run->numData;    }    run->numData++;    return (OK);}/* gtri - modify - wbk - 4/15/91 - Modify param list for returning currents to Mspice *//*static intaddSpecialDesc(run, name, devname, param, depind)    runDesc *run;    char *name;    char *devname;    char *param;    int depind;*/static intaddSpecialDesc(run, name, devname, param, depind, modtype)    runDesc *run;    char *name;    char *devname;    char *param;    int depind;    double modtype;/* gtri - modify - wbk - 4/15/91 - Modify param list for returning currents to Mspice */{    dataDesc *data;    char *unique;       /* unique char * from back-end */    if (!run->numData)        run->data = (dataDesc *) tmalloc(sizeof (dataDesc));    else        run->data = (dataDesc *) trealloc((char *) run->data,                sizeof (dataDesc) * (run->numData + 1));    data = &run->data[run->numData];    /* so freeRun will get nice NULL pointers for the fields we don't set */    bzero(data, sizeof(dataDesc));    data->name = copy(name);/* gtri - modify - wbk - 4/15/91 - Fix Berkeley pointer bug *//*  The following original Berkeley code frees space pointed to by    devname, which was never malloced ...    unique = devname;    INPinsert(&unique, (INPtables *) ft_curckt->ci_symtab);    data->specName = unique;*/    unique = copy(devname);    INPinsert(&unique, (INPtables *) ft_curckt->ci_symtab);    data->specName = unique;/* gtri - modify - wbk - 4/15/91 - Fix Berkeley pointer bug */    data->specParamName = copy(param);    data->specIndex = depind;    data->specType = -1;    data->specFast = NULL;

⌨️ 快捷键说明

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