diff --git a/src/include/ngspice/cmproto.h b/src/include/ngspice/cmproto.h index 89a8b3e0b..d29d91c0d 100644 --- a/src/include/ngspice/cmproto.h +++ b/src/include/ngspice/cmproto.h @@ -48,6 +48,7 @@ NON-STANDARD FEATURES #include #include "ngspice/cmtypes.h" +#include "ngspice/cktdefs.h" void cm_climit_fcn(double in, double in_offset, double cntl_upper, @@ -102,6 +103,7 @@ Complex_t cm_complex_multiply(Complex_t x, Complex_t y); Complex_t cm_complex_divide(Complex_t x, Complex_t y); char *cm_get_path(void); +CKTcircuit *cm_get_circuit(void); FILE *cm_stream_out(void); FILE *cm_stream_in(void); diff --git a/src/include/ngspice/dllitf.h b/src/include/ngspice/dllitf.h index fe98a2851..8bdbc2354 100644 --- a/src/include/ngspice/dllitf.h +++ b/src/include/ngspice/dllitf.h @@ -64,6 +64,7 @@ struct coreInfo_t { Complex_t ((*dllitf_cm_complex_multiply)(Complex_t, Complex_t)); Complex_t ((*dllitf_cm_complex_divide)(Complex_t, Complex_t)); char * ((*dllitf_cm_get_path)(void)); + CKTcircuit *((*dllitf_cm_get_circuit)(void)); FILE * ((*dllitf_cm_stream_out)(void)); FILE * ((*dllitf_cm_stream_in)(void)); FILE * ((*dllitf_cm_stream_err)(void)); diff --git a/src/xspice/cm/cm.c b/src/xspice/cm/cm.c index b57ff2baf..462047915 100644 --- a/src/xspice/cm/cm.c +++ b/src/xspice/cm/cm.c @@ -37,6 +37,7 @@ INTERFACES cm_message_get_errmsg() cm_message_send() cm_get_path() + cm_get_circuit() REFERENCED FILES @@ -706,3 +707,21 @@ char *cm_get_path(void) return Infile_Path; } + +/* cm_get_circuit(void) + +To build complex custom-built xspice-models, access to certain +parameters (e.g. maximum step size) may be needed to get reasonable +results of a simulation. In detail, this may be necessary when +spice interacts with an external sensor-simulator and the results +of that external simulator do not have a direct impact on the spice +circuit. Then, modifying the maximum step size on the fly may help +to improve the simulation results. Modifying such parameters has to +be done carefully. The patch enhances the xspice interface with +access to the (fundamental) ckt pointer. +*/ + +CKTcircuit *cm_get_circuit(void) +{ + return(g_mif_info.ckt); +} diff --git a/src/xspice/cm/cmexport.c b/src/xspice/cm/cmexport.c index cf16cbbe0..fa8e9199c 100644 --- a/src/xspice/cm/cmexport.c +++ b/src/xspice/cm/cmexport.c @@ -64,6 +64,7 @@ struct coreInfo_t coreInfo = cm_complex_multiply, cm_complex_divide, cm_get_path, + cm_get_circuit, no_file, no_file, no_file, diff --git a/src/xspice/icm/dlmain.c b/src/xspice/icm/dlmain.c index a2aed9cc4..d993ff374 100644 --- a/src/xspice/icm/dlmain.c +++ b/src/xspice/icm/dlmain.c @@ -362,6 +362,10 @@ char * cm_get_path(void) { return (coreitf->dllitf_cm_get_path)(); } +CKTcircuit *cm_get_circuit(void) { + return (coreitf->dllitf_cm_get_circuit)(); +} + FILE * cm_stream_out(void) { return (coreitf->dllitf_cm_stream_out)(); } diff --git a/src/xspice/xspice.c b/src/xspice/xspice.c index c43d58f0a..620981b91 100644 --- a/src/xspice/xspice.c +++ b/src/xspice/xspice.c @@ -62,6 +62,7 @@ struct coreInfo_t coreInfo = cm_complex_multiply, cm_complex_divide, cm_get_path, + cm_get_circuit, no_file, no_file, no_file,