store deck for command mc_source for each circuit in ft_curckt->ci_mcdeck
remove this storage during remcirc keep most recent deck in recent_deck
This commit is contained in:
parent
9475daf9d2
commit
d1a8637a29
|
|
@ -53,6 +53,7 @@ static char *upper(register char *string);
|
|||
static bool doedit(char *filename);
|
||||
static struct card *com_options = NULL;
|
||||
static struct card *mc_deck = NULL;
|
||||
static struct card *recent_deck = NULL;
|
||||
static void cktislinear(CKTcircuit *ckt, struct card *deck);
|
||||
static void dotifeval(struct card *deck);
|
||||
|
||||
|
|
@ -61,6 +62,10 @@ static wordlist *inp_savecurrents(struct card *deck, struct card *options, wordl
|
|||
static void eval_agauss(struct card *deck, char *fcn);
|
||||
void line_free_x(struct card *deck, bool recurse);
|
||||
void create_circbyline(char *line);
|
||||
void inp_source_recent(void);
|
||||
void inp_mc_free(void);
|
||||
void inp_remove_recent(void);
|
||||
static bool mc_reload = FALSE;
|
||||
|
||||
extern bool ft_batchmode;
|
||||
|
||||
|
|
@ -331,13 +336,34 @@ line_reverse(struct card *head)
|
|||
}
|
||||
|
||||
|
||||
/* free mc_deck */
|
||||
/* store ft_curckt->ci_mcdeck into a 'previous' deck */
|
||||
void
|
||||
mc_free(void)
|
||||
inp_mc_free(void)
|
||||
{
|
||||
line_free(mc_deck, TRUE);
|
||||
if (ft_curckt && ft_curckt->ci_mcdeck) {
|
||||
if (recent_deck)
|
||||
line_free(recent_deck, TRUE);
|
||||
recent_deck = ft_curckt->ci_mcdeck;
|
||||
ft_curckt->ci_mcdeck = NULL;
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Error: No circuit loaded\n");
|
||||
}
|
||||
|
||||
/* called by com_rset: reload most recent circuit */
|
||||
void
|
||||
inp_source_recent(void) {
|
||||
mc_deck = recent_deck;
|
||||
mc_reload = TRUE;
|
||||
inp_spsource(NULL, FALSE, NULL, FALSE);
|
||||
}
|
||||
|
||||
/* remove the 'recent' deck */
|
||||
void
|
||||
inp_remove_recent(void) {
|
||||
if (recent_deck)
|
||||
line_free(recent_deck, TRUE);
|
||||
}
|
||||
|
||||
/* check for .option seed=[val|random] and set the random number generator */
|
||||
void
|
||||
|
|
@ -435,17 +461,25 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
|
|||
comfile = TRUE;
|
||||
/* save a copy of the deck for later reloading with 'mc_source' */
|
||||
if (deck && !comfile) {
|
||||
if (mc_deck)
|
||||
mc_free();
|
||||
/* stored to new circuit ci_mcdeck in fcn */
|
||||
mc_deck = inp_deckcopy_oc(deck);
|
||||
}
|
||||
}
|
||||
/* called with *fp == NULL and not intfile: we want to reload circuit from mc_deck */
|
||||
else {
|
||||
if (mc_deck) {
|
||||
deck = inp_deckcopy(mc_deck);
|
||||
/* re-load input deck from the current circuit structure */
|
||||
if (ft_curckt && ft_curckt->ci_mcdeck) {
|
||||
deck = inp_deckcopy(ft_curckt->ci_mcdeck);
|
||||
expr_w_temper = TRUE;
|
||||
}
|
||||
/* re-load deck due to command 'reset' via function inp_source_recent() */
|
||||
else if (mc_reload) {
|
||||
deck = inp_deckcopy(mc_deck);
|
||||
expr_w_temper = TRUE;
|
||||
mc_reload = FALSE;
|
||||
fprintf(stdout, "Reset re-loads circuit %s\n", mc_deck->line);
|
||||
}
|
||||
/* no circuit available, should not happen */
|
||||
else {
|
||||
fprintf(stderr, "Error: No circuit loaded, cannot copy internally using mc_source\n");
|
||||
controlled_exit(1);
|
||||
|
|
@ -1115,6 +1149,7 @@ inp_dodeck(
|
|||
}
|
||||
ct->ci_name = tt;
|
||||
ct->ci_deck = deck;
|
||||
ct->ci_mcdeck = mc_deck;
|
||||
ct->ci_options = options;
|
||||
if (deck->actualLine)
|
||||
ct->ci_origdeck = deck->actualLine;
|
||||
|
|
@ -1299,7 +1334,7 @@ com_alterparam(wordlist *wl)
|
|||
char *pname, *pval, *tmp, *subcktname = NULL, *linein, *linefree, *s;
|
||||
bool found = FALSE;
|
||||
|
||||
if (!mc_deck) {
|
||||
if (!ft_curckt->ci_mcdeck) {
|
||||
fprintf(cp_err, "Error: No internal deck available\n");
|
||||
return;
|
||||
}
|
||||
|
|
@ -1328,7 +1363,7 @@ com_alterparam(wordlist *wl)
|
|||
}
|
||||
tfree(linefree);
|
||||
tfree(s);
|
||||
for (dd = mc_deck->nextcard; dd; dd = dd->nextcard) {
|
||||
for (dd = ft_curckt->ci_mcdeck->nextcard; dd; dd = dd->nextcard) {
|
||||
char *curr_line = dd->line;
|
||||
/* alterparam subcktname pname=vpval
|
||||
Parameters from within subcircuit are no longer .param lines, but have been added to
|
||||
|
|
@ -1366,7 +1401,7 @@ com_alterparam(wordlist *wl)
|
|||
/* find x line with same subcircuit name */
|
||||
struct card *xx;
|
||||
char *bsubb = tprintf(" %s ", subcktname);
|
||||
for (xx = mc_deck->nextcard; xx; xx = xx->nextcard) {
|
||||
for (xx = ft_curckt->ci_mcdeck->nextcard; xx; xx = xx->nextcard) {
|
||||
char *xline = xx->line;
|
||||
if (*xline == 'x') {
|
||||
xline = strstr(xline, bsubb);
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ com_quit(wordlist *wl)
|
|||
return;
|
||||
|
||||
#ifndef SHARED_MODULE
|
||||
#if 0
|
||||
if (!ft_ngdebug && !ft_nutmeg) {
|
||||
/* Destroy CKT */
|
||||
struct circ *cc;
|
||||
|
|
@ -64,6 +65,9 @@ com_quit(wordlist *wl)
|
|||
if (SIMinfo.deleteCircuit)
|
||||
SIMinfo.deleteCircuit(cc->ci_ckt);
|
||||
}
|
||||
#endif
|
||||
while (ft_curckt)
|
||||
com_remcirc(NULL);
|
||||
exit(exitcode);
|
||||
#endif
|
||||
|
||||
|
|
@ -111,7 +115,7 @@ com_quit(wordlist *wl)
|
|||
destroy_const_plot();
|
||||
spice_destroy_devices();
|
||||
#endif
|
||||
mc_free();
|
||||
|
||||
#ifdef SHARED_MODULE
|
||||
/* add 1000 to notify that we exit from 'quit' */
|
||||
controlled_exit(1000 + exitcode);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ extern char rawfileBuf[RAWBUF_SIZE];
|
|||
extern void line_free_x(struct card *deck, bool recurse);
|
||||
extern INPmodel *modtab;
|
||||
|
||||
extern void com_mc_source(wordlist *wl);
|
||||
|
||||
#define line_free(line, flag) \
|
||||
do { \
|
||||
line_free_x(line, flag); \
|
||||
|
|
@ -171,10 +173,18 @@ com_resume(wordlist *wl)
|
|||
void
|
||||
com_rset(wordlist *wl)
|
||||
{
|
||||
struct variable *v, *next;
|
||||
|
||||
NG_IGNORE(wl);
|
||||
|
||||
#if (1)
|
||||
if (ft_curckt == NULL) {
|
||||
fprintf(cp_err, "Error: there is no circuit loaded.\n");
|
||||
return;
|
||||
}
|
||||
com_remcirc(NULL);
|
||||
inp_source_recent();
|
||||
#else
|
||||
struct variable *v, *next;
|
||||
|
||||
if (ft_curckt == NULL) {
|
||||
fprintf(cp_err, "Error: there is no circuit loaded.\n");
|
||||
return;
|
||||
|
|
@ -190,6 +200,7 @@ com_rset(wordlist *wl)
|
|||
|
||||
inp_dodeck(ft_curckt->ci_deck, ft_curckt->ci_name, NULL,
|
||||
TRUE, ft_curckt->ci_options, ft_curckt->ci_filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -262,6 +273,8 @@ com_remcirc(wordlist *wl)
|
|||
rem_tlist(ft_curckt->devtlist);
|
||||
rem_tlist(ft_curckt->modtlist);
|
||||
|
||||
inp_mc_free();
|
||||
|
||||
/* delete the actual circuit entry from ft_circuits */
|
||||
for (p = ft_circuits; p; p = p->ci_next) {
|
||||
if (ft_curckt == p) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ struct circ {
|
|||
struct dbcomm *ci_dbs; /* The database storing save, iplot, stop data */
|
||||
struct card *ci_deck; /* The input deck. */
|
||||
struct card *ci_origdeck; /* The input deck, before subckt expansion. */
|
||||
struct card *ci_mcdeck; /* The compacted input deck, used by mc_source */
|
||||
struct card *ci_options; /* The .option cards from the deck... */
|
||||
struct card *ci_meas; /* .measure commands to run after simulation */
|
||||
struct card *ci_param; /* .param statements found in deck */
|
||||
|
|
|
|||
|
|
@ -220,7 +220,9 @@ extern char *find_back_assignment(const char *s, const char *start);
|
|||
|
||||
extern struct card *line_nconc(struct card *head, struct card *rest);
|
||||
extern struct card *line_reverse(struct card *head);
|
||||
extern void mc_free(void);
|
||||
extern void inp_mc_free(void);
|
||||
extern void inp_source_recent(void);
|
||||
extern void inp_remove_recent(void);
|
||||
|
||||
extern char **circarray;
|
||||
extern void rem_tlist(struct pt_temper *p);
|
||||
|
|
|
|||
Loading…
Reference in New Issue