📄 device.c
字号:
/**********Copyright 1990 Regents of the University of California. All rights reserved.Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group**********//* * Routines to query and alter devices. */#include "spice.h"#include "gendefs.h"#include "cktdefs.h"#include "cpdefs.h"#include "ftedefs.h"#include "dgen.h"static wordlist *devexpand();/* * show: list device operating point info * show * show devs : params * show devs : params ; devs : params * show dev dev dev : param param param , dev dev : param param * show t : param param param, t : param param * */int printstr( );int listparam( );int printvals( );int bogus1( );int bogus2( );void old_show( );static void all_show( );static int count;voidcom_showmod(wl) wordlist *wl;{ all_show(wl, 1);}voidcom_show(wl) wordlist *wl;{ all_show(wl, 0);}static voidall_show(wl, mode) wordlist *wl; int mode;{ wordlist *params, *nextgroup, *thisgroup; wordlist *prev, *next, *w; int screen_width; dgen *dg, *listdg; int instances; int i, j, n; int param_flag, dev_flag; if (!ft_curckt) { fprintf(cp_err, "Error: no circuit loaded\n"); return; } if (wl && wl->wl_word && eq(wl->wl_word, "-v")) { old_show(wl->wl_next); return; } if (!cp_getvar("width", VT_NUM, (char *) &screen_width)) screen_width = DEF_WIDTH; count = screen_width / 11 - 1; n = 0; do { prev = NULL; params = NULL; nextgroup = NULL; thisgroup = wl; param_flag = 0; dev_flag = 0; /* find the parameter list and the nextgroup */ for (w = wl; w && !nextgroup; w = next) { next = w->wl_next; if (eq(w->wl_word, "++") || eq(w->wl_word, "all")) { if (params) { param_flag = DGEN_ALLPARAMS; if (prev) prev->wl_next = w->wl_next; else params = next; } else { dev_flag = DGEN_ALLDEVS; if (prev) prev->wl_next = w->wl_next; else thisgroup = next; } /* tfree(w->wl_word); tfree(w); */ w = NULL; } else if (eq(w->wl_word, "+")) { if (params) { param_flag = DGEN_DEFPARAMS; if (prev) prev->wl_next = w->wl_next; else params = next; } else { dev_flag = DGEN_DEFDEVS; if (prev) prev->wl_next = w->wl_next; else thisgroup = next; } tfree(w->wl_word); tfree(w); w = NULL; } else if (eq(w->wl_word, ":")) { tfree(w->wl_word); tfree(w); w = NULL; if (!params) { params = next; if (prev) prev->wl_next = NULL; else thisgroup = NULL; } else { if (prev) prev->wl_next = next; else params = next; } } else if (eq(w->wl_word, ";") || eq(w->wl_word, ",")) { nextgroup = next; tfree(w->wl_word); tfree(w); w = NULL; if (prev) prev->wl_next = NULL; break; } prev = w; } instances = 0; for (dg = dgen_init(ft_curckt->ci_ckt, thisgroup, 1, dev_flag, mode); dg; dgen_nth_next(&dg, count)) { instances = 1; if (dg->flags & DGEN_INSTANCE) { instances = 2; printf(" %s: %s\n", ft_sim->devices[dg->dev_type_no]->name, ft_sim->devices[dg->dev_type_no]->description); n += 1; i = 0; do { printf(" device "); j = dgen_for_n(dg, count, printstr, "n", i); i += 1; printf("\n"); } while (j); if (ft_sim->devices[dg->dev_type_no]->numModelParms) { i = 0; do { printf(" model "); j = dgen_for_n(dg, count, printstr, "m", i); i += 1; printf("\n"); } while (j); } listdg = dg; if (param_flag) param_forall(dg, param_flag); else if (!params) param_forall(dg, DGEN_DEFPARAMS); if (params) wl_forall(params, listparam, dg); printf("\n"); } else if (ft_sim->devices[dg->dev_type_no]->numModelParms) { printf(" %s models (%s)\n", ft_sim->devices[dg->dev_type_no]->name, ft_sim->devices[dg->dev_type_no]->description); n += 1; i = 0; do { printf(" model "); j = dgen_for_n(dg, count, printstr, "m", i); i += 1; printf("\n"); } while (j); printf("\n"); if (param_flag) param_forall(dg, param_flag); else if (!params) param_forall(dg, DGEN_DEFPARAMS); if (params) wl_forall(params, listparam, dg); printf("\n"); } } wl = nextgroup; } while (wl); if (!n) { if (instances == 0) printf("No matching instances or models\n"); else if (instances == 1) printf("No matching models\n"); else printf("No matching elements\n"); }}intprintstr(dg, name) dgen *dg; char *name;{ if (*name == 'n') { if (dg->instance) printf(" % 9.9s", dg->instance->GENname); else printf(" <???????>"); } else if (*name == 'm') { if (dg->model) printf(" % 9.9s", dg->model->GENmodName); else printf(" <???????>"); } else printf(" <error> "); return 0;}param_forall(dg, flags) dgen *dg; int flags;{ int i, j, k, found; int xcount; IFparm *plist; found = 0; if (dg->flags & DGEN_INSTANCE) { xcount = *ft_sim->devices[dg->dev_type_no]->numInstanceParms; plist = ft_sim->devices[dg->dev_type_no]->instanceParms; } else { xcount = *ft_sim->devices[dg->dev_type_no]->numModelParms; plist = ft_sim->devices[dg->dev_type_no]->modelParms; } for (i = 0; i < xcount; i++) { if (plist[i].dataType & IF_ASK) { if ((((CKTcircuit *) (dg->ckt))->CKTrhsOld || (plist[i].dataType & IF_SET)) && (!(plist[i].dataType & (IF_REDUNDANT | IF_UNINTERESTING)) || (flags == DGEN_ALLPARAMS && !(plist[i].dataType & IF_REDUNDANT)))) { j = 0; do { if (!j) printf("%10.10s", plist[i].keyword); else printf(" "); k = dgen_for_n(dg, count, printvals, (char *) (plist + i), j); printf("\n"); j += 1; } while (k); } } }}listparam(p, dg) wordlist *p; dgen *dg;{ int i, j, k, found; int xcount; IFparm *plist; found = 0; if (dg->flags & DGEN_INSTANCE) { xcount = *ft_sim->devices[dg->dev_type_no]->numInstanceParms; plist = ft_sim->devices[dg->dev_type_no]->instanceParms; } else { xcount = *ft_sim->devices[dg->dev_type_no]->numModelParms; plist = ft_sim->devices[dg->dev_type_no]->modelParms; } for (i = 0; i < xcount; i++) { if (eqc(p->wl_word, plist[i].keyword) && (plist[i].dataType & IF_ASK)) { found = 1; break; } } if (found) { if ((((CKTcircuit *) (dg->ckt))->CKTrhsOld || (plist[i].dataType & IF_SET))) { j = 0; do { if (!j) printf("%10.10s", p->wl_word); else printf(" "); k = dgen_for_n(dg, count, printvals, plist + i, j); printf("\n"); j += 1; } while (k > 0); } else { j = 0; do { if (!j) printf("%10.10s", p->wl_word); else printf(" "); k = dgen_for_n(dg, count, bogus1, 0, j); printf("\n"); j += 1; } while (k > 0); } } else { j = 0; do { if (!j) printf("%10.10s", p->wl_word); else printf(" "); k = dgen_for_n(dg, count, bogus2, 0, j); printf("\n"); j += 1; } while (k > 0); }}bogus1(dg) dgen *dg;{ printf(" ---------"); return 0;}bogus2(dg) dgen *dg;{ printf(" ?????????"); return 0;}intprintvals(dg, p, i) dgen *dg; IFparm *p; int i;{ IFvalue val; int n; IFvalue *vp; if (dg->flags & DGEN_INSTANCE) (*ft_sim->askInstanceQuest)(ft_curckt->ci_ckt, dg->instance,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -