From f1e234aa49b9f4cacd7953e6d5d420dbccb69ae2 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 16 Aug 2025 09:24:45 +0200 Subject: [PATCH] Add two macros TSTEP and TSTOP to XSPICE --- src/include/ngspice/mifcmdat.h | 2 ++ src/xspice/cmpp/mod_lex.l | 2 ++ src/xspice/cmpp/mod_yacc.y | 6 ++++++ src/xspice/mif/mifload.c | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/src/include/ngspice/mifcmdat.h b/src/include/ngspice/mifcmdat.h index 00504f5a2..22e1e7bce 100644 --- a/src/include/ngspice/mifcmdat.h +++ b/src/include/ngspice/mifcmdat.h @@ -333,6 +333,8 @@ typedef struct Mif_Circ_Data_s { double frequency; /* Current analysis frequency */ double temperature; /* Current analysis temperature */ double t[8]; /* History of last 8 analysis times t[0]=time */ + double tstep; /* tran simulation tstep */ + double tstop; /* tran simulation tstop */ } Mif_Circ_Data_t; diff --git a/src/xspice/cmpp/mod_lex.l b/src/xspice/cmpp/mod_lex.l index fbb86eb5b..cfa9f5953 100644 --- a/src/xspice/cmpp/mod_lex.l +++ b/src/xspice/cmpp/mod_lex.l @@ -101,6 +101,8 @@ TIME {return TOK_TIME;} RAD_FREQ {return TOK_RAD_FREQ;} TEMPERATURE {return TOK_TEMPERATURE;} T {return TOK_T;} +TSTEP {return TOK_TSTEP;} +TSTOP {return TOK_TSTOP;} LOAD {return TOK_LOAD;} TOTAL_LOAD {return TOK_TOTAL_LOAD;} MESSAGE {return TOK_MESSAGE;} diff --git a/src/xspice/cmpp/mod_yacc.y b/src/xspice/cmpp/mod_yacc.y index 92433aca4..2ebaa0e22 100644 --- a/src/xspice/cmpp/mod_yacc.y +++ b/src/xspice/cmpp/mod_yacc.y @@ -337,6 +337,8 @@ static void append (char *str) %token TOK_RAD_FREQ %token TOK_TEMPERATURE %token TOK_T +%token TOK_TSTEP +%token TOK_TSTOP %token TOK_PARAM %token TOK_PARAM_SIZE %token TOK_PARAM_NULL @@ -435,6 +437,10 @@ macro : TOK_INIT {fprintf (mod_yyout, "mif_private->circuit.call_type");} | TOK_TIME {fprintf (mod_yyout, "mif_private->circuit.time");} + | TOK_TSTEP + {fprintf (mod_yyout, "mif_private->circuit.tstep");} + | TOK_TSTOP + {fprintf (mod_yyout, "mif_private->circuit.tstop");} | TOK_RAD_FREQ {fprintf (mod_yyout, "mif_private->circuit.frequency");} | TOK_TEMPERATURE diff --git a/src/xspice/mif/mifload.c b/src/xspice/mif/mifload.c index cc6c7c016..b0fcdeeff 100644 --- a/src/xspice/mif/mifload.c +++ b/src/xspice/mif/mifload.c @@ -194,6 +194,8 @@ MIFload( /* otherwise, set the times to zero */ if(anal_type == MIF_TRAN) { cm_data.circuit.time = ckt->CKTtime; + cm_data.circuit.tstep = ckt->CKTstep; + cm_data.circuit.tstop = ckt->CKTfinalTime; cm_data.circuit.t[0] = ckt->CKTtime; for(i = 1; i < 8; i++) { cm_data.circuit.t[i] = cm_data.circuit.t[i-1] - ckt->CKTdeltaOld[i-1]; @@ -203,6 +205,8 @@ MIFload( } else { cm_data.circuit.time = 0.0; + cm_data.circuit.tstep = 0.0; + cm_data.circuit.tstop = 0.0; for(i = 0; i < 8; i++) { cm_data.circuit.t[i] = 0.0; }