Add a command 'degsim' to reset the circuit, remove the monitors,

and add the degradation model to each degraded device.
Use function preparedegsim() to add the model with parameters from
degdatahash.
This commit is contained in:
Holger Vogt 2026-02-08 15:47:04 +01:00
parent 6a0b8b16ce
commit 44fd33ea7d
6 changed files with 52 additions and 2 deletions

View File

@ -32,6 +32,8 @@ pre_osdi ../lib/ngspice/psp103_nqs.osdi
pre_osdi ../lib/ngspice/psp103.osdi
run
rusage
degsim
run
*set nolegend
set xbrushwidth=3
plot xnot1.mon1 xnot2.mon1 xnot3.mon1

View File

@ -448,7 +448,11 @@ struct comm spcp_coms[] = {
{ "reset", com_rset, TRUE, TRUE,
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, 0,
NULL,
": Terminate a simulation after a breakpoint (formerly 'end')." } ,
": Remove current ciuit, reload circuit from internal storage." } ,
{ "degsim", com_degsim, TRUE, TRUE,
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, 0,
NULL,
": Remove current circuit, reload and modify circuit." } ,
{ "run", com_run, TRUE, TRUE,
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, 1,
NULL,

View File

@ -64,6 +64,8 @@ static void rem_unused_mos_models(struct card* deck);
extern void com_optran(wordlist * wl);
extern void tprint(struct card *deck);
static bool wantdegsim = FALSE;
extern int preparedegsim(struct card* deck);
//void inp_source_recent(void);
//void inp_mc_free(void);
@ -1091,7 +1093,15 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
if (newcompat.hs || newcompat.spe)
rem_unused_mos_models(deck->nextcard);
#endif
/* Parsing the circuit 5.
/* If compatmode is de and degsim is set by command 'degsim',
translate the netlist by removing the monitors and adding the
extra degradation elements. */
if (wantdegsim && newcompat.de) {
wantdegsim = FALSE;
preparedegsim(deck);
}
/* Parsing the circuit 5.
This is the next major step:
load deck into ft_curckt -- the current circuit. */
if(inp_dodeck(deck, tt, wl_first, FALSE, options, filename) != 0)
@ -2679,6 +2689,10 @@ struct mlist {
bool checked;
};
void setdegsim(void) {
wantdegsim = TRUE;
}
#ifdef REM_UNUSED
/* Finally get rid of unused MOS models */
static void rem_unused_mos_models(struct card* deck) {

View File

@ -15,6 +15,8 @@ License: Modified BSD
#include "inpcom.h"
int preparedegsim(struct card* deck);
/* maximum number of model parameters */
#define DEGPARAMAX 64
/* maximum number of models */
@ -296,3 +298,11 @@ int remsqrbra(struct card* deck) {
}
return 0;
}
/* Remove the degradation monitors.
Add current measurement, delta_vg and current source.
Use the data retrieved from degdatahash */
int preparedegsim(struct card* deck) {
fprintf(stdout, "Note: degradation simulation prepared.\n");
return 0;
}

View File

@ -36,6 +36,8 @@ extern void line_free_x(struct card *deck, bool recurse);
extern INPmodel *modtab;
extern NGHASHPTR modtabhash;
extern void setdegsim(void);
#ifdef SHARED_MODULE
extern void exec_controls(wordlist *newcontrols);
#endif
@ -169,6 +171,23 @@ com_resume(wordlist *wl)
}
/* Throw out the circuit struct and recreate it from the deck. */
void
com_degsim(wordlist* wl)
{
NG_IGNORE(wl);
if (ft_curckt == NULL) {
fprintf(cp_err, "Warning: there is no circuit loaded.\n");
fprintf(cp_err, " Command 'reset' is ignored.\n");
return;
}
com_remcirc(NULL);
setdegsim();
inp_source_recent();
}
/* Throw out the circuit struct and recreate it from the deck. */
void
com_rset(wordlist *wl)

View File

@ -9,5 +9,6 @@
void com_resume(wordlist *wl);
void com_rset(wordlist *wl);
void com_remcirc(wordlist *wl);
void com_degsim(wordlist* wl);
#endif