Browse Source

patch no. 16 by Thomy add a function cm_get_circuit to allow accessing the circuit structure ckt from within an XSPICE code model. This is a change to the interface and requires recopiling all code models!

pre-master-46
h_vogt 10 years ago
committed by Holger Vogt
parent
commit
7198056a41
  1. 2
      src/include/ngspice/cmproto.h
  2. 1
      src/include/ngspice/dllitf.h
  3. 19
      src/xspice/cm/cm.c
  4. 1
      src/xspice/cm/cmexport.c
  5. 4
      src/xspice/icm/dlmain.c
  6. 1
      src/xspice/xspice.c

2
src/include/ngspice/cmproto.h

@ -48,6 +48,7 @@ NON-STANDARD FEATURES
#include <stdio.h>
#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);

1
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));

19
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);
}

1
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,

4
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)();
}

1
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,

Loading…
Cancel
Save