From 5af898f2fb9e0e7892fbabfef3d21400593b6519 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 20 Aug 2025 19:42:14 +0200 Subject: [PATCH] Add INSTNAME and INSTMODNAME to code model macros --- src/include/ngspice/mifcmdat.h | 1 + src/xspice/cmpp/mod_lex.l | 2 ++ src/xspice/cmpp/mod_yacc.y | 6 ++++++ src/xspice/icm/xtradev/degmonitor/cfunc.mod | 4 +++- src/xspice/mif/mifload.c | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/include/ngspice/mifcmdat.h b/src/include/ngspice/mifcmdat.h index d88003032..da1bac814 100644 --- a/src/include/ngspice/mifcmdat.h +++ b/src/include/ngspice/mifcmdat.h @@ -430,6 +430,7 @@ struct Mif_Private { Mif_Inst_Var_Data_t **inst_var; /* Information about each inst variable */ Mif_Callback_t *callback; /* Callback function */ Mif_Noise_Data_t *noise; /* Noise context, NULL when not in noise analysis */ + MIFinstance *instance; /* Information about the instance */ }; diff --git a/src/xspice/cmpp/mod_lex.l b/src/xspice/cmpp/mod_lex.l index 883603e99..6c9e616db 100644 --- a/src/xspice/cmpp/mod_lex.l +++ b/src/xspice/cmpp/mod_lex.l @@ -129,6 +129,8 @@ OUTPUT_TYPE {return TOK_OUTPUT_TYPE;} OUTPUT_CHANGED {return TOK_OUTPUT_CHANGED;} NOISE_DENSITY {return TOK_NOISE_DENSITY;} NOISE_FREQ {return TOK_NOISE_FREQ;} +INSTNAME {return TOK_INSTNAME;} +INSTMODNAME {return TOK_INSTMODNAME;} "(" {return TOK_LPAREN;} ")" {return TOK_RPAREN;} diff --git a/src/xspice/cmpp/mod_yacc.y b/src/xspice/cmpp/mod_yacc.y index ccf3b2a18..cde1dc010 100644 --- a/src/xspice/cmpp/mod_yacc.y +++ b/src/xspice/cmpp/mod_yacc.y @@ -373,6 +373,8 @@ static void append (char *str) %token TOK_CALL_TYPE %token TOK_NOISE_DENSITY %token TOK_NOISE_FREQ +%token TOK_INSTNAME +%token TOK_INSTMODNAME %start mod_file @@ -447,6 +449,10 @@ macro : TOK_INIT {fprintf (mod_yyout, "mif_private->circuit.frequency");} | TOK_TEMPERATURE {fprintf (mod_yyout, "mif_private->circuit.temperature");} + | TOK_INSTNAME + {fprintf (mod_yyout, "mif_private->instance->MIFname");} + | TOK_INSTMODNAME + {fprintf (mod_yyout, "mif_private->instance->gen.GENmodPtr->GENmodName");} | TOK_T TOK_LPAREN buffered_c_code TOK_RPAREN {fprintf (mod_yyout, "mif_private->circuit.t[%s]", $3);} | TOK_PARAM TOK_LPAREN subscriptable_id TOK_RPAREN diff --git a/src/xspice/icm/xtradev/degmonitor/cfunc.mod b/src/xspice/icm/xtradev/degmonitor/cfunc.mod index dc2dba7f3..c9aa896fa 100644 --- a/src/xspice/icm/xtradev/degmonitor/cfunc.mod +++ b/src/xspice/icm/xtradev/degmonitor/cfunc.mod @@ -43,7 +43,7 @@ NON-STANDARD FEATURES /*=== INCLUDE FILES ====================*/ - +#include "ngspice/mifdefs.h" /*=== CONSTANTS ========================*/ @@ -185,6 +185,8 @@ void cm_degmon(ARGS) /* structure holding parms, STATIC_VAR(prevtime) = (double *) malloc(sizeof(double)); prevtime = (double *) STATIC_VAR(prevtime); *prevtime = 0.; + cm_message_send(INSTNAME); + cm_message_send(INSTMODNAME); } else { diff --git a/src/xspice/mif/mifload.c b/src/xspice/mif/mifload.c index b0fcdeeff..1f1c579aa 100644 --- a/src/xspice/mif/mifload.c +++ b/src/xspice/mif/mifload.c @@ -241,6 +241,7 @@ MIFload( /* ***************************************************************** */ g_mif_info.instance = here; g_mif_info.errmsg = ""; + cm_data.instance = here; if(here->initialized) { cm_data.circuit.init = MIF_FALSE;