2000-04-27 22:03:57 +02:00
|
|
|
/**********
|
|
|
|
|
Copyright 1990 Regents of the University of California. All rights reserved.
|
|
|
|
|
Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
2000-09-03 11:00:08 +02:00
|
|
|
Modified: 2000 AlansFixes
|
2000-04-27 22:03:57 +02:00
|
|
|
**********/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Interface routines. These are specific to spice. The only changes to FTE
|
|
|
|
|
* that should be needed to make FTE work with a different simulator is
|
|
|
|
|
* to rewrite this file. What each routine is expected to do can be
|
|
|
|
|
* found in the programmer's manual. This file should be the only one
|
|
|
|
|
* that includes ngspice.header files.
|
|
|
|
|
*/
|
|
|
|
|
|
2004-01-21 19:27:57 +01:00
|
|
|
/*CDHW Notes:
|
|
|
|
|
|
|
|
|
|
I have never really understood the way Berkeley intended the six pointers
|
|
|
|
|
to default values (ci_defOpt/Task ci_specOpt/Task ci_curOpt/Task) to work,
|
|
|
|
|
as there only see to be two data blocks to point at, or I've missed something
|
|
|
|
|
clever elsewhere.
|
|
|
|
|
|
|
|
|
|
Anyway, in the original 3f4 the interactive command 'set temp = 10'
|
|
|
|
|
set temp for its current task and clobbered the default values as a side
|
|
|
|
|
effect. When an interactive is run it created specTask using the spice
|
|
|
|
|
application default values, not the circuit defaults affected
|
|
|
|
|
by 'set temp = 10'.
|
|
|
|
|
|
|
|
|
|
The fix involves two changes
|
|
|
|
|
|
|
|
|
|
1. Make 'set temp = 10' change the values in the 'default' block, not whatever
|
|
|
|
|
the 'current' pointer happens to be pointing at (which is usually the
|
2011-09-18 11:03:55 +02:00
|
|
|
default block except when one interactive is run immediately
|
2004-01-21 19:27:57 +01:00
|
|
|
after another).
|
|
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
2. Hack CKTnewTask() so that it looks to see whether it is creating
|
2004-01-21 19:27:57 +01:00
|
|
|
a 'special'
|
2011-09-18 11:03:55 +02:00
|
|
|
task, in which case it copies the values from
|
2004-01-21 19:27:57 +01:00
|
|
|
ft_curckt->ci_defTask providing
|
2011-09-18 11:03:55 +02:00
|
|
|
everything looks sane, otherwise it uses the hard-coded
|
2004-01-21 19:27:57 +01:00
|
|
|
'application defaults'.
|
|
|
|
|
|
|
|
|
|
These are fairly minor changes, and as they don't change the data structures
|
|
|
|
|
they should be fairly 'safe'. However, ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CDHW*/
|
|
|
|
|
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/ngspice.h"
|
|
|
|
|
#include "ngspice/cktdefs.h"
|
|
|
|
|
#include "ngspice/cpdefs.h"
|
|
|
|
|
#include "ngspice/tskdefs.h" /* Is really needed ? */
|
|
|
|
|
#include "ngspice/ftedefs.h"
|
|
|
|
|
#include "ngspice/fteinp.h"
|
|
|
|
|
#include "ngspice/inpdefs.h"
|
|
|
|
|
#include "ngspice/iferrmsg.h"
|
|
|
|
|
#include "ngspice/ifsim.h"
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2000-06-27 18:09:02 +02:00
|
|
|
#include "circuits.h"
|
|
|
|
|
#include "spiceif.h"
|
|
|
|
|
#include "variable.h"
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2003-07-23 21:36:39 +02:00
|
|
|
#ifdef XSPICE
|
|
|
|
|
/* gtri - add - wbk - 11/9/90 - include MIF function prototypes */
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/mifproto.h"
|
2003-07-23 21:36:39 +02:00
|
|
|
/* gtri - end - wbk - 11/9/90 */
|
|
|
|
|
|
|
|
|
|
/* gtri - evt - wbk - 5/20/91 - Add stuff for user-defined nodes */
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/evtproto.h"
|
|
|
|
|
#include "ngspice/evtudn.h"
|
2003-07-23 21:36:39 +02:00
|
|
|
/* gtri - end - wbk - 5/20/91 - Add stuff for user-defined nodes */
|
2012-02-19 11:23:56 +01:00
|
|
|
#include "ngspice/mif.h"
|
2003-07-23 21:36:39 +02:00
|
|
|
#endif
|
|
|
|
|
|
2013-02-22 22:25:55 +01:00
|
|
|
extern INPmodel *modtab;
|
2012-08-12 20:28:42 +02:00
|
|
|
|
|
|
|
|
static struct variable *parmtovar(IFvalue *pv, IFparm *opt);
|
|
|
|
|
static IFparm *parmlookup(IFdevice *dev, GENinstance **inptr, char *param,
|
2011-09-18 11:03:55 +02:00
|
|
|
int do_model, int inout);
|
2012-08-12 20:28:42 +02:00
|
|
|
static IFvalue *doask(CKTcircuit *ckt, int typecode, GENinstance *dev, GENmodel *mod,
|
2011-09-18 11:03:55 +02:00
|
|
|
IFparm *opt, int ind);
|
|
|
|
|
static int doset(CKTcircuit *ckt, int typecode, GENinstance *dev, GENmodel *mod,
|
|
|
|
|
IFparm *opt, struct dvec *val);
|
2013-06-30 20:23:58 +02:00
|
|
|
static int finddev(CKTcircuit *ckt, char *name, GENinstance **devptr, GENmodel **modptr);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
/* espice fix integration */
|
2013-06-30 20:23:58 +02:00
|
|
|
static int finddev_special(CKTcircuit *ckt, char *name, GENinstance **devptr, GENmodel **modptr, int *device_or_model);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Input a single deck, and return a pointer to the circuit. */
|
|
|
|
|
|
2010-07-06 21:03:40 +02:00
|
|
|
CKTcircuit *
|
2000-04-27 22:03:57 +02:00
|
|
|
if_inpdeck(struct line *deck, INPtables **tab)
|
|
|
|
|
{
|
2010-07-07 19:26:05 +02:00
|
|
|
CKTcircuit *ckt;
|
2013-07-27 20:34:59 +02:00
|
|
|
int err, i;
|
2000-04-27 22:03:57 +02:00
|
|
|
struct line *ll;
|
|
|
|
|
IFuid taskUid;
|
|
|
|
|
IFuid optUid;
|
|
|
|
|
int which = -1;
|
|
|
|
|
|
|
|
|
|
for (i = 0, ll = deck; ll; ll = ll->li_next)
|
|
|
|
|
i++;
|
|
|
|
|
*tab = INPtabInit(i);
|
|
|
|
|
ft_curckt->ci_symtab = *tab;
|
2000-09-05 21:48:22 +02:00
|
|
|
|
2011-04-27 20:30:15 +02:00
|
|
|
err = ft_sim->newCircuit (&ckt);
|
2000-09-05 21:48:22 +02:00
|
|
|
if (err != OK) {
|
2000-04-27 22:03:57 +02:00
|
|
|
ft_sperror(err, "CKTinit");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2000-09-05 21:48:22 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/*CDHW Create a task DDD with a new UID. ci_defTask will point to it CDHW*/
|
2004-01-21 19:27:57 +01:00
|
|
|
|
2011-04-28 17:59:36 +02:00
|
|
|
err = IFnewUid(ckt, &taskUid, NULL, "default", UID_TASK, NULL);
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "newUid");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2004-01-21 19:27:57 +01:00
|
|
|
#if (0)
|
2011-09-18 11:03:55 +02:00
|
|
|
err = ft_sim->newTask (ckt, &(ft_curckt->ci_defTask), taskUid);
|
2004-01-21 19:27:57 +01:00
|
|
|
#else /*CDHW*/
|
2011-09-18 11:03:55 +02:00
|
|
|
err = ft_sim->newTask (ckt, &(ft_curckt->ci_defTask), taskUid, NULL);
|
2004-01-21 19:27:57 +01:00
|
|
|
#endif
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "newTask");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2000-09-05 21:48:22 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/*CDHW which options available for this simulator? CDHW*/
|
2004-01-21 19:27:57 +01:00
|
|
|
|
2013-07-27 20:34:59 +02:00
|
|
|
which = ft_find_analysis("options");
|
2000-09-05 21:48:22 +02:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
if (which != -1) {
|
2012-08-14 20:38:25 +02:00
|
|
|
err = IFnewUid(ckt, &optUid, NULL, "options", UID_ANALYSIS, NULL);
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "newUid");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2000-09-05 21:48:22 +02:00
|
|
|
|
2011-04-27 20:30:15 +02:00
|
|
|
err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, optUid,
|
2011-09-18 11:03:55 +02:00
|
|
|
&(ft_curckt->ci_defOpt),
|
|
|
|
|
ft_curckt->ci_defTask);
|
|
|
|
|
|
|
|
|
|
/*CDHW ci_defTask and ci_defOpt point to parameters DDD CDHW*/
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "createOptions");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2000-09-05 21:48:22 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
ft_curckt->ci_curOpt = ft_curckt->ci_defOpt;
|
2011-09-18 11:03:55 +02:00
|
|
|
/*CDHW ci_curOpt and ci_defOpt point to DDD CDHW*/
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2000-09-05 21:48:22 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
ft_curckt->ci_curTask = ft_curckt->ci_defTask;
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2013-02-22 22:25:55 +01:00
|
|
|
/* reset the model table, will be filled in anew in INPpas1() */
|
|
|
|
|
modtab = NULL;
|
2012-08-12 20:28:42 +02:00
|
|
|
INPpas1(ckt, (card *) deck->li_next, *tab);
|
2013-02-22 22:25:55 +01:00
|
|
|
/* store the new model table in the current circuit */
|
|
|
|
|
ft_curckt->ci_modtab = modtab;
|
2012-08-12 20:28:42 +02:00
|
|
|
INPpas2(ckt, (card *) deck->li_next, *tab, ft_curckt->ci_defTask);
|
|
|
|
|
|
2000-09-05 21:48:22 +02:00
|
|
|
/* INPpas2 has been modified to ignore .NODESET and .IC
|
|
|
|
|
* cards. These are left till INPpas3 so that we can check for
|
|
|
|
|
* nodeset/ic of non-existant nodes. */
|
2000-09-03 11:00:08 +02:00
|
|
|
|
2010-07-07 19:32:40 +02:00
|
|
|
INPpas3(ckt, (card *) deck->li_next,
|
2011-05-08 14:52:58 +02:00
|
|
|
*tab, ft_curckt->ci_defTask, ft_sim->nodeParms,
|
2011-09-18 11:03:55 +02:00
|
|
|
ft_sim->numNodeParms);
|
2000-09-03 11:00:08 +02:00
|
|
|
|
2003-07-23 21:36:39 +02:00
|
|
|
#ifdef XSPICE
|
2011-09-18 11:03:55 +02:00
|
|
|
/* gtri - begin - wbk - 6/6/91 - Finish initialization of event driven structures */
|
2010-07-07 19:32:40 +02:00
|
|
|
err = EVTinit(ckt);
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "EVTinit");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2003-07-23 21:36:39 +02:00
|
|
|
}
|
2011-09-18 11:03:55 +02:00
|
|
|
/* gtri - end - wbk - 6/6/91 - Finish initialization of event driven structures */
|
2003-07-23 21:36:39 +02:00
|
|
|
#endif
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
return (ckt);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-05 21:48:22 +02:00
|
|
|
/* Do a run of the circuit, of the given type. Type "resume" is
|
|
|
|
|
* special -- it means to resume whatever simulation that was in
|
|
|
|
|
* progress. The return value of this routine is 0 if the exit was ok,
|
|
|
|
|
* and 1 if there was a reason to interrupt the circuit (interrupt
|
|
|
|
|
* typed at the keyboard, error in the simulation, etc). args should
|
|
|
|
|
* be the entire command line, e.g. "tran 1 10 20 uic" */
|
2000-04-27 22:03:57 +02:00
|
|
|
int
|
2011-05-08 14:52:58 +02:00
|
|
|
if_run(CKTcircuit *ckt, char *what, wordlist *args, INPtables *tab)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
|
|
|
|
int err;
|
2004-08-16 23:05:42 +02:00
|
|
|
struct line deck;
|
2000-04-27 22:03:57 +02:00
|
|
|
char buf[BSIZE_SP];
|
|
|
|
|
int which = -1;
|
2012-08-12 20:28:42 +02:00
|
|
|
IFuid specUid, optUid;
|
2003-07-23 21:36:39 +02:00
|
|
|
char *s;
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* First parse the line... */
|
2004-01-21 19:27:57 +01:00
|
|
|
/*CDHW Look for an interactive task CDHW*/
|
2012-09-20 20:30:53 +02:00
|
|
|
if (eq(what, "tran") ||
|
|
|
|
|
eq(what, "ac") ||
|
|
|
|
|
eq(what, "dc") ||
|
|
|
|
|
eq(what, "op") ||
|
|
|
|
|
eq(what, "pz") ||
|
|
|
|
|
eq(what, "disto") ||
|
|
|
|
|
eq(what, "adjsen") ||
|
|
|
|
|
eq(what, "sens") ||
|
|
|
|
|
eq(what, "tf") ||
|
|
|
|
|
eq(what, "noise")
|
2012-12-28 18:10:06 +01:00
|
|
|
#ifdef WITH_PSS
|
|
|
|
|
/* SP: Steady State Analysis */
|
|
|
|
|
|| eq(what, "pss")
|
|
|
|
|
/* SP */
|
|
|
|
|
#endif
|
2012-01-02 13:31:22 +01:00
|
|
|
)
|
2001-01-24 18:24:32 +01:00
|
|
|
{
|
2011-09-18 11:03:55 +02:00
|
|
|
s = wl_flatten(args); /* va: tfree char's tmalloc'ed in wl_flatten */
|
2003-07-23 21:36:39 +02:00
|
|
|
(void) sprintf(buf, ".%s", s);
|
2011-09-18 11:03:55 +02:00
|
|
|
tfree(s);
|
2004-08-16 23:05:42 +02:00
|
|
|
deck.li_next = deck.li_actual = NULL;
|
|
|
|
|
deck.li_error = NULL;
|
|
|
|
|
deck.li_linenum = 0;
|
|
|
|
|
deck.li_line = buf;
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/*CDHW Delete any previous special task CDHW*/
|
2004-01-21 19:27:57 +01:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
if (ft_curckt->ci_specTask) {
|
2012-08-14 20:38:25 +02:00
|
|
|
if (ft_curckt->ci_specTask == ft_curckt->ci_defTask) /*CDHW*/
|
2011-09-18 11:03:55 +02:00
|
|
|
printf("Oh dear...something bad has happened to the options.\n");
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2012-08-14 20:38:25 +02:00
|
|
|
err = ft_sim->deleteTask (ft_curckt->ci_ckt, ft_curckt->ci_specTask);
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "deleteTask");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (2);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
ft_curckt->ci_specTask = NULL;
|
|
|
|
|
ft_curckt->ci_specOpt = NULL; /*CDHW*/
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2011-09-18 11:03:55 +02:00
|
|
|
/*CDHW Create an interactive task AAA with a new UID.
|
2012-08-12 20:28:42 +02:00
|
|
|
ci_specTask will point to it CDHW*/
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2013-07-14 15:15:04 +02:00
|
|
|
err = IFnewUid(ft_curckt->ci_ckt, &specUid, NULL, "special", UID_TASK, NULL);
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "newUid");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (2);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2004-01-21 19:27:57 +01:00
|
|
|
#if (0)
|
2011-04-27 20:30:15 +02:00
|
|
|
err = ft_sim->newTask (ft_curckt->ci_ckt,
|
2011-09-18 11:03:55 +02:00
|
|
|
&(ft_curckt->ci_specTask), specUid);
|
2004-01-21 19:27:57 +01:00
|
|
|
#else /*CDHW*/
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2011-04-27 20:30:15 +02:00
|
|
|
err = ft_sim->newTask (ft_curckt->ci_ckt,
|
2011-09-18 11:03:55 +02:00
|
|
|
&(ft_curckt->ci_specTask),
|
|
|
|
|
specUid, &(ft_curckt->ci_defTask));
|
|
|
|
|
#endif
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "newTask");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (2);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2004-01-21 19:27:57 +01:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/*CDHW which options available for this simulator? CDHW*/
|
|
|
|
|
|
2013-07-27 20:34:59 +02:00
|
|
|
which = ft_find_analysis("options");
|
2012-08-12 20:28:42 +02:00
|
|
|
|
|
|
|
|
if (which != -1) { /*CDHW options are available CDHW*/
|
2013-07-14 15:15:04 +02:00
|
|
|
err = IFnewUid(ft_curckt->ci_ckt, &optUid, NULL, "options", UID_ANALYSIS, NULL);
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "newUid");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (2);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2011-04-27 20:30:15 +02:00
|
|
|
err = ft_sim->newAnalysis (ft_curckt->ci_ckt, which, optUid,
|
2011-09-18 11:03:55 +02:00
|
|
|
&(ft_curckt->ci_specOpt),
|
|
|
|
|
ft_curckt->ci_specTask);
|
|
|
|
|
|
|
|
|
|
/*CDHW 'options' ci_specOpt points to AAA in this case CDHW*/
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
if (err) {
|
|
|
|
|
ft_sperror(err, "createOptions");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (2);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2004-01-21 19:27:57 +01:00
|
|
|
ft_curckt->ci_curOpt = ft_curckt->ci_specOpt;
|
|
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/*CDHW ci_specTask ci_specOpt and ci_curOpt all point to AAA CDHW*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
ft_curckt->ci_curTask = ft_curckt->ci_specTask;
|
2004-01-21 19:27:57 +01:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/*CDHW ci_curTask and ci_specTask point to the interactive task AAA CDHW*/
|
|
|
|
|
|
|
|
|
|
INPpas2(ckt, (card *) &deck, tab, ft_curckt->ci_specTask);
|
|
|
|
|
|
2004-08-16 23:05:42 +02:00
|
|
|
if (deck.li_error) {
|
|
|
|
|
fprintf(cp_err, "Warning: %s\n", deck.li_error);
|
2011-09-18 11:03:55 +02:00
|
|
|
return 2;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
2001-01-24 18:24:32 +01:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/*CDHW
|
|
|
|
|
** if the task is to 'run' the deck, change ci_curTask and
|
|
|
|
|
** ci_curOpt to point to DDD
|
|
|
|
|
** created by if_inpdeck(), otherwise they point to AAA.
|
|
|
|
|
CDHW*/
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
if (eq(what, "run")) {
|
2000-04-27 22:03:57 +02:00
|
|
|
ft_curckt->ci_curTask = ft_curckt->ci_defTask;
|
|
|
|
|
ft_curckt->ci_curOpt = ft_curckt->ci_defOpt;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/* -- Find out what we are supposed to do. */
|
2001-01-24 18:24:32 +01:00
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
if ((eq(what, "tran")) ||
|
|
|
|
|
(eq(what, "ac")) ||
|
|
|
|
|
(eq(what, "dc")) ||
|
|
|
|
|
(eq(what, "op")) ||
|
|
|
|
|
(eq(what, "pz")) ||
|
|
|
|
|
(eq(what, "disto")) ||
|
|
|
|
|
(eq(what, "noise")) ||
|
|
|
|
|
(eq(what, "adjsen")) ||
|
|
|
|
|
(eq(what, "sens")) ||
|
|
|
|
|
(eq(what, "tf")) ||
|
2012-12-28 18:10:06 +01:00
|
|
|
#ifdef WITH_PSS
|
|
|
|
|
/* SP: Steady State Analysis */
|
|
|
|
|
(eq(what, "pss")) ||
|
|
|
|
|
/* SP */
|
|
|
|
|
#endif
|
2012-09-20 20:30:53 +02:00
|
|
|
(eq(what, "run")))
|
|
|
|
|
{
|
2011-09-18 11:03:55 +02:00
|
|
|
/*CDHW Run the analysis pointed to by ci_curTask CDHW*/
|
|
|
|
|
|
|
|
|
|
ft_curckt->ci_curOpt = ft_curckt->ci_defOpt;
|
|
|
|
|
if ((err = ft_sim->doAnalyses (ckt, 1, ft_curckt->ci_curTask)) != OK) {
|
2000-04-27 22:03:57 +02:00
|
|
|
ft_sperror(err, "doAnalyses");
|
|
|
|
|
/* wrd_end(); */
|
2011-09-18 11:03:55 +02:00
|
|
|
if (err == E_PAUSE)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (1);
|
2011-09-18 11:03:55 +02:00
|
|
|
else
|
2012-09-20 20:30:53 +02:00
|
|
|
return (2);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
} else if (eq(what, "resume")) {
|
2011-09-18 11:03:55 +02:00
|
|
|
if ((err = ft_sim->doAnalyses (ckt, 0, ft_curckt->ci_curTask)) != OK) {
|
2000-04-27 22:03:57 +02:00
|
|
|
ft_sperror(err, "doAnalyses");
|
|
|
|
|
/* wrd_end(); */
|
2011-09-18 11:03:55 +02:00
|
|
|
if (err == E_PAUSE)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (1);
|
2011-09-18 11:03:55 +02:00
|
|
|
else
|
2012-09-20 20:30:53 +02:00
|
|
|
return (2);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
2012-08-14 20:38:25 +02:00
|
|
|
fprintf(cp_err, "if_run: Internal Error: bad run type %s\n", what);
|
2012-09-20 20:30:53 +02:00
|
|
|
return (2);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
return (0);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Set an option in the circuit. Arguments are option name, type, and
|
|
|
|
|
* value (the last a char *), suitable for casting to whatever needed...
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static char *unsupported[] = {
|
|
|
|
|
"itl3",
|
|
|
|
|
"itl5",
|
|
|
|
|
"lvltim",
|
|
|
|
|
"maxord",
|
|
|
|
|
"method",
|
|
|
|
|
NULL
|
2012-08-12 20:28:42 +02:00
|
|
|
};
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
static char *obsolete[] = {
|
|
|
|
|
"limpts",
|
|
|
|
|
"limtim",
|
|
|
|
|
"lvlcod",
|
|
|
|
|
NULL
|
2012-08-12 20:28:42 +02:00
|
|
|
};
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
int
|
2010-07-18 00:11:51 +02:00
|
|
|
if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
|
|
|
|
IFvalue pval;
|
|
|
|
|
int err, i;
|
|
|
|
|
char **vv;
|
|
|
|
|
int which = -1;
|
|
|
|
|
|
|
|
|
|
if (eq(name, "acct")) {
|
|
|
|
|
ft_acctprint = TRUE;
|
2011-09-18 11:03:55 +02:00
|
|
|
return 0;
|
2009-02-22 19:28:25 +01:00
|
|
|
} else if (eq(name, "noacct")) {
|
|
|
|
|
ft_noacctprint = TRUE;
|
2011-09-18 11:03:55 +02:00
|
|
|
return 0;
|
2009-08-22 18:54:03 +02:00
|
|
|
} else if (eq(name, "noinit")) {
|
|
|
|
|
ft_noinitprint = TRUE;
|
2011-09-18 11:03:55 +02:00
|
|
|
return 0;
|
2000-04-27 22:03:57 +02:00
|
|
|
} else if (eq(name, "list")) {
|
|
|
|
|
ft_listprint = TRUE;
|
2011-09-18 11:03:55 +02:00
|
|
|
return 0;
|
2000-04-27 22:03:57 +02:00
|
|
|
} else if (eq(name, "node")) {
|
|
|
|
|
ft_nodesprint = TRUE;
|
2011-09-18 11:03:55 +02:00
|
|
|
return 0;
|
2000-04-27 22:03:57 +02:00
|
|
|
} else if (eq(name, "opts")) {
|
|
|
|
|
ft_optsprint = TRUE;
|
2011-09-18 11:03:55 +02:00
|
|
|
return 0;
|
2000-04-27 22:03:57 +02:00
|
|
|
} else if (eq(name, "nopage")) {
|
2011-09-18 11:03:55 +02:00
|
|
|
ft_nopage = TRUE;
|
|
|
|
|
return 0;
|
2000-04-27 22:03:57 +02:00
|
|
|
} else if (eq(name, "nomod")) {
|
2011-09-18 11:03:55 +02:00
|
|
|
ft_nomod = TRUE;
|
|
|
|
|
return 0;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-27 20:34:59 +02:00
|
|
|
which = ft_find_analysis("options");
|
2012-08-12 20:28:42 +02:00
|
|
|
|
|
|
|
|
if (which == -1) {
|
|
|
|
|
fprintf(cp_err, "Warning: .options line unsupported\n");
|
2000-04-27 22:03:57 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ft_sim->analyses[which]->numParms; i++)
|
|
|
|
|
if (eq(ft_sim->analyses[which]->analysisParms[i].keyword, name) &&
|
2012-08-12 20:28:42 +02:00
|
|
|
(ft_sim->analyses[which]->analysisParms[i].dataType & IF_SET))
|
2000-04-27 22:03:57 +02:00
|
|
|
break;
|
|
|
|
|
if (i == ft_sim->analyses[which]->numParms) {
|
|
|
|
|
/* See if this is unsupported or obsolete. */
|
|
|
|
|
for (vv = unsupported; *vv; vv++)
|
|
|
|
|
if (eq(name, *vv)) {
|
2012-09-20 20:30:53 +02:00
|
|
|
fprintf(cp_err, "Warning: option %s is currently unsupported.\n", name);
|
2000-04-27 22:03:57 +02:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
for (vv = obsolete; *vv; vv++)
|
|
|
|
|
if (eq(name, *vv)) {
|
2012-09-20 20:30:53 +02:00
|
|
|
fprintf(cp_err, "Warning: option %s is obsolete.\n", name);
|
2000-04-27 22:03:57 +02:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (ft_sim->analyses[which]->analysisParms[i].dataType & IF_VARTYPES) {
|
2011-09-18 11:03:55 +02:00
|
|
|
case IF_REAL:
|
|
|
|
|
if (type == CP_REAL)
|
|
|
|
|
pval.rValue = *((double *) value);
|
|
|
|
|
else if (type == CP_NUM)
|
|
|
|
|
pval.rValue = *((int *) value);
|
|
|
|
|
else
|
|
|
|
|
goto badtype;
|
|
|
|
|
break;
|
|
|
|
|
case IF_INTEGER:
|
|
|
|
|
if (type == CP_NUM)
|
|
|
|
|
pval.iValue = *((int *) value);
|
|
|
|
|
else if (type == CP_REAL)
|
|
|
|
|
pval.iValue = (int)floor((*(double *)value) + 0.5);
|
|
|
|
|
else
|
|
|
|
|
goto badtype;
|
|
|
|
|
break;
|
|
|
|
|
case IF_STRING:
|
|
|
|
|
if (type == CP_STRING)
|
|
|
|
|
pval.sValue = copy((char*) value);
|
|
|
|
|
else
|
|
|
|
|
goto badtype;
|
|
|
|
|
break;
|
|
|
|
|
case IF_FLAG:
|
|
|
|
|
if (type == CP_BOOL)
|
|
|
|
|
pval.iValue = *((bool *) value) ? 1 : 0;
|
|
|
|
|
else if (type == CP_NUM) /* FIXME, shall we allow this ? */
|
|
|
|
|
pval.iValue = *((int *) value);
|
|
|
|
|
else
|
|
|
|
|
goto badtype;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(cp_err,
|
|
|
|
|
"if_option: Internal Error: bad option type %d.\n",
|
|
|
|
|
ft_sim->analyses[which]->analysisParms[i].dataType);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ckt) {
|
2011-09-18 11:03:55 +02:00
|
|
|
/* XXX No circuit loaded */
|
|
|
|
|
fprintf(cp_err, "Simulation parameter \"%s\" can't be set until\n",
|
|
|
|
|
name);
|
|
|
|
|
fprintf(cp_err, "a circuit has been loaded.\n");
|
|
|
|
|
return 1;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2004-01-21 19:27:57 +01:00
|
|
|
#if (0)
|
2011-09-18 11:03:55 +02:00
|
|
|
if ((err = ft_sim->setAnalysisParm (ckt, ft_curckt->ci_curOpt,
|
|
|
|
|
ft_sim->analyses[which]->analysisParms[i].id, &pval,
|
|
|
|
|
NULL)) != OK)
|
|
|
|
|
ft_sperror(err, "setAnalysisParm(options) ci_curOpt");
|
2004-01-21 19:27:57 +01:00
|
|
|
#else /*CDHW*/
|
2011-09-18 11:03:55 +02:00
|
|
|
if ((err = ft_sim->setAnalysisParm (ckt, ft_curckt->ci_defOpt,
|
|
|
|
|
ft_sim->analyses[which]->analysisParms[i].id, &pval,
|
|
|
|
|
NULL)) != OK)
|
|
|
|
|
ft_sperror(err, "setAnalysisParm(options) ci_curOpt");
|
|
|
|
|
return 1;
|
2004-01-21 19:27:57 +01:00
|
|
|
#endif
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
badtype:
|
|
|
|
|
fprintf(cp_err, "Error: bad type given for option %s --\n", name);
|
|
|
|
|
fprintf(cp_err, "\ttype given was ");
|
|
|
|
|
switch (type) {
|
2011-09-18 11:03:55 +02:00
|
|
|
case CP_BOOL:
|
|
|
|
|
fputs("boolean", cp_err);
|
|
|
|
|
break;
|
|
|
|
|
case CP_NUM:
|
|
|
|
|
fputs("integer", cp_err);
|
|
|
|
|
break;
|
|
|
|
|
case CP_REAL:
|
|
|
|
|
fputs("real", cp_err);
|
|
|
|
|
break;
|
|
|
|
|
case CP_STRING:
|
|
|
|
|
fputs("string", cp_err);
|
|
|
|
|
break;
|
|
|
|
|
case CP_LIST:
|
|
|
|
|
fputs("list", cp_err);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fputs("something strange", cp_err);
|
|
|
|
|
break;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
fprintf(cp_err, ", type expected was ");
|
2012-09-20 20:30:53 +02:00
|
|
|
switch (ft_sim->analyses[which]->analysisParms[i].dataType & IF_VARTYPES) {
|
2011-09-18 11:03:55 +02:00
|
|
|
case IF_REAL:
|
|
|
|
|
fputs("real.\n", cp_err);
|
|
|
|
|
break;
|
|
|
|
|
case IF_INTEGER:
|
|
|
|
|
fputs("integer.\n", cp_err);
|
|
|
|
|
break;
|
|
|
|
|
case IF_STRING:
|
|
|
|
|
fputs("string.\n", cp_err);
|
|
|
|
|
break;
|
|
|
|
|
case IF_FLAG:
|
|
|
|
|
fputs("flag.\n", cp_err);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fputs("something strange.\n", cp_err);
|
|
|
|
|
break;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2010-07-17 22:48:20 +02:00
|
|
|
if (type == CP_BOOL)
|
2011-09-18 11:03:55 +02:00
|
|
|
fputs("\t(Note that you must use an = to separate option name and value.)\n",
|
|
|
|
|
cp_err);
|
2000-04-27 22:03:57 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2010-07-06 21:03:40 +02:00
|
|
|
if_dump(CKTcircuit *ckt, FILE *file)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(ckt);
|
2010-11-16 20:11:32 +01:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
fprintf(file, "diagnostic output dump unavailable.");
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
void
|
2010-07-06 21:03:40 +02:00
|
|
|
if_cktfree(CKTcircuit *ckt, INPtables *tab)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2011-05-08 14:52:58 +02:00
|
|
|
ft_sim->deleteCircuit (ckt);
|
2010-08-10 20:02:26 +02:00
|
|
|
INPtabEnd(tab);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
/* Return a string describing an error code. */
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
/* BLOW THIS AWAY.... */
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
if_errstring(int code)
|
|
|
|
|
{
|
2012-09-20 20:30:53 +02:00
|
|
|
return (INPerror(code));
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2009-01-15 17:46:31 +01:00
|
|
|
/* Get pointers to a device, its model, and its type number given the name. If
|
|
|
|
|
* there is no such device, try to find a model with that name
|
|
|
|
|
* device_or_model says if we are referencing a device or a model.
|
2012-08-12 20:28:42 +02:00
|
|
|
* finddev_special(ck, name, devptr, modptr, device_or_model):
|
2011-09-18 11:03:55 +02:00
|
|
|
* Introduced to look for correct reference in expression like print @BC107 [is]
|
|
|
|
|
* and find out whether a model or a device parameter is referenced and properly
|
2009-01-15 17:46:31 +01:00
|
|
|
* call the spif_getparam_special (ckt, name, param, ind, do_model) function in
|
|
|
|
|
* vector.c - A. Roldan (espice).
|
|
|
|
|
*/
|
2011-09-18 11:03:55 +02:00
|
|
|
static int
|
2009-01-15 17:46:31 +01:00
|
|
|
finddev_special(
|
2011-05-08 14:52:58 +02:00
|
|
|
CKTcircuit *ckt,
|
2009-01-15 17:46:31 +01:00
|
|
|
char *name,
|
2010-07-06 21:03:40 +02:00
|
|
|
GENinstance **devptr,
|
|
|
|
|
GENmodel **modptr,
|
2009-01-15 17:46:31 +01:00
|
|
|
int *device_or_model)
|
|
|
|
|
{
|
2013-07-17 20:28:42 +02:00
|
|
|
*devptr = ft_sim->findInstance (ckt, name);
|
2013-07-17 20:27:52 +02:00
|
|
|
if (*devptr) {
|
2012-08-12 20:28:42 +02:00
|
|
|
*device_or_model = 0;
|
2013-07-04 19:43:16 +02:00
|
|
|
return (*devptr)->GENmodPtr->GENmodType;
|
2009-01-15 17:46:31 +01:00
|
|
|
}
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2013-07-17 20:36:29 +02:00
|
|
|
*modptr = ft_sim->findModel (ckt, name);
|
2013-07-17 20:31:12 +02:00
|
|
|
if (*modptr) {
|
2012-08-12 20:28:42 +02:00
|
|
|
*device_or_model = 1;
|
2013-07-17 20:34:04 +02:00
|
|
|
return (*modptr)->GENmodType;
|
2009-01-15 17:46:31 +01:00
|
|
|
}
|
2012-08-12 20:28:42 +02:00
|
|
|
|
|
|
|
|
*device_or_model = 2;
|
2012-09-20 20:30:53 +02:00
|
|
|
return (-1);
|
2009-01-15 17:46:31 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2009-01-15 17:46:31 +01:00
|
|
|
/* Get a parameter value from the circuit. If name is left unspecified,
|
|
|
|
|
* we want a circuit parameter. Now works both for devices and models.
|
|
|
|
|
* A.Roldan (espice)
|
|
|
|
|
*/
|
|
|
|
|
struct variable *
|
2012-09-20 20:30:53 +02:00
|
|
|
spif_getparam_special(CKTcircuit *ckt, char **name, char *param, int ind, int do_model)
|
|
|
|
|
{
|
2009-01-15 17:46:31 +01:00
|
|
|
struct variable *vv = NULL, *tv;
|
|
|
|
|
IFvalue *pv;
|
|
|
|
|
IFparm *opt;
|
|
|
|
|
int typecode, i, modelo_dispositivo;
|
2011-04-28 17:59:36 +02:00
|
|
|
GENinstance *dev = NULL;
|
|
|
|
|
GENmodel *mod = NULL;
|
2009-01-15 17:46:31 +01:00
|
|
|
IFdevice *device;
|
|
|
|
|
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(do_model);
|
2010-11-16 20:11:32 +01:00
|
|
|
|
2009-01-15 17:46:31 +01:00
|
|
|
/* fprintf(cp_err, "Calling if_getparam(%s, %s)\n", *name, param); */
|
|
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
if (!param || (param && eq(param, "all"))) {
|
2010-07-08 19:50:29 +02:00
|
|
|
INPretrieve(name, ft_curckt->ci_symtab);
|
2010-07-08 19:20:03 +02:00
|
|
|
typecode = finddev_special(ckt, *name, &dev, &mod, &modelo_dispositivo);
|
2011-09-18 11:03:55 +02:00
|
|
|
if (typecode == -1) {
|
2012-08-12 20:28:42 +02:00
|
|
|
fprintf(cp_err, "Error: no such device or model name %s\n", *name);
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2009-01-15 17:46:31 +01:00
|
|
|
}
|
|
|
|
|
device = ft_sim->devices[typecode];
|
2012-08-12 20:28:42 +02:00
|
|
|
if (!modelo_dispositivo) {
|
2011-09-18 11:03:55 +02:00
|
|
|
/* It is a device */
|
|
|
|
|
for (i = 0; i < *(device->numInstanceParms); i++) {
|
|
|
|
|
opt = &device->instanceParms[i];
|
2012-08-14 20:38:25 +02:00
|
|
|
if (opt->dataType & IF_REDUNDANT || !opt->description)
|
|
|
|
|
continue;
|
|
|
|
|
if (!(opt->dataType & IF_ASK))
|
|
|
|
|
continue;
|
2011-09-18 11:03:55 +02:00
|
|
|
pv = doask(ckt, typecode, dev, mod, opt, ind);
|
|
|
|
|
if (pv) {
|
|
|
|
|
tv = parmtovar(pv, opt);
|
|
|
|
|
|
|
|
|
|
/* With the following we pack the name and the acronym of the parameter */
|
|
|
|
|
{
|
2012-08-12 20:28:42 +02:00
|
|
|
char auxiliar[70], *aux_pointer;
|
|
|
|
|
sprintf(auxiliar, "%s [%s]", tv->va_name, device->instanceParms[i].keyword);
|
|
|
|
|
aux_pointer = tv->va_name;
|
2011-09-18 11:03:55 +02:00
|
|
|
free(aux_pointer);
|
|
|
|
|
tv->va_name = copy(auxiliar);
|
|
|
|
|
}
|
2012-08-14 20:38:25 +02:00
|
|
|
if (vv)
|
|
|
|
|
tv->va_next = vv;
|
2011-09-18 11:03:55 +02:00
|
|
|
vv = tv;
|
2012-09-20 20:30:53 +02:00
|
|
|
} else {
|
|
|
|
|
fprintf(cp_err,
|
|
|
|
|
"Internal Error: no parameter '%s' on device '%s'\n",
|
2012-08-12 20:28:42 +02:00
|
|
|
device->instanceParms[i].keyword, device->name);
|
2012-09-20 20:30:53 +02:00
|
|
|
}
|
2011-09-18 11:03:55 +02:00
|
|
|
}
|
2012-09-20 20:30:53 +02:00
|
|
|
return (vv);
|
2011-09-18 11:03:55 +02:00
|
|
|
} else { /* Is it a model or a device ? */
|
|
|
|
|
/* It is a model */
|
|
|
|
|
for (i = 0; i < *(device->numModelParms); i++) {
|
|
|
|
|
opt = &device->modelParms[i];
|
2012-08-14 20:38:25 +02:00
|
|
|
if (opt->dataType & IF_REDUNDANT || !opt->description)
|
|
|
|
|
continue;
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* We check that the parameter is interesting and therefore is
|
|
|
|
|
* implemented in the corresponding function ModelAsk. Originally
|
|
|
|
|
* the argument of "if" was: || (opt->dataType & IF_STRING)) continue;
|
|
|
|
|
* so, a model parameter defined like OP("type", MOS_SGT_MOD_TYPE,
|
|
|
|
|
* IF_STRING, N-channel or P-channel MOS") would not be printed.
|
|
|
|
|
*/
|
2009-01-15 17:46:31 +01:00
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
/* if (!(opt->dataType & IF_ASK) || (opt->dataType & IF_UNINTERESTING) || (opt->dataType & IF_STRING)) continue; */
|
2012-09-22 19:32:30 +02:00
|
|
|
if (!(opt->dataType & IF_ASK) || (opt->dataType & IF_UNINTERESTING))
|
2012-08-14 20:38:25 +02:00
|
|
|
continue;
|
2011-09-18 11:03:55 +02:00
|
|
|
pv = doask(ckt, typecode, dev, mod, opt, ind);
|
|
|
|
|
if (pv) {
|
|
|
|
|
tv = parmtovar(pv, opt);
|
|
|
|
|
/* Inside parmtovar:
|
|
|
|
|
* 1. tv->va_name = copy(opt->description);
|
|
|
|
|
* 2. Copy the type of variable of IFparm into a variable (thus parm-to-var)
|
|
|
|
|
* vv->va_type = opt->dataType
|
|
|
|
|
* The long description of the parameter:
|
|
|
|
|
* IFparm MOS_SGTmPTable[] = { // model parameters //
|
|
|
|
|
* OP("type", MOS_SGT_MOD_TYPE, IF_STRING, "N-channel or P-channel MOS")
|
|
|
|
|
* goes into tv->va_name to put braces around the parameter of the model
|
|
|
|
|
* tv->va_name += device->modelParms[i].keyword;
|
|
|
|
|
*/
|
|
|
|
|
{
|
2012-08-12 20:28:42 +02:00
|
|
|
char auxiliar[70], *aux_pointer;
|
|
|
|
|
sprintf(auxiliar, "%s [%s]", tv->va_name, device->modelParms[i].keyword);
|
|
|
|
|
aux_pointer = tv->va_name;
|
2011-09-18 11:03:55 +02:00
|
|
|
free(aux_pointer);
|
|
|
|
|
tv->va_name = copy(auxiliar);
|
2012-08-12 20:28:42 +02:00
|
|
|
/* strcpy(aux_pointer, auxiliar); */
|
2011-09-18 11:03:55 +02:00
|
|
|
}
|
2012-08-12 20:28:42 +02:00
|
|
|
/* tv->va_string = device->modelParms[i].keyword; Put the name of the variable */
|
2012-08-14 20:38:25 +02:00
|
|
|
if (vv)
|
2011-09-18 11:03:55 +02:00
|
|
|
tv->va_next = vv;
|
|
|
|
|
vv = tv;
|
2012-09-20 20:30:53 +02:00
|
|
|
} else {
|
|
|
|
|
fprintf(cp_err,
|
|
|
|
|
"Internal Error: no parameter '%s' on device '%s'\n",
|
|
|
|
|
device->modelParms[i].keyword, device->name);
|
|
|
|
|
}
|
2009-01-15 17:46:31 +01:00
|
|
|
}
|
2012-09-20 20:30:53 +02:00
|
|
|
return (vv);
|
2009-01-15 17:46:31 +01:00
|
|
|
}
|
2011-09-18 11:03:55 +02:00
|
|
|
} else if (param) {
|
2010-07-08 19:50:29 +02:00
|
|
|
INPretrieve(name, ft_curckt->ci_symtab);
|
2010-07-08 19:20:03 +02:00
|
|
|
typecode = finddev_special(ckt, *name, &dev, &mod, &modelo_dispositivo);
|
2011-09-18 11:03:55 +02:00
|
|
|
if (typecode == -1) {
|
2012-08-12 20:28:42 +02:00
|
|
|
fprintf(cp_err, "Error: no such device or model name %s\n", *name);
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2009-01-15 17:46:31 +01:00
|
|
|
}
|
|
|
|
|
device = ft_sim->devices[typecode];
|
|
|
|
|
opt = parmlookup(device, &dev, param, modelo_dispositivo, 0);
|
2011-09-18 11:03:55 +02:00
|
|
|
if (!opt) {
|
2012-08-12 20:28:42 +02:00
|
|
|
fprintf(cp_err, "Error: no such parameter %s.\n", param);
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2009-01-15 17:46:31 +01:00
|
|
|
}
|
|
|
|
|
pv = doask(ckt, typecode, dev, mod, opt, ind);
|
|
|
|
|
if (pv)
|
|
|
|
|
vv = parmtovar(pv, opt);
|
2012-09-20 20:30:53 +02:00
|
|
|
return (vv);
|
|
|
|
|
} else {
|
|
|
|
|
return (if_getstat(ckt, *name));
|
|
|
|
|
}
|
2009-01-15 17:46:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Get a parameter value from the circuit. If name is left unspecified,
|
|
|
|
|
* we want a circuit parameter.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct variable *
|
2012-09-20 20:30:53 +02:00
|
|
|
spif_getparam(CKTcircuit *ckt, char **name, char *param, int ind, int do_model)
|
|
|
|
|
{
|
2000-04-27 22:03:57 +02:00
|
|
|
struct variable *vv = NULL, *tv;
|
|
|
|
|
IFvalue *pv;
|
|
|
|
|
IFparm *opt;
|
|
|
|
|
int typecode, i;
|
2011-04-28 17:59:36 +02:00
|
|
|
GENinstance *dev = NULL;
|
|
|
|
|
GENmodel *mod = NULL;
|
2000-04-27 22:03:57 +02:00
|
|
|
IFdevice *device;
|
|
|
|
|
|
|
|
|
|
/* fprintf(cp_err, "Calling if_getparam(%s, %s)\n", *name, param); */
|
|
|
|
|
|
|
|
|
|
if (param && eq(param, "all")) {
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* MW. My "special routine here" */
|
2010-07-08 19:50:29 +02:00
|
|
|
INPretrieve(name, ft_curckt->ci_symtab);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2010-07-08 19:20:03 +02:00
|
|
|
typecode = finddev(ckt, *name, &dev, &mod);
|
2000-04-27 22:03:57 +02:00
|
|
|
if (typecode == -1) {
|
|
|
|
|
fprintf(cp_err,
|
2011-09-18 11:03:55 +02:00
|
|
|
"Error: no such device or model name %s\n",
|
2000-04-27 22:03:57 +02:00
|
|
|
*name);
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
device = ft_sim->devices[typecode];
|
|
|
|
|
for (i = 0; i < *(device->numInstanceParms); i++) {
|
|
|
|
|
opt = &device->instanceParms[i];
|
2012-08-12 20:28:42 +02:00
|
|
|
if (opt->dataType & IF_REDUNDANT || !opt->description)
|
2011-09-18 11:03:55 +02:00
|
|
|
continue;
|
2012-08-14 20:38:25 +02:00
|
|
|
if (!(opt->dataType & IF_ASK))
|
|
|
|
|
continue;
|
2004-08-16 23:05:42 +02:00
|
|
|
pv = doask(ckt, typecode, dev, mod, opt, ind);
|
2000-04-27 22:03:57 +02:00
|
|
|
if (pv) {
|
|
|
|
|
tv = parmtovar(pv, opt);
|
|
|
|
|
if (vv)
|
|
|
|
|
tv->va_next = vv;
|
|
|
|
|
vv = tv;
|
2012-09-20 20:30:53 +02:00
|
|
|
} else {
|
2000-04-27 22:03:57 +02:00
|
|
|
fprintf(cp_err,
|
2011-09-18 11:03:55 +02:00
|
|
|
"Internal Error: no parameter '%s' on device '%s'\n",
|
|
|
|
|
device->instanceParms[i].keyword,
|
|
|
|
|
device->name);
|
2012-09-20 20:30:53 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-09-20 20:30:53 +02:00
|
|
|
return (vv);
|
2000-04-27 22:03:57 +02:00
|
|
|
} else if (param) {
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* MW. */
|
2010-07-08 19:50:29 +02:00
|
|
|
INPretrieve(name, ft_curckt->ci_symtab);
|
2010-07-08 19:20:03 +02:00
|
|
|
typecode = finddev(ckt, *name, &dev, &mod);
|
2000-04-27 22:03:57 +02:00
|
|
|
if (typecode == -1) {
|
2012-09-20 20:30:53 +02:00
|
|
|
fprintf(cp_err, "Error: no such device or model name %s\n", *name);
|
|
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
device = ft_sim->devices[typecode];
|
2004-08-16 23:05:42 +02:00
|
|
|
opt = parmlookup(device, &dev, param, do_model, 0);
|
2000-04-27 22:03:57 +02:00
|
|
|
if (!opt) {
|
2012-09-20 20:30:53 +02:00
|
|
|
fprintf(cp_err, "Error: no such parameter %s.\n", param);
|
|
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2004-08-16 23:05:42 +02:00
|
|
|
pv = doask(ckt, typecode, dev, mod, opt, ind);
|
2000-04-27 22:03:57 +02:00
|
|
|
if (pv)
|
|
|
|
|
vv = parmtovar(pv, opt);
|
2012-09-20 20:30:53 +02:00
|
|
|
return (vv);
|
|
|
|
|
} else {
|
|
|
|
|
return (if_getstat(ckt, *name));
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2007-10-08 23:45:00 +02:00
|
|
|
/* 9/26/03 PJB : function to allow setting model of device */
|
|
|
|
|
void
|
2012-08-05 12:11:16 +02:00
|
|
|
if_setparam_model(CKTcircuit *ckt, char **name, char *val)
|
2007-10-08 23:45:00 +02:00
|
|
|
{
|
2011-09-18 11:03:55 +02:00
|
|
|
GENinstance *dev = NULL;
|
|
|
|
|
GENinstance *prevDev = NULL;
|
|
|
|
|
GENmodel *curMod = NULL;
|
|
|
|
|
GENmodel *newMod = NULL;
|
|
|
|
|
INPmodel *inpmod = NULL;
|
|
|
|
|
GENinstance *iter;
|
|
|
|
|
GENmodel *mods, *prevMod;
|
|
|
|
|
int typecode;
|
2012-08-05 12:11:16 +02:00
|
|
|
char *modname;
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* retrieve device name from symbol table */
|
|
|
|
|
INPretrieve(name, ft_curckt->ci_symtab);
|
|
|
|
|
/* find the specified device */
|
|
|
|
|
typecode = finddev(ckt, *name, &dev, &curMod);
|
|
|
|
|
if (typecode == -1) {
|
2012-08-05 12:11:16 +02:00
|
|
|
fprintf(cp_err, "Error: no such device name %s\n", *name);
|
2011-09-18 11:03:55 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
curMod = dev->GENmodPtr;
|
2012-08-05 12:11:16 +02:00
|
|
|
modname = copy(dev->GENmodPtr->GENmodName);
|
|
|
|
|
modname = strtok(modname, "."); /* want only have the parent model name */
|
2011-09-18 11:03:55 +02:00
|
|
|
/*
|
2012-08-12 20:28:42 +02:00
|
|
|
retrieve the model from the global model table; also add the model to 'ckt'
|
|
|
|
|
and indicate model is being used
|
2011-09-18 11:03:55 +02:00
|
|
|
*/
|
2012-08-12 20:28:42 +02:00
|
|
|
INPgetMod(ckt, modname, &inpmod, ft_curckt->ci_symtab);
|
2012-08-05 12:11:16 +02:00
|
|
|
/* check if using model binning -- pass in line since need 'l' and 'w' */
|
2012-08-14 20:38:25 +02:00
|
|
|
if (inpmod == NULL)
|
2012-08-12 20:28:42 +02:00
|
|
|
INPgetModBin(ckt, modname, &inpmod, ft_curckt->ci_symtab, val);
|
2012-08-05 12:11:16 +02:00
|
|
|
tfree(modname);
|
2012-08-12 20:28:42 +02:00
|
|
|
if (inpmod == NULL) {
|
2013-02-22 22:25:55 +01:00
|
|
|
fprintf(cp_err, "Error: no model available for %s.\n", val);
|
2011-09-18 11:03:55 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
newMod = inpmod->INPmodfast;
|
2007-10-08 23:45:00 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/* see if new model name same as current model name */
|
2012-08-14 20:38:25 +02:00
|
|
|
if (newMod->GENmodName != curMod->GENmodName)
|
2012-08-05 12:11:16 +02:00
|
|
|
printf("Notice: model has changed from %s to %s.\n", curMod->GENmodName, newMod->GENmodName);
|
2012-08-12 20:28:42 +02:00
|
|
|
if (newMod->GENmodType != curMod->GENmodType) {
|
2011-09-18 11:03:55 +02:00
|
|
|
fprintf(cp_err, "Error: new model %s must be same type as current model.\n", val);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* fix current model linked list */
|
|
|
|
|
prevDev = NULL;
|
2012-08-14 20:38:25 +02:00
|
|
|
for (iter = curMod->GENinstances; iter; iter = iter->GENnextInstance) {
|
2012-08-12 20:28:42 +02:00
|
|
|
if (iter->GENname == dev->GENname) {
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* see if at beginning of linked list */
|
2012-08-14 20:38:25 +02:00
|
|
|
if (prevDev == NULL)
|
|
|
|
|
curMod->GENinstances = iter->GENnextInstance;
|
|
|
|
|
else
|
|
|
|
|
prevDev->GENnextInstance = iter->GENnextInstance;
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* update model for device */
|
|
|
|
|
dev->GENmodPtr = newMod;
|
|
|
|
|
dev->GENnextInstance = newMod->GENinstances;
|
|
|
|
|
newMod->GENinstances = dev;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
prevDev = iter;
|
|
|
|
|
}
|
|
|
|
|
/* see if any devices remaining that reference current model */
|
2012-08-12 20:28:42 +02:00
|
|
|
if (curMod->GENinstances == NULL) {
|
2011-09-18 11:03:55 +02:00
|
|
|
prevMod = NULL;
|
2012-08-14 20:38:25 +02:00
|
|
|
for (mods = ckt->CKThead[typecode]; mods; mods = mods->GENnextModel) {
|
2012-08-12 20:28:42 +02:00
|
|
|
if (mods->GENmodName == curMod->GENmodName) {
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* see if at beginning of linked list */
|
2012-08-14 20:38:25 +02:00
|
|
|
if (prevMod == NULL)
|
|
|
|
|
ckt->CKThead[typecode] = mods->GENnextModel;
|
|
|
|
|
else
|
|
|
|
|
prevMod->GENnextModel = mods->GENnextModel;
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
INPgetMod(ckt, mods->GENmodName, &inpmod, ft_curckt->ci_symtab);
|
2013-07-17 20:36:21 +02:00
|
|
|
if (curMod != nghash_delete(ckt->MODnameHash, curMod->GENmodName))
|
|
|
|
|
fprintf(stderr, "ERROR, ouch nasal daemons ...\n");
|
2011-09-18 11:03:55 +02:00
|
|
|
FREE(mods);
|
|
|
|
|
|
2013-07-17 20:40:13 +02:00
|
|
|
inpmod->INPmodfast = NULL;
|
2011-09-18 11:03:55 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
prevMod = mods;
|
|
|
|
|
}
|
2007-10-08 23:45:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
void
|
2010-07-06 21:03:40 +02:00
|
|
|
if_setparam(CKTcircuit *ckt, char **name, char *param, struct dvec *val, int do_model)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
|
|
|
|
IFparm *opt;
|
|
|
|
|
IFdevice *device;
|
2011-04-28 17:59:36 +02:00
|
|
|
GENmodel *mod = NULL;
|
|
|
|
|
GENinstance *dev = NULL;
|
2000-04-27 22:03:57 +02:00
|
|
|
int typecode;
|
|
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/* PN */
|
2010-07-08 19:50:29 +02:00
|
|
|
INPretrieve(name, ft_curckt->ci_symtab);
|
2010-07-08 19:20:03 +02:00
|
|
|
typecode = finddev(ckt, *name, &dev, &mod);
|
2000-04-27 22:03:57 +02:00
|
|
|
if (typecode == -1) {
|
2011-09-18 11:03:55 +02:00
|
|
|
fprintf(cp_err, "Error: no such device or model name %s\n", *name);
|
|
|
|
|
return;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
device = ft_sim->devices[typecode];
|
2004-08-16 23:05:42 +02:00
|
|
|
opt = parmlookup(device, &dev, param, do_model, 1);
|
2000-04-27 22:03:57 +02:00
|
|
|
if (!opt) {
|
2011-09-18 11:03:55 +02:00
|
|
|
if (param)
|
|
|
|
|
fprintf(cp_err, "Error: no such parameter %s.\n", param);
|
|
|
|
|
else
|
|
|
|
|
fprintf(cp_err, "Error: no default parameter.\n");
|
|
|
|
|
return;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2004-08-16 23:05:42 +02:00
|
|
|
if (do_model && !mod) {
|
2011-09-18 11:03:55 +02:00
|
|
|
mod = dev->GENmodPtr;
|
|
|
|
|
dev = NULL;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2004-08-16 23:05:42 +02:00
|
|
|
doset(ckt, typecode, dev, mod, opt, val);
|
2011-01-01 15:38:47 +01:00
|
|
|
|
|
|
|
|
/* Call to CKTtemp(ckt) will be invoked here only by 'altermod' commands,
|
2011-09-18 11:03:55 +02:00
|
|
|
to set internal model parameters pParam of each instance for immediate use,
|
|
|
|
|
otherwise e.g. model->BSIM3vth0 will be set, but not pParam of any BSIM3 instance.
|
2011-01-02 15:15:42 +01:00
|
|
|
Call only if CKTtime > 0 to avoid conflict with previous 'reset' command.
|
2011-09-18 11:03:55 +02:00
|
|
|
May contain side effects because called from many places. h_vogt 110101
|
2011-01-01 15:38:47 +01:00
|
|
|
*/
|
2013-07-24 20:58:34 +02:00
|
|
|
if (do_model && (ckt->CKTtime > 0)) {
|
2011-01-03 21:37:36 +01:00
|
|
|
int error = 0;
|
|
|
|
|
error = CKTtemp(ckt);
|
2012-09-20 20:30:53 +02:00
|
|
|
if (error)
|
|
|
|
|
fprintf(stderr, "Error during changing a device model parameter!\n");
|
|
|
|
|
if (error)
|
|
|
|
|
controlled_exit(1);
|
2011-01-03 21:37:36 +01:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
static struct variable *
|
2012-09-20 20:30:53 +02:00
|
|
|
parmtovar(IFvalue *pv, IFparm *opt)
|
|
|
|
|
{
|
2000-04-27 22:03:57 +02:00
|
|
|
struct variable *vv = alloc(struct variable);
|
|
|
|
|
struct variable *nv;
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
switch (opt->dataType & IF_VARTYPES) {
|
2011-09-18 11:03:55 +02:00
|
|
|
case IF_INTEGER:
|
|
|
|
|
vv->va_type = CP_NUM;
|
|
|
|
|
vv->va_num = pv->iValue;
|
|
|
|
|
break;
|
|
|
|
|
case IF_REAL:
|
|
|
|
|
case IF_COMPLEX:
|
|
|
|
|
vv->va_type = CP_REAL;
|
|
|
|
|
vv->va_real = pv->rValue;
|
|
|
|
|
break;
|
|
|
|
|
case IF_STRING:
|
|
|
|
|
vv->va_type = CP_STRING;
|
|
|
|
|
vv->va_string = pv->sValue;
|
|
|
|
|
break;
|
|
|
|
|
case IF_FLAG:
|
|
|
|
|
vv->va_type = CP_BOOL;
|
|
|
|
|
vv->va_bool = pv->iValue ? TRUE : FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case IF_REALVEC:
|
|
|
|
|
vv->va_type = CP_LIST;
|
|
|
|
|
for (i = 0; i < pv->v.numValue; i++) {
|
|
|
|
|
nv = alloc(struct variable);
|
|
|
|
|
nv->va_next = vv->va_vlist;
|
|
|
|
|
vv->va_vlist = nv;
|
|
|
|
|
nv->va_type = CP_REAL;
|
|
|
|
|
/* Change this so that the values are printed in order and
|
|
|
|
|
* not in inverted order as happens in the conversion process.
|
|
|
|
|
* Originally was nv->va_real = pv->v.vec.rVec[i];
|
|
|
|
|
*/
|
|
|
|
|
nv->va_real = pv->v.vec.rVec[pv->v.numValue-i-1];
|
|
|
|
|
}
|
|
|
|
|
/* It is a linked list where the first node is a variable
|
|
|
|
|
* pointing to the different values of the variables.
|
|
|
|
|
*
|
|
|
|
|
* To access the values of the real variable vector must be
|
2012-08-12 20:28:42 +02:00
|
|
|
* vv->va_V.vV_real = valor node ppal that is of no use.
|
2011-09-18 11:03:55 +02:00
|
|
|
*
|
|
|
|
|
* In the case of Vin_sin 1 0 sin (0 2 2000)
|
|
|
|
|
* and of print @vin_sin[sin]
|
|
|
|
|
*
|
2012-08-12 20:28:42 +02:00
|
|
|
* vv->va_V.vV_list->va_V.vV_real = 2000
|
|
|
|
|
* vv->va_V.vV_list->va_next->va_V.vV_real = 2
|
|
|
|
|
* vv->va_V.vV_list->va_next->va_next->va_V.vV_real = 0
|
2011-09-18 11:03:55 +02:00
|
|
|
* So the list is starting from behind, but no problem
|
|
|
|
|
* This works fine
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(cp_err,
|
|
|
|
|
"parmtovar: Internal Error: bad PARM type %d.\n",
|
|
|
|
|
opt->dataType);
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* It's not clear whether we want the keyword or the desc here... */
|
|
|
|
|
vv->va_name = copy(opt->description);
|
|
|
|
|
vv->va_next = NULL;
|
2012-09-20 20:30:53 +02:00
|
|
|
return (vv);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2005-04-24 23:17:31 +02:00
|
|
|
/* Extract the parameter (IFparm structure) from the device or device's model.
|
|
|
|
|
* If do_mode is TRUE then look in the device's parameters
|
|
|
|
|
* If do_mode is FALSE then look in the device model's parameters
|
|
|
|
|
* If inout equals 1 then look only for parameters with the IF_SET type flag
|
|
|
|
|
* if inout equals 0 then look only for parameters with the IF_ASK type flag
|
2000-04-27 22:03:57 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static IFparm *
|
|
|
|
|
parmlookup(IFdevice *dev, GENinstance **inptr, char *param, int do_model, int inout)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(inptr);
|
2010-11-16 20:11:32 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* First try the device questions... */
|
|
|
|
|
if (!do_model && dev->numInstanceParms) {
|
|
|
|
|
for (i = 0; i < *(dev->numInstanceParms); i++) {
|
|
|
|
|
if (!param && (dev->instanceParms[i].dataType & IF_PRINCIPAL))
|
2012-09-20 20:30:53 +02:00
|
|
|
return (&dev->instanceParms[i]);
|
2011-09-18 11:03:55 +02:00
|
|
|
else if (!param)
|
|
|
|
|
continue;
|
2012-09-20 20:30:53 +02:00
|
|
|
else if ((((dev->instanceParms[i].dataType & IF_SET) && inout == 1) ||
|
|
|
|
|
((dev->instanceParms[i].dataType & IF_ASK) && inout == 0)) &&
|
|
|
|
|
cieq(dev->instanceParms[i].keyword, param))
|
|
|
|
|
{
|
2011-09-18 11:03:55 +02:00
|
|
|
if (dev->instanceParms[i].dataType & IF_REDUNDANT)
|
|
|
|
|
i -= 1;
|
2012-09-20 20:30:53 +02:00
|
|
|
return (&dev->instanceParms[i]);
|
2011-09-18 11:03:55 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2011-09-18 11:03:55 +02:00
|
|
|
return NULL;
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-14 20:38:25 +02:00
|
|
|
if (dev->numModelParms)
|
2011-09-18 11:03:55 +02:00
|
|
|
for (i = 0; i < *(dev->numModelParms); i++)
|
2012-08-14 20:38:25 +02:00
|
|
|
if ((((dev->modelParms[i].dataType & IF_SET) && inout == 1) ||
|
|
|
|
|
((dev->modelParms[i].dataType & IF_ASK) && inout == 0)) &&
|
|
|
|
|
eq(dev->modelParms[i].keyword, param))
|
|
|
|
|
{
|
2011-09-18 11:03:55 +02:00
|
|
|
if (dev->modelParms[i].dataType & IF_REDUNDANT)
|
|
|
|
|
i -= 1;
|
2012-09-20 20:30:53 +02:00
|
|
|
return (&dev->modelParms[i]);
|
2011-09-18 11:03:55 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Perform the CKTask call. We have both 'fast' and 'modfast', so the other
|
|
|
|
|
* parameters aren't necessary.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static IFvalue *
|
2010-07-06 21:03:40 +02:00
|
|
|
doask(CKTcircuit *ckt, int typecode, GENinstance *dev, GENmodel *mod, IFparm *opt, int ind)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
|
|
|
|
static IFvalue pv;
|
|
|
|
|
int err;
|
|
|
|
|
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(typecode);
|
2010-11-16 20:11:32 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
pv.iValue = ind; /* Sometimes this will be junk and ignored... */
|
|
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/* fprintf(cp_err, "Calling doask(%d, %x, %x, %x)\n",
|
2012-08-12 20:28:42 +02:00
|
|
|
typecode, dev, mod, opt); */
|
2000-04-27 22:03:57 +02:00
|
|
|
if (dev)
|
2012-08-14 20:38:25 +02:00
|
|
|
err = ft_sim->askInstanceQuest (ckt, dev, opt->id, &pv, NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
else
|
2012-08-14 20:38:25 +02:00
|
|
|
err = ft_sim->askModelQuest (ckt, mod, opt->id, &pv, NULL);
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
if (err != OK) {
|
|
|
|
|
ft_sperror(err, "if_getparam");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
return (&pv);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Perform the CKTset call. We have both 'fast' and 'modfast', so the other
|
|
|
|
|
* parameters aren't necessary.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int
|
2010-07-06 21:03:40 +02:00
|
|
|
doset(CKTcircuit *ckt, int typecode, GENinstance *dev, GENmodel *mod, IFparm *opt, struct dvec *val)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
|
|
|
|
IFvalue nval;
|
|
|
|
|
int err;
|
|
|
|
|
int n;
|
|
|
|
|
int *iptr;
|
|
|
|
|
double *dptr;
|
|
|
|
|
int i;
|
|
|
|
|
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(typecode);
|
2010-11-16 20:11:32 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Count items */
|
|
|
|
|
if (opt->dataType & IF_VECTOR) {
|
2011-09-18 11:03:55 +02:00
|
|
|
n = nval.v.numValue = val->v_length;
|
|
|
|
|
|
|
|
|
|
dptr = val->v_realdata;
|
|
|
|
|
/* XXXX compdata!!! */
|
|
|
|
|
|
|
|
|
|
switch (opt->dataType & (IF_VARTYPES & ~IF_VECTOR)) {
|
|
|
|
|
case IF_FLAG:
|
|
|
|
|
case IF_INTEGER:
|
|
|
|
|
iptr = nval.v.vec.iVec = NEWN(int, n);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
|
*iptr++ = (int)floor(*dptr++ + 0.5);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case IF_REAL:
|
|
|
|
|
nval.v.vec.rVec = val->v_realdata;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
fprintf(cp_err,
|
|
|
|
|
"Can't assign value to \"%s\" (unsupported vector type)\n",
|
|
|
|
|
opt->keyword);
|
|
|
|
|
return E_UNSUPP;
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
} else {
|
2011-09-18 11:03:55 +02:00
|
|
|
switch (opt->dataType & IF_VARTYPES) {
|
|
|
|
|
case IF_FLAG:
|
|
|
|
|
case IF_INTEGER:
|
|
|
|
|
nval.iValue = (int)floor(*val->v_realdata + 0.5);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case IF_REAL:
|
|
|
|
|
/*kensmith don't blow up with NULL dereference*/
|
|
|
|
|
if (!val->v_realdata) {
|
2012-08-12 20:28:42 +02:00
|
|
|
fprintf(cp_err, "Unable to determine the value\n");
|
2011-09-18 11:03:55 +02:00
|
|
|
return E_UNSUPP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nval.rValue = *val->v_realdata;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
fprintf(cp_err,
|
|
|
|
|
"Can't assign value to \"%s\" (unsupported type)\n",
|
|
|
|
|
opt->keyword);
|
|
|
|
|
return E_UNSUPP;
|
|
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/* fprintf(cp_err, "Calling doask(%d, %x, %x, %x)\n",
|
2012-08-12 20:28:42 +02:00
|
|
|
typecode, dev, mod, opt); */
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
if (dev)
|
2012-08-14 20:38:25 +02:00
|
|
|
err = ft_sim->setInstanceParm (ckt, dev, opt->id, &nval, NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
else
|
2012-08-14 20:38:25 +02:00
|
|
|
err = ft_sim->setModelParm (ckt, mod, opt->id, &nval, NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Get pointers to a device, its model, and its type number given the name. If
|
|
|
|
|
* there is no such device, try to find a model with that name.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int
|
2013-06-30 20:23:58 +02:00
|
|
|
finddev(CKTcircuit *ckt, char *name, GENinstance **devptr, GENmodel **modptr)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
2013-07-17 20:28:42 +02:00
|
|
|
*devptr = ft_sim->findInstance (ckt, name);
|
2013-07-17 20:27:52 +02:00
|
|
|
if (*devptr)
|
2013-07-04 19:43:16 +02:00
|
|
|
return (*devptr)->GENmodPtr->GENmodType;
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2013-07-17 20:36:29 +02:00
|
|
|
*modptr = ft_sim->findModel (ckt, name);
|
2013-07-17 20:31:12 +02:00
|
|
|
if (*modptr)
|
2013-07-17 20:34:04 +02:00
|
|
|
return (*modptr)->GENmodType;
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
return (-1);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* get an analysis parameter by name instead of id */
|
|
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
int
|
2010-10-08 18:49:18 +02:00
|
|
|
if_analQbyName(CKTcircuit *ckt, int which, JOB *anal, char *name, IFvalue *parm)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
|
|
|
|
int i;
|
2012-08-14 20:38:25 +02:00
|
|
|
for (i = 0; i < ft_sim->analyses[which]->numParms; i++)
|
|
|
|
|
if (strcmp(ft_sim->analyses[which]->analysisParms[i].keyword, name) == 0)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (ft_sim->askAnalysisQuest
|
2012-08-14 20:38:25 +02:00
|
|
|
(ckt, anal, ft_sim->analyses[which]->analysisParms[i].id, parm, NULL));
|
2012-09-20 20:30:53 +02:00
|
|
|
return (E_BADPARM);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Get the parameters tstart, tstop, and tstep from the CKT struct. */
|
|
|
|
|
|
|
|
|
|
/* BLOW THIS AWAY TOO */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
if_tranparams(struct circ *ci, double *start, double *stop, double *step)
|
|
|
|
|
{
|
|
|
|
|
IFvalue tmp;
|
|
|
|
|
int err;
|
|
|
|
|
int which = -1;
|
2010-10-08 18:49:18 +02:00
|
|
|
JOB *anal;
|
2000-04-27 22:03:57 +02:00
|
|
|
IFuid tranUid;
|
|
|
|
|
|
2012-08-14 20:38:25 +02:00
|
|
|
if (!ci->ci_curTask)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (FALSE);
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2013-07-27 20:34:59 +02:00
|
|
|
which = ft_find_analysis("TRAN");
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2012-08-14 20:38:25 +02:00
|
|
|
if (which == -1)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (FALSE);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2013-07-14 15:15:04 +02:00
|
|
|
err = IFnewUid(ci->ci_ckt, &tranUid, NULL, "Transient Analysis", UID_ANALYSIS, NULL);
|
2012-08-14 20:38:25 +02:00
|
|
|
if (err != OK)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (FALSE);
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2011-04-27 20:30:15 +02:00
|
|
|
err = ft_sim->findAnalysis (ci->ci_ckt, &which, &anal, tranUid,
|
2011-09-18 11:03:55 +02:00
|
|
|
ci->ci_curTask, NULL);
|
2012-08-14 20:38:25 +02:00
|
|
|
if (err != OK)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (FALSE);
|
2012-08-12 20:28:42 +02:00
|
|
|
|
|
|
|
|
err = if_analQbyName(ci->ci_ckt, which, anal, "tstart", &tmp);
|
2012-08-14 20:38:25 +02:00
|
|
|
if (err != OK)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (FALSE);
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
*start = tmp.rValue;
|
2012-08-12 20:28:42 +02:00
|
|
|
|
|
|
|
|
err = if_analQbyName(ci->ci_ckt, which, anal, "tstop", &tmp);
|
2012-08-14 20:38:25 +02:00
|
|
|
if (err != OK)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (FALSE);
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
*stop = tmp.rValue;
|
2012-08-12 20:28:42 +02:00
|
|
|
|
|
|
|
|
err = if_analQbyName(ci->ci_ckt, which, anal, "tstep", &tmp);
|
2012-08-14 20:38:25 +02:00
|
|
|
if (err != OK)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (FALSE);
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
*step = tmp.rValue;
|
2012-09-20 20:30:53 +02:00
|
|
|
return (TRUE);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* Get the statistic called 'name'. If this is NULL get all statistics
|
|
|
|
|
* available.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct variable *
|
2012-09-20 20:30:53 +02:00
|
|
|
if_getstat(CKTcircuit *ckt, char *name)
|
|
|
|
|
{
|
2000-04-27 22:03:57 +02:00
|
|
|
int i;
|
|
|
|
|
struct variable *v, *vars;
|
|
|
|
|
IFvalue parm;
|
|
|
|
|
int which = -1;
|
|
|
|
|
|
2013-07-27 20:34:59 +02:00
|
|
|
which = ft_find_analysis("options");
|
2012-08-12 20:28:42 +02:00
|
|
|
|
|
|
|
|
if (which == -1) {
|
|
|
|
|
fprintf(cp_err, "Warning: statistics unsupported\n");
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
|
for (i = 0; i < ft_sim->analyses[which]->numParms; i++)
|
|
|
|
|
if (eq(ft_sim->analyses[which]->analysisParms[i].keyword, name))
|
|
|
|
|
break;
|
|
|
|
|
if (i == ft_sim->analyses[which]->numParms)
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2011-04-27 20:30:15 +02:00
|
|
|
if (ft_sim->askAnalysisQuest (ckt, &(ft_curckt->ci_curTask->taskOptions),
|
2011-09-18 11:03:55 +02:00
|
|
|
ft_sim->analyses[which]->analysisParms[i].id, &parm,
|
2012-08-14 20:38:25 +02:00
|
|
|
NULL) == -1)
|
|
|
|
|
{
|
2012-09-20 20:30:53 +02:00
|
|
|
fprintf(cp_err, "if_getstat: Internal Error: can't get %s\n", name);
|
|
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
2012-09-20 20:30:53 +02:00
|
|
|
return (parmtovar(&parm, &(ft_sim->analyses[which]->analysisParms[i])));
|
2000-04-27 22:03:57 +02:00
|
|
|
} else {
|
2012-08-12 20:28:42 +02:00
|
|
|
for (i = 0, vars = v = NULL; i < ft_sim->analyses[which]->numParms; i++) {
|
2012-08-14 20:38:25 +02:00
|
|
|
if (!(ft_sim->analyses[which]->analysisParms[i].dataType & IF_ASK))
|
2000-04-27 22:03:57 +02:00
|
|
|
continue;
|
2011-04-27 20:30:15 +02:00
|
|
|
if (ft_sim->askAnalysisQuest (ckt, &(ft_curckt->ci_curTask->taskOptions),
|
2011-09-18 11:03:55 +02:00
|
|
|
ft_sim->analyses[which]->analysisParms[i].id,
|
|
|
|
|
&parm, NULL) == -1) {
|
|
|
|
|
fprintf(cp_err,
|
|
|
|
|
"if_getstat: Internal Error: can't get %s\n",
|
|
|
|
|
name);
|
2012-09-20 20:30:53 +02:00
|
|
|
return (NULL);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
if (v) {
|
2012-08-14 20:38:25 +02:00
|
|
|
v->va_next =
|
|
|
|
|
parmtovar(&parm, &(ft_sim->analyses[which]->analysisParms[i]));
|
2000-04-27 22:03:57 +02:00
|
|
|
v = v->va_next;
|
|
|
|
|
} else {
|
2012-08-14 20:38:25 +02:00
|
|
|
vars = v =
|
|
|
|
|
parmtovar(&parm, &(ft_sim->analyses[which]->analysisParms[i]));
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-09-20 20:30:53 +02:00
|
|
|
return (vars);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-20 20:30:53 +02:00
|
|
|
|
2012-02-19 11:23:56 +01:00
|
|
|
/* Some small updates to make it work, h_vogt, Feb. 2012
|
|
|
|
|
Still very experimental !
|
|
|
|
|
It is now possible to save a state during transient simulation,
|
|
|
|
|
reload it later into a new ngspice run and resume simulation.
|
|
|
|
|
XSPICE code models probably will not do.
|
|
|
|
|
LTRA transmission line will not do.
|
|
|
|
|
Many others are not tested.
|
|
|
|
|
*/
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/cktdefs.h"
|
|
|
|
|
#include "ngspice/trandefs.h"
|
2003-07-23 21:36:39 +02:00
|
|
|
|
|
|
|
|
/* arg0: circuit file, arg1: data file */
|
2012-11-01 14:41:13 +01:00
|
|
|
void com_snload(wordlist *wl)
|
2011-09-18 11:03:55 +02:00
|
|
|
{
|
|
|
|
|
int error = 0;
|
|
|
|
|
FILE *file;
|
|
|
|
|
int tmpI, i, size;
|
|
|
|
|
CKTcircuit *my_ckt, *ckt;
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/*
|
2012-04-08 11:00:49 +02:00
|
|
|
Pseudo code:
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
source(file_name);
|
|
|
|
|
This should setup all the device structs, voltage nodes, etc.
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
call cktsetup;
|
|
|
|
|
This is needed to setup vector mamory allocation for vectors and branch nodes
|
|
|
|
|
|
|
|
|
|
load_binary_data(info);
|
|
|
|
|
Overwrite the allocated numbers, rhs etc, with saved data
|
|
|
|
|
*/
|
2003-07-23 21:36:39 +02:00
|
|
|
|
|
|
|
|
|
2012-11-03 16:24:01 +01:00
|
|
|
if (ft_curckt && !strstr(ft_curckt->ci_name, "script")) {
|
|
|
|
|
/* Circuit, not a script */
|
2011-09-18 11:03:55 +02:00
|
|
|
fprintf(cp_err, "Error: there is already a circuit loaded.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* source the circuit */
|
|
|
|
|
inp_source(wl->wl_word);
|
2012-08-14 20:38:25 +02:00
|
|
|
if (!ft_curckt)
|
2011-09-18 11:03:55 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* allocate all the vectors, with luck! */
|
|
|
|
|
if (!error)
|
|
|
|
|
error = CKTsetup(ft_curckt->ci_ckt);
|
|
|
|
|
if (!error)
|
|
|
|
|
error = CKTtemp(ft_curckt->ci_ckt);
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
if (error) {
|
|
|
|
|
fprintf(cp_err, "Some error in the CKT setup fncts!\n");
|
2011-09-18 11:03:55 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* so it resumes ... */
|
|
|
|
|
ft_curckt->ci_inprogress = TRUE;
|
|
|
|
|
|
|
|
|
|
/* now load the binary file */
|
|
|
|
|
ckt = ft_curckt->ci_ckt;
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
file = fopen(wl->wl_next->wl_word, "rb");
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
if (!file) {
|
2012-09-20 20:30:53 +02:00
|
|
|
fprintf(cp_err, "Error: Couldn't open \"%s\" for reading\n", wl->wl_next->wl_word);
|
2011-09-18 11:03:55 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
fread(&tmpI, sizeof(int), 1, file);
|
2012-09-20 20:30:53 +02:00
|
|
|
if (tmpI != sizeof(CKTcircuit)) {
|
2012-08-12 20:28:42 +02:00
|
|
|
fprintf(cp_err, "loaded num: %d, expected num: %ld\n", tmpI, (long)sizeof(CKTcircuit));
|
2012-09-20 20:30:53 +02:00
|
|
|
fprintf(cp_err, "Error: snapshot saved with different version of spice\n");
|
2011-09-18 11:03:55 +02:00
|
|
|
fclose(file);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my_ckt = TMALLOC(CKTcircuit, 1);
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
fread(my_ckt, sizeof(CKTcircuit), 1, file);
|
2003-07-23 21:36:39 +02:00
|
|
|
|
|
|
|
|
#define _t(name) ckt->name = my_ckt->name
|
2012-08-12 20:28:42 +02:00
|
|
|
#define _ta(name, size) \
|
|
|
|
|
do { int __i; for (__i = 0; __i < size; __i++) _t(name[__i]); } while(0)
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
_t(CKTtime);
|
|
|
|
|
_t(CKTdelta);
|
2012-08-12 20:28:42 +02:00
|
|
|
_ta(CKTdeltaOld, 7);
|
2011-09-18 11:03:55 +02:00
|
|
|
_t(CKTtemp);
|
|
|
|
|
_t(CKTnomTemp);
|
|
|
|
|
_t(CKTvt);
|
2012-08-12 20:28:42 +02:00
|
|
|
_ta(CKTag, 7);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
_t(CKTorder);
|
|
|
|
|
_t(CKTmaxOrder);
|
|
|
|
|
_t(CKTintegrateMethod);
|
|
|
|
|
|
|
|
|
|
_t(CKTniState);
|
|
|
|
|
|
|
|
|
|
_t(CKTmaxEqNum);
|
|
|
|
|
_t(CKTcurrentAnalysis);
|
|
|
|
|
|
|
|
|
|
_t(CKTnumStates);
|
|
|
|
|
_t(CKTmode);
|
|
|
|
|
|
|
|
|
|
_t(CKTbypass);
|
|
|
|
|
_t(CKTdcMaxIter);
|
|
|
|
|
_t(CKTdcTrcvMaxIter);
|
|
|
|
|
_t(CKTtranMaxIter);
|
|
|
|
|
_t(CKTbreakSize);
|
|
|
|
|
_t(CKTbreak);
|
|
|
|
|
_t(CKTsaveDelta);
|
|
|
|
|
_t(CKTminBreak);
|
|
|
|
|
_t(CKTabstol);
|
|
|
|
|
_t(CKTpivotAbsTol);
|
|
|
|
|
_t(CKTpivotRelTol);
|
|
|
|
|
_t(CKTreltol);
|
|
|
|
|
_t(CKTchgtol);
|
|
|
|
|
_t(CKTvoltTol);
|
|
|
|
|
|
|
|
|
|
_t(CKTgmin);
|
|
|
|
|
_t(CKTgshunt);
|
|
|
|
|
_t(CKTdelmin);
|
|
|
|
|
_t(CKTtrtol);
|
|
|
|
|
_t(CKTfinalTime);
|
|
|
|
|
_t(CKTstep);
|
|
|
|
|
_t(CKTmaxStep);
|
|
|
|
|
_t(CKTinitTime);
|
|
|
|
|
_t(CKTomega);
|
|
|
|
|
_t(CKTsrcFact);
|
|
|
|
|
_t(CKTdiagGmin);
|
|
|
|
|
_t(CKTnumSrcSteps);
|
|
|
|
|
_t(CKTnumGminSteps);
|
|
|
|
|
_t(CKTgminFactor);
|
|
|
|
|
_t(CKTnoncon);
|
|
|
|
|
_t(CKTdefaultMosM);
|
|
|
|
|
_t(CKTdefaultMosL);
|
|
|
|
|
_t(CKTdefaultMosW);
|
|
|
|
|
_t(CKTdefaultMosAD);
|
|
|
|
|
_t(CKTdefaultMosAS);
|
|
|
|
|
_t(CKThadNodeset);
|
|
|
|
|
_t(CKTfixLimit);
|
|
|
|
|
_t(CKTnoOpIter);
|
|
|
|
|
_t(CKTisSetup);
|
2012-04-08 11:00:49 +02:00
|
|
|
#ifdef XSPICE
|
|
|
|
|
_t(CKTadevFlag);
|
|
|
|
|
#endif
|
2011-09-18 11:03:55 +02:00
|
|
|
_t(CKTtimeListSize);
|
|
|
|
|
_t(CKTtimeIndex);
|
|
|
|
|
_t(CKTsizeIncr);
|
|
|
|
|
|
|
|
|
|
_t(CKTtryToCompact);
|
|
|
|
|
_t(CKTbadMos3);
|
|
|
|
|
_t(CKTkeepOpInfo);
|
|
|
|
|
_t(CKTcopyNodesets);
|
|
|
|
|
_t(CKTnodeDamping);
|
|
|
|
|
_t(CKTabsDv);
|
|
|
|
|
_t(CKTrelDv);
|
|
|
|
|
_t(CKTtroubleNode);
|
|
|
|
|
|
2003-07-23 21:36:39 +02:00
|
|
|
#undef _foo
|
2012-08-12 20:28:42 +02:00
|
|
|
#define _foo(name, type, _size) \
|
|
|
|
|
do { \
|
|
|
|
|
int __i; \
|
|
|
|
|
fread(&__i, sizeof(int), 1, file); \
|
|
|
|
|
if (__i) { \
|
|
|
|
|
if (name) \
|
|
|
|
|
tfree(name); \
|
|
|
|
|
name = (type *)tmalloc((size_t) __i); \
|
|
|
|
|
fread(name, 1, (size_t) __i, file); \
|
|
|
|
|
} else { \
|
|
|
|
|
fprintf(cp_err, "size for vector " #name " is 0\n"); \
|
|
|
|
|
} \
|
|
|
|
|
if ((_size) != -1 && __i != (_size) * (int)sizeof(type)) { \
|
|
|
|
|
fprintf(cp_err, "expected %ld, but got %d for "#name"\n", (_size)*(long)sizeof(type), __i); \
|
|
|
|
|
} \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
2012-08-14 20:38:25 +02:00
|
|
|
for (i = 0; i <= ckt->CKTmaxOrder+1; i++)
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt->CKTstates[i], double, ckt->CKTnumStates);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2003-07-23 21:36:39 +02:00
|
|
|
size = SMPmatSize(ckt->CKTmatrix) + 1;
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt->CKTrhs, double, size);
|
|
|
|
|
_foo(ckt->CKTrhsOld, double, size);
|
|
|
|
|
_foo(ckt->CKTrhsSpare, double, size);
|
|
|
|
|
_foo(ckt->CKTirhs, double, size);
|
|
|
|
|
_foo(ckt->CKTirhsOld, double, size);
|
|
|
|
|
_foo(ckt->CKTirhsSpare, double, size);
|
|
|
|
|
// _foo(ckt->CKTrhsOp, double, size);
|
|
|
|
|
// _foo(ckt->CKTsenRhs, double, size);
|
|
|
|
|
// _foo(ckt->CKTseniRhs, double, size);
|
|
|
|
|
|
|
|
|
|
// _foo(ckt->CKTtimePoints, double, -1);
|
|
|
|
|
// _foo(ckt->CKTdeltaList, double, -1);
|
|
|
|
|
|
|
|
|
|
_foo(ckt->CKTbreaks, double, ckt->CKTbreakSize);
|
|
|
|
|
|
|
|
|
|
{ /* avoid invalid lvalue assignment errors in the macro _foo() */
|
2012-11-03 16:24:01 +01:00
|
|
|
TSKtask *lname = NULL;
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(lname, TSKtask, 1);
|
2012-11-03 16:24:01 +01:00
|
|
|
ft_curckt->ci_curTask = lname;
|
2007-12-15 16:11:12 +01:00
|
|
|
}
|
2003-07-23 21:36:39 +02:00
|
|
|
|
|
|
|
|
/* To stop the Free */
|
2010-10-08 18:46:06 +02:00
|
|
|
ft_curckt->ci_curTask->TSKname = NULL;
|
|
|
|
|
ft_curckt->ci_curTask->jobs = NULL;
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2010-10-08 18:46:06 +02:00
|
|
|
_foo(ft_curckt->ci_curTask->TSKname, char, -1);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2012-11-03 16:24:01 +01:00
|
|
|
{
|
|
|
|
|
TRANan *lname = NULL;
|
|
|
|
|
_foo(lname, TRANan, -1);
|
|
|
|
|
ft_curckt->ci_curTask->jobs = (JOB *)lname;
|
2007-12-15 16:11:12 +01:00
|
|
|
}
|
2010-10-08 18:46:06 +02:00
|
|
|
ft_curckt->ci_curTask->jobs->JOBname = NULL;
|
|
|
|
|
_foo(ft_curckt->ci_curTask->jobs->JOBname, char, -1);
|
|
|
|
|
ft_curckt->ci_curTask->jobs->JOBnextJob = NULL;
|
2012-11-03 16:24:01 +01:00
|
|
|
ckt->CKTcurJob = ft_curckt->ci_curTask->jobs;
|
2010-10-08 18:46:06 +02:00
|
|
|
((TRANan *)ft_curckt->ci_curTask->jobs)->TRANplot = NULL;
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt->CKTstat, STATistics, 1);
|
2012-04-08 11:00:49 +02:00
|
|
|
ckt->CKTstat->STATdevNum = NULL;
|
2012-11-03 16:24:01 +01:00
|
|
|
_foo(ckt->CKTstat->STATdevNum, STATdevList, -1);
|
2012-02-19 11:23:56 +01:00
|
|
|
|
|
|
|
|
#ifdef XSPICE
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt->evt, Evt_Ckt_Data_t, 1);
|
|
|
|
|
_foo(ckt->enh, Enh_Ckt_Data_t, 1);
|
2012-02-19 11:23:56 +01:00
|
|
|
g_mif_info.breakpoint.current = ckt->enh->breakpoint.current;
|
|
|
|
|
g_mif_info.breakpoint.last = ckt->enh->breakpoint.last;
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-07-23 21:36:39 +02:00
|
|
|
tfree(my_ckt);
|
|
|
|
|
fclose(file);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2003-07-23 21:36:39 +02:00
|
|
|
/* Finally to resume the plot in some fashion */
|
|
|
|
|
|
|
|
|
|
/* a worked out version of this should be enough */
|
|
|
|
|
{
|
2011-09-18 11:03:55 +02:00
|
|
|
IFuid *nameList;
|
|
|
|
|
int numNames;
|
|
|
|
|
IFuid timeUid;
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
error = CKTnames(ckt, &numNames, &nameList);
|
|
|
|
|
if (error) {
|
|
|
|
|
fprintf(cp_err, "error in CKTnames\n");
|
2011-09-18 11:03:55 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2012-08-14 20:38:25 +02:00
|
|
|
SPfrontEnd->IFnewUid (ckt, &timeUid, NULL, "time", UID_OTHER, NULL);
|
2013-07-14 15:11:00 +02:00
|
|
|
error = SPfrontEnd->OUTpBeginPlot (ckt, ckt->CKTcurJob,
|
|
|
|
|
ckt->CKTcurJob->JOBname,
|
|
|
|
|
timeUid, IF_REAL,
|
|
|
|
|
numNames, nameList, IF_REAL,
|
|
|
|
|
&(((TRANan*)ckt->CKTcurJob)->TRANplot));
|
2012-08-12 20:28:42 +02:00
|
|
|
if (error) {
|
|
|
|
|
fprintf(cp_err, "error in CKTnames\n");
|
2011-09-18 11:03:55 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2003-07-23 21:36:39 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
|
2012-11-01 14:41:13 +01:00
|
|
|
void com_snsave(wordlist *wl)
|
2011-09-18 11:03:55 +02:00
|
|
|
{
|
|
|
|
|
FILE *file;
|
|
|
|
|
int i, size;
|
|
|
|
|
CKTcircuit *ckt;
|
|
|
|
|
TSKtask *task;
|
|
|
|
|
|
|
|
|
|
if (!ft_curckt) {
|
|
|
|
|
fprintf(cp_err, "Error: there is no circuit loaded.\n");
|
|
|
|
|
return;
|
2012-08-14 20:38:25 +02:00
|
|
|
} else if (!ft_curckt->ci_ckt) { /* Set noparse? */
|
2011-09-18 11:03:55 +02:00
|
|
|
fprintf(cp_err, "Error: circuit not parsed.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
/* save the data */
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
ckt = ft_curckt->ci_ckt;
|
|
|
|
|
|
2012-04-08 11:00:49 +02:00
|
|
|
#ifdef XSPICE
|
|
|
|
|
if (ckt->CKTadevFlag == 1) {
|
2012-11-01 14:41:13 +01:00
|
|
|
fprintf(cp_err, "Warning: snsave not implemented for XSPICE A devices.\n");
|
|
|
|
|
fprintf(cp_err, " Command 'snsave' will be ingnored!\n");
|
2012-04-08 11:00:49 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-09-18 11:03:55 +02:00
|
|
|
task = ft_curckt->ci_curTask;
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
if (task->jobs->JOBtype != 4) {
|
|
|
|
|
fprintf(cp_err, "Only saving of tran analysis is implemented\n");
|
2011-09-18 11:03:55 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
file = fopen(wl->wl_word, "wb");
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
if (!file) {
|
2011-09-18 11:03:55 +02:00
|
|
|
fprintf(cp_err,
|
2012-08-12 20:28:42 +02:00
|
|
|
"Error: Couldn't open \"%s\" for writing\n", wl->wl_word);
|
2011-09-18 11:03:55 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2003-07-23 21:36:39 +02:00
|
|
|
|
|
|
|
|
#undef _foo
|
2012-08-12 20:28:42 +02:00
|
|
|
#define _foo(name, type, num) \
|
|
|
|
|
do { \
|
|
|
|
|
int __i; \
|
|
|
|
|
if (name) { \
|
|
|
|
|
__i = (num) * (int)sizeof(type); fwrite(&__i, sizeof(int), 1, file); \
|
|
|
|
|
if ((num)) \
|
|
|
|
|
fwrite(name, sizeof(type), (size_t)(num), file); \
|
|
|
|
|
} else { \
|
|
|
|
|
__i = 0; \
|
|
|
|
|
fprintf(cp_err, #name " is NULL, zero written\n"); \
|
|
|
|
|
fwrite(&__i, sizeof(int), 1, file); \
|
|
|
|
|
} \
|
2003-07-23 21:36:39 +02:00
|
|
|
} while(0)
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt, CKTcircuit, 1);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* To save list
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
double *(CKTstates[8]);
|
|
|
|
|
double *CKTrhs;
|
|
|
|
|
double *CKTrhsOld;
|
|
|
|
|
double *CKTrhsSpare;
|
|
|
|
|
double *CKTirhs;
|
|
|
|
|
double *CKTirhsOld;
|
|
|
|
|
double *CKTirhsSpare;
|
|
|
|
|
double *CKTrhsOp;
|
|
|
|
|
double *CKTsenRhs;
|
|
|
|
|
double *CKTseniRhs;
|
|
|
|
|
double *CKTtimePoints; list of all accepted timepoints in
|
|
|
|
|
the current transient simulation
|
|
|
|
|
double *CKTdeltaList; list of all timesteps in the
|
|
|
|
|
current transient simulation
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2012-08-14 20:38:25 +02:00
|
|
|
for (i = 0; i <= ckt->CKTmaxOrder+1; i++)
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt->CKTstates[i], double, ckt->CKTnumStates);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
size = SMPmatSize(ckt->CKTmatrix) + 1;
|
|
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt->CKTrhs, double, size);
|
|
|
|
|
_foo(ckt->CKTrhsOld, double, size);
|
|
|
|
|
_foo(ckt->CKTrhsSpare, double, size);
|
|
|
|
|
_foo(ckt->CKTirhs, double, size);
|
|
|
|
|
_foo(ckt->CKTirhsOld, double, size);
|
|
|
|
|
_foo(ckt->CKTirhsSpare, double, size);
|
|
|
|
|
// _foo(ckt->CKTrhsOp, double, size);
|
|
|
|
|
// _foo(ckt->CKTsenRhs, double, size);
|
|
|
|
|
// _foo(ckt->CKTseniRhs, double, size);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
2012-08-12 20:28:42 +02:00
|
|
|
// _foo(ckt->CKTtimePoints, double, ckt->CKTtimeListSize);
|
|
|
|
|
// _foo(ckt->CKTdeltaList, double, ckt->CKTtimeListSize);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* need to save the breakpoints, or something */
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt->CKTbreaks, double, ckt->CKTbreakSize);
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* now save the TSK struct, ft_curckt->ci_curTask*/
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(task, TSKtask, 1);
|
|
|
|
|
_foo(task->TSKname, char, ((int)strlen(task->TSKname)+1));
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* now save the JOB struct task->jobs */
|
|
|
|
|
/* lol, only allow one job, tough! */
|
|
|
|
|
/* Note that JOB is a base class, need to save actual type!! */
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(task->jobs, TRANan, 1);
|
|
|
|
|
_foo(task->jobs->JOBname, char, ((int)strlen(task->jobs->JOBname)+1));
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
/* Finally the stats */
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt->CKTstat, STATistics, 1);
|
2012-11-03 16:24:01 +01:00
|
|
|
_foo(ckt->CKTstat->STATdevNum, STATdevList, 1);
|
2012-04-08 11:00:49 +02:00
|
|
|
|
2012-02-19 11:23:56 +01:00
|
|
|
#ifdef XSPICE
|
2012-08-12 20:28:42 +02:00
|
|
|
/* FIXME struct ckt->evt->data and others are not stored
|
2012-11-01 14:41:13 +01:00
|
|
|
thus snsave, snload not compatible with XSPICE code models*/
|
2012-08-12 20:28:42 +02:00
|
|
|
_foo(ckt->evt, Evt_Ckt_Data_t, 1);
|
|
|
|
|
_foo(ckt->enh, Enh_Ckt_Data_t, 1);
|
2012-02-19 11:23:56 +01:00
|
|
|
#endif
|
2011-09-18 11:03:55 +02:00
|
|
|
|
|
|
|
|
fclose(file);
|
2012-11-01 14:41:13 +01:00
|
|
|
fprintf(stdout, "Snapshot saved to %s.\n", wl->wl_word);
|
2003-07-23 21:36:39 +02:00
|
|
|
}
|
2013-07-27 20:34:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ft_find_analysis(char *name)
|
|
|
|
|
{
|
|
|
|
|
int j;
|
|
|
|
|
for (j = 0; j < ft_sim->numAnalyses; j++)
|
|
|
|
|
if (strcmp(ft_sim->analyses[j]->name, name) == 0)
|
|
|
|
|
return j;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|