Enable command 'optran' in spinit or .spiceinit,

when the circuit is not yet loaded.
Then the optran data are stored in static variables,
until optran is called again with arg NULL from inp.c,
to set the data in ft_curckt->ci_defTask.
This commit is contained in:
Holger Vogt 2021-08-24 15:53:31 +02:00
parent a225ce2aaf
commit f06496c912
2 changed files with 66 additions and 9 deletions

View File

@ -66,6 +66,7 @@ static void recifeval(struct card *pdeck);
static char *upper(register char *string); static char *upper(register char *string);
static void rem_unused_mos_models(struct card* deck); static void rem_unused_mos_models(struct card* deck);
extern void com_optran(wordlist * wl);
//void inp_source_recent(void); //void inp_source_recent(void);
@ -1347,6 +1348,10 @@ inp_dodeck(
#endif #endif
ct->ci_filename = copy(filename); ct->ci_filename = copy(filename);
/* load the optran data, if provided by .spiceinit or spinit.
Return immediately, if optran is not selected.*/
com_optran(NULL);
if (!noparse) { if (!noparse) {
/* /*
* for (; options; options = options->nextcard) { * for (; options; options = options->nextcard) {

View File

@ -58,36 +58,87 @@ static bool nooptran = TRUE;
A typical command may be A typical command may be
optran 0 0 0 50u 10m 0 optran 0 0 0 50u 10m 0
(no initial iteration, no gmin stepping, no source stepping, (no initial iteration, no gmin stepping, no source stepping,
stepsize for optran 50 us, optran run until 10 ms, no supply ramping stepsize for optran 50 us, optran run until 10 ms, no supply ramping.
If com_optran is given in .spiceinit, the circuit is not yet loaded. So
we firstly fill the static vars opstepsize, opfinaltime,
and opramptime. Later from inp.c we call com_optran again and set the
data in ft_curckt->ci_defTask.
*/ */
void com_optran(wordlist* wl) { void com_optran(wordlist* wl) {
wordlist* wltmp = wl; wordlist* wltmp = wl;
char* stpstr; char* stpstr;
int err, optrancom; int err, optrancom;
static bool dataset = FALSE;
static bool getdata = FALSE;
static int opiter = 1;
static int ngminsteps = 1;
static int nsrcsteps = 1;
/* current circuit */ /* current circuit */
if (!ft_curckt) { if (ft_curckt && dataset && wl == NULL) { /* called from inp.c */
fprintf(cp_err, "Error: no circuit loaded\n"); ft_curckt->ci_defTask->TSKnoOpIter = opiter;
ft_curckt->ci_defTask->TSKnumGminSteps = ngminsteps;
ft_curckt->ci_defTask->TSKnumSrcSteps = nsrcsteps;
getdata = FALSE; /* allow more calls to 'optran' */
return; return;
} }
else if (!ft_curckt && !dataset && wl == NULL) {
fprintf(stderr, "Error: syntax error with command 'optran'!\n");
fprintf(stderr, " Command ingnored\n");
return;
}
else if (ft_curckt && !dataset && wl == NULL) {
/* no optran wanted */
return;
}
else if (!ft_curckt && !dataset) { /* called from .spiceinit */
getdata = TRUE;
}
nooptran = FALSE; nooptran = FALSE;
/* wordlist with 6 parameters */ /* wordlist with 6 parameters */
optrancom = strtol(wltmp->wl_word, &stpstr, 10); optrancom = strtol(wltmp->wl_word, &stpstr, 10);
if ((errno == ERANGE) || (*stpstr != '\0')) if ((errno == ERANGE) || (*stpstr != '\0'))
goto bugquit; goto bugquit;
if (optrancom == 0) if (optrancom == 0) {
ft_curckt->ci_defTask->TSKnoOpIter = 1; if (getdata) {
else opiter = 1;
ft_curckt->ci_defTask->TSKnoOpIter = 0; }
else {
ft_curckt->ci_defTask->TSKnoOpIter = 1;
}
}
else {
if (getdata) {
opiter = 0;
}
else {
ft_curckt->ci_defTask->TSKnoOpIter = 0;
}
}
wltmp = wltmp->wl_next; wltmp = wltmp->wl_next;
optrancom = strtol(wltmp->wl_word, &stpstr, 10); optrancom = strtol(wltmp->wl_word, &stpstr, 10);
if ((errno == ERANGE) || (*stpstr != '\0')) if ((errno == ERANGE) || (*stpstr != '\0'))
goto bugquit; goto bugquit;
ft_curckt->ci_defTask->TSKnumGminSteps = optrancom; if (getdata) {
ngminsteps = optrancom;
}
else {
ft_curckt->ci_defTask->TSKnumGminSteps = optrancom;
}
wltmp = wltmp->wl_next; wltmp = wltmp->wl_next;
optrancom = strtol(wltmp->wl_word, &stpstr, 10); optrancom = strtol(wltmp->wl_word, &stpstr, 10);
if ((errno == ERANGE) || (*stpstr != '\0')) if ((errno == ERANGE) || (*stpstr != '\0'))
goto bugquit; goto bugquit;
ft_curckt->ci_defTask->TSKnumSrcSteps = optrancom; if (getdata) {
nsrcsteps = optrancom;
}
else {
ft_curckt->ci_defTask->TSKnumSrcSteps = optrancom;
}
wltmp = wltmp->wl_next; wltmp = wltmp->wl_next;
stpstr = wltmp->wl_word; stpstr = wltmp->wl_word;
opstepsize = INPevaluate(&stpstr, &err, 1); opstepsize = INPevaluate(&stpstr, &err, 1);
@ -114,6 +165,7 @@ void com_optran(wordlist* wl) {
fprintf(stderr, "Error: Ramp time larger than final time.\n"); fprintf(stderr, "Error: Ramp time larger than final time.\n");
goto bugquit; goto bugquit;
} }
dataset = TRUE;
return; return;
bugquit: bugquit:
fprintf(stderr, "Error in command 'optran'\n"); fprintf(stderr, "Error in command 'optran'\n");