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

📄 outinterface.c

📁 支持数字元件仿真的SPICE插件
💻 C
📖 第 1 页 / 共 3 页
字号:
static voidplotAddRealValue(desc, value)    dataDesc *desc;    double value;{    struct dvec *v = desc->vec;    if (isreal(v)) {      v->v_realdata = (double *) realloc((char *) v->v_realdata,            sizeof (double) * (v->v_length + 1));      v->v_realdata[v->v_length] = value;    } else {      /* a real parading as a VF_COMPLEX */      v->v_compdata = (complex *) realloc((char *) v->v_compdata,            sizeof (complex) * (v->v_length + 1));      v->v_compdata[v->v_length].cx_real = value;      v->v_compdata[v->v_length].cx_imag = (double) 0;    }    v->v_length++;    return;}static voidplotAddComplexValue(desc, value)    dataDesc *desc;    IFcomplex value;{    struct dvec *v = desc->vec;    v->v_compdata = (complex *) realloc((char *) v->v_compdata,            sizeof (complex) * (v->v_length + 1));    v->v_compdata[v->v_length].cx_real = value.real;    v->v_compdata[v->v_length].cx_imag = value.imag;    v->v_length++;    return;}/* ARGSUSED */ /* until some code gets written */static voidplotEnd(run)    runDesc *run;{    return;}/* ParseSpecial takes something of the form "@name[param,index]" and rips * out name, param, and index. */static boolparseSpecial(name, dev, param, ind)    char *name;    char *dev;    char *param;    char *ind;{    char *s;    *dev = *param = *ind = '\0';    if (*name != '@')        return (false);    name++;        s = dev;    while (*name && (*name != '['))        *s++ = *name++;    *s = '\0';    if (!*name)        return (true);    name++;    s = param;    while (*name && (*name != ',') && (*name != ']'))        *s++ = *name++;    *s = '\0';    if (*name == ']')        return (!name[1] ? true : false);    else if (!*name)        return (false);    name++;    s = ind;    while (*name && (*name != ']'))        *s++ = *name++;    *s = '\0';    if (*name && !name[1])        return (true);    else        return (false);}/* This routine must match two names with or without a V() around them. */static boolname_eq(n1, n2)    char *n1, *n2;{    char buf1[BSIZE], buf2[BSIZE], *s;    if (s = index(n1, '(')) {        strcpy(buf1, s);        if (!(s = index(buf1, ')')))            return (false);        *s = '\0';        n1 = buf1;    }    if (s = index(n2, '(')) {        strcpy(buf2, s);        if (!(s = index(buf2, ')')))            return (false);        *s = '\0';        n2 = buf2;    }    return (strcmp(n1, n2) ? false : true);}static boolgetSpecial(desc, run, val)    dataDesc *desc;    runDesc *run;    IFvalue *val;{    IFvalue selector;    struct variable *vv;    selector.iValue = desc->specIndex;    if (INPaName(desc->specParamName, val, run->circuit, &desc->specType,            desc->specName, &desc->specFast, ft_sim, &desc->type,            &selector) == OK) {      desc->type &= (IF_REAL | IF_COMPLEX);   /* mask out other bits */      return(true);    } else if (vv = if_getstat(run->circuit, &desc->name[1])) {						/* skip @ sign */      desc->type = IF_REAL;      if (vv->va_type == VT_REAL)	val->rValue = vv->va_real;      else if (vv->va_type == VT_NUM)	val->rValue = vv->va_num;      else if (vv->va_type == VT_BOOL)	val->rValue = (vv->va_bool ? 1.0 : 0.0);      else {	return (false); /* not a real */      }      tfree(vv);      return(true);    }    return (false);}static voidfreeRun(run)    runDesc *run;{    int i;    for (i=0; i < run->numData; i++) {/*    vec_free(run->data[i].vec); */ /* kill run, leave plot */      tfree(run->data[i].name);      tfree(run->data[i].specParamName);    }    tfree(run->data);/*  killplot(run->runPlot); */ /* kill run, leave plot */    free(run->type);    free(run->name);    free(run);}intOUTstopnow(){    if (ft_intrpt || shouldstop) {        ft_intrpt = shouldstop = false;        return (1);    } else        return (0);}/* Print out error messages. */static struct mesg {        char *string;        long flag;} msgs[] = {        { "Warning", ERR_WARNING } ,        { "Fatal error", ERR_FATAL } ,        { "Panic", ERR_PANIC } ,        { "Note", ERR_INFO } ,        { NULL, 0 }} ;int OUTerror(flags,format,names)     int flags;    char *format;    IFuid *names;{    struct mesg *m;    char buf[BSIZE], *s, *bptr;    int nindex = 0;    if ((flags == ERR_INFO) && !printinfo)	return;    for (m = msgs; m->flag; m++)                if (flags & m->flag)                        fprintf(cp_err, "%s: ", m->string);    for (s = format, bptr = buf; *s; s++) {      if (*s == '%' && (s == format || *(s-1) != '%') && *(s+1) == 's') {        strcpy(bptr, names[nindex]);        bptr += strlen(names[nindex]);        s++;        nindex++;      } else {        *bptr++ = *s;      }    }    *bptr = '\0';        fprintf(cp_err, "%s\n", buf);        fflush(cp_err);}#ifdef notdef   /* now converted *//* This is to make the linker happy while the code is being converted. */intwrd_open(filename, title, asc)    char *filename, *title;{    abort();}intwrd_run(title)    char *title;{    abort();}intwrd_init(plotname, flags)    char *plotname;    short flags;{    abort();}intwrd_command(com)    char *com;{    abort();}intwrd_output(oname, type, flags, extra)    char *oname;    int type;    short flags;    char *extra;{    abort();}intwrd_point(rdata, idata)    double *rdata, *idata;{    abort();}intwrd_end(){    abort();}intwrd_close(){    abort();}voidwrd_chtrace(name, what, which)    char *name;    bool what;{    abort();}voidwrd_version(string)    char *string;{    abort();}/* unfortunately, this one has to live after the endif until *//* the read OUTerror function gets written and INPerror can be converted *//* ARGSUSED */voidwrd_error(mess, flags)    char *mess;    long flags;{    abort();}#endif/* gtri - add - 4/15/91 - wbk - Add new routines for returning currents */static void addIspecials(run)runDesc *run;{    char **names;    double *modtypes;    int  num_names;    int  i;    /* Get a list of names containing each I source not in a subcircuit */    num_names = ipc_get_devices(run->circuit, "Isource", &names, &modtypes);    /* Add the instances to the dataDesc array as special items */    /* We use the 'dc' parameter since the 'c' parameter is specified */    /* as input only (IP macro used in its definition) */    for(i = 0; i < num_names; i++)        addSpecialDesc(run, "", names[i], "current", 0, modtypes[i]);    /* Free the space allocated by ipc_get_devices() */    ipc_free_devices(num_names, names, modtypes);}static void addCLDQJMspecials(run)runDesc *run;{    char **names;    double *modtypes;    int  num_names;    int  i;    /* Add each capacitor not in a subcircuit */    num_names = ipc_get_devices(run->circuit, "Capacitor", &names, &modtypes);    for(i = 0; i < num_names; i++) {        addSpecialDesc(run, "", names[i], "c", 0, modtypes[i]);    }    ipc_free_devices(num_names, names, modtypes);    /* Add each inductor not in a subcircuit */    num_names = ipc_get_devices(run->circuit, "Inductor", &names, &modtypes);    for(i = 0; i < num_names; i++) {        addSpecialDesc(run, "", names[i], "current", 0, modtypes[i]);    }    ipc_free_devices(num_names, names, modtypes);    /* Add each diode not in a subcircuit */    num_names = ipc_get_devices(run->circuit, "Diode", &names, &modtypes);    for(i = 0; i < num_names; i++) {        addSpecialDesc(run, "", names[i], "c", 0, modtypes[i]);    }    ipc_free_devices(num_names, names, modtypes);    /* Add each BJT not in a subcircuit */    num_names = ipc_get_devices(run->circuit, "BJT", &names, &modtypes);    for(i = 0; i < num_names; i++) {        addSpecialDesc(run, "", names[i], "cc", 0, modtypes[i]);        addSpecialDesc(run, "", names[i], "cb", 0, modtypes[i]);    }    ipc_free_devices(num_names, names, modtypes);    /* Add each JFET not in a subcircuit */    num_names = ipc_get_devices(run->circuit, "JFET", &names, &modtypes);    for(i = 0; i < num_names; i++) {        addSpecialDesc(run, "", names[i], "cd", 0, modtypes[i]);        addSpecialDesc(run, "", names[i], "cg", 0, modtypes[i]);    }    ipc_free_devices(num_names, names, modtypes);    /* Add each level 1 MOSFET not in a subcircuit */    num_names = ipc_get_devices(run->circuit, "Mos1", &names, &modtypes);    for(i = 0; i < num_names; i++) {        addSpecialDesc(run, "", names[i], "cd", 0, modtypes[i]);        addSpecialDesc(run, "", names[i], "cs", 0, modtypes[i]);        addSpecialDesc(run, "", names[i], "cb", 0, modtypes[i]);    }    ipc_free_devices(num_names, names, modtypes);    /* Add each level 2 MOSFET not in a subcircuit */    num_names = ipc_get_devices(run->circuit, "Mos2", &names, &modtypes);    for(i = 0; i < num_names; i++) {        addSpecialDesc(run, "", names[i], "cd", 0, modtypes[i]);        addSpecialDesc(run, "", names[i], "cs", 0, modtypes[i]);        addSpecialDesc(run, "", names[i], "cb", 0, modtypes[i]);    }    ipc_free_devices(num_names, names, modtypes);    /* Add each level 3 MOSFET not in a subcircuit */    num_names = ipc_get_devices(run->circuit, "Mos3", &names, &modtypes);    for(i = 0; i < num_names; i++) {        addSpecialDesc(run, "", names[i], "cd", 0, modtypes[i]);        addSpecialDesc(run, "", names[i], "cs", 0, modtypes[i]);        addSpecialDesc(run, "", names[i], "cb", 0, modtypes[i]);    }    ipc_free_devices(num_names, names, modtypes);}/* gtri - end - 4/15/91 - wbk - Add new routines for returning currents */

⌨️ 快捷键说明

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