Code model:
Put the monitored degradation data onto the heap and into the hash table. prepare_degsim(): Re-read the netlist, remove the monitors, get the device instance name. Retrieve the degradation data from the result hash table.
This commit is contained in:
parent
44fd33ea7d
commit
2b21666a4d
|
|
@ -32,11 +32,12 @@ pre_osdi ../lib/ngspice/psp103_nqs.osdi
|
|||
pre_osdi ../lib/ngspice/psp103.osdi
|
||||
run
|
||||
rusage
|
||||
plot xnot1.mon1 xnot2.mon1 xnot3.mon1
|
||||
plot in out+2
|
||||
degsim
|
||||
run
|
||||
*set nolegend
|
||||
set xbrushwidth=3
|
||||
plot xnot1.mon1 xnot2.mon1 xnot3.mon1
|
||||
plot in out+2
|
||||
.endc
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ extern void com_optran(wordlist * wl);
|
|||
extern void tprint(struct card *deck);
|
||||
|
||||
static bool wantdegsim = FALSE;
|
||||
extern int preparedegsim(struct card* deck);
|
||||
extern int prepare_degsim(struct card* deck);
|
||||
|
||||
//void inp_source_recent(void);
|
||||
//void inp_mc_free(void);
|
||||
|
|
@ -1098,7 +1098,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
|
|||
extra degradation elements. */
|
||||
if (wantdegsim && newcompat.de) {
|
||||
wantdegsim = FALSE;
|
||||
preparedegsim(deck);
|
||||
prepare_degsim(deck);
|
||||
}
|
||||
|
||||
/* Parsing the circuit 5.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ License: Modified BSD
|
|||
|
||||
#include "inpcom.h"
|
||||
|
||||
int preparedegsim(struct card* deck);
|
||||
int prepare_degsim(struct card* deck);
|
||||
|
||||
/* maximum number of model parameters */
|
||||
#define DEGPARAMAX 64
|
||||
|
|
@ -302,7 +302,53 @@ int remsqrbra(struct card* deck) {
|
|||
/* Remove the degradation monitors.
|
||||
Add current measurement, delta_vg and current source.
|
||||
Use the data retrieved from degdatahash */
|
||||
int preparedegsim(struct card* deck) {
|
||||
int prepare_degsim(struct card* deck) {
|
||||
struct card* prevcard = deck, *ldeck;
|
||||
|
||||
if (!deck)
|
||||
return 1;
|
||||
|
||||
/* skip the title line */
|
||||
for (ldeck = deck->nextcard; ldeck; ldeck = ldeck->nextcard) {
|
||||
char* line = ldeck->line;
|
||||
|
||||
if (*line == '*') {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* remove the remnants of the first run */
|
||||
if (ciprefix(".model", line) && search_plain_identifier(line, "degmon")) {
|
||||
double *result;
|
||||
char* insttoken;
|
||||
struct card* nextdeck = ldeck->nextcard;
|
||||
char* prevline = prevcard->line;
|
||||
if (nextdeck) {
|
||||
char* nextline = nextdeck->line;
|
||||
if (*nextline == 'a' && strstr(nextline, "degmon")) {
|
||||
*nextline = '*';
|
||||
}
|
||||
}
|
||||
/* get the device instance line */
|
||||
insttoken = gettok_instance(&prevline);
|
||||
result = (double*)nghash_find(degdatahash, insttoken);
|
||||
if (result) {
|
||||
fprintf(stdout, "Instance %s, Result: %e, %e, %e\n", insttoken, result[0], result[1], result[2]);
|
||||
}
|
||||
else
|
||||
fprintf(stdout, "Instance %s not found in hash table\n", insttoken);
|
||||
|
||||
tfree(insttoken);
|
||||
|
||||
*line = '*';
|
||||
}
|
||||
prevcard = ldeck;
|
||||
}
|
||||
fprintf(stdout, "Note: degradation simulation prepared.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* clear memory */
|
||||
int clear_degsim (void){
|
||||
/* delete the hashtables */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ typedef struct {
|
|||
double L2[3]; /* degradation model parameter */
|
||||
double n[3]; /* degradation model parameter */
|
||||
double c[3]; /* degradation model parameter */
|
||||
double result[3]; /* degradation simulation result */
|
||||
double *result; /* degradation simulation result */
|
||||
char *parentname; /* name of parent device for degmon */
|
||||
} degLocal_Data_t;
|
||||
|
||||
|
|
@ -110,7 +110,8 @@ cm_degmon_callback(ARGS, Mif_Callback_Reason_t reason)
|
|||
if (loc == (degLocal_Data_t *) NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* loc->result) should not be freed here, as is used in the second run.
|
||||
Free it via the hash table.*/
|
||||
free(loc);
|
||||
|
||||
STATIC_VAR(locdata) = NULL;
|
||||
|
|
@ -343,6 +344,9 @@ void cm_degmon(ARGS) /* structure holding parms,
|
|||
cm_cexit(1);
|
||||
}
|
||||
|
||||
double *result = (double*)malloc(3 * sizeof(double));
|
||||
loc->result = result;
|
||||
|
||||
/* use agemods as input to set the agemodel model parameters,
|
||||
e.g. loc->A[3] */
|
||||
err = getdata(agemods, loc, devmod);
|
||||
|
|
@ -466,6 +470,8 @@ void cm_degmon(ARGS) /* structure holding parms,
|
|||
/* save the degradation data for this instance */
|
||||
if (T(0) > 0.99999 * tsim) {
|
||||
nghash_insert(glohash, loc->parentname, loc->result);
|
||||
cm_message_printf("instance %s, data: %e %e %e\n", loc->parentname, loc->result[0],
|
||||
loc->result[1], loc->result[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue