diff --git a/src/xspice/icm/GNUmakefile.in b/src/xspice/icm/GNUmakefile.in index a72cb488c..fe4494f85 100644 --- a/src/xspice/icm/GNUmakefile.in +++ b/src/xspice/icm/GNUmakefile.in @@ -7,7 +7,7 @@ include makedefs # The codemodels to make -CMDIRS = spice2poly digital analog xtradev xtraevt +CMDIRS = spice2poly digital analog xtradev xtraevt sherlockmbv all: diff --git a/src/xspice/icm/sherlockmbv/.gitignore b/src/xspice/icm/sherlockmbv/.gitignore new file mode 100644 index 000000000..27b44acbe --- /dev/null +++ b/src/xspice/icm/sherlockmbv/.gitignore @@ -0,0 +1,12 @@ +/spice2poly.cm + +/cmextrn.h +/cminfo.h +/dlmain.c +/objects.inc +/udnextrn.h +/udninfo.h + +/*/*.c + +!/*/udnfunc.c diff --git a/src/xspice/icm/sherlockmbv/limitsmbv/cfunc.mod b/src/xspice/icm/sherlockmbv/limitsmbv/cfunc.mod new file mode 100644 index 000000000..18d6d9a72 --- /dev/null +++ b/src/xspice/icm/sherlockmbv/limitsmbv/cfunc.mod @@ -0,0 +1,94 @@ +#include +void cm_limitsmbv(ARGS) /* structure holding parms, + inputs, outputs, etc. */ +{ + + double x; /* Input Variable */ + double xtp; /* Transition threshold from linear to exponention (positive side) */ + double xtm; /* Transition threshold from linear to exponention (positive side) */ + + double y; /* Output Variable */ + + double xtpi; /* xtp limited to positive range */ + double xtmi; /* xtm limited to negative range */ + + double g; /* Linear slope passing through x,y=0,0 */ + double a; /* Term for exponetial regions below xtm and above xtp */ + double Xg; /* Relation for continuous derivatives at xtm and xtp */ + double Xo; /* Offset of exponentional terms for continuos derivatives */ + + Mif_Complex_t dy_dx; /* Complex partial derivative dy/dx */ + Mif_Complex_t dy_dxtp; /* Complex partial derivative dy/dxtp */ + Mif_Complex_t dy_dxtm; /* Complex partial derivative dy/dxtm */ + + + /* + * Linear to Exponention Transistion Management + */ + g = PARAM(g); + a = PARAM(a); + if ( g > 0.0 ) { + Xg = log( g / a ) / a; + Xo = exp( a * Xg ); + } + else { + Xg = 0.0; + Xo = 1.0; + } + + /* + * Access the inputs from the interface + */ + x = INPUT(x); + xtp = INPUT(xtp); + xtm = INPUT(xtm); + + + /* + * Sanity check on dynamic thresholds. + */ + xtpi = (xtp >= 0.0) ? xtp : 0.0; + xtmi = (xtm <= 0.0) ? xtm : 0.0; + + /* + * Ideal Avalanche Characteristic + */ + if (x >= xtpi) { + y = g * xtpi+exp(a * (x - xtpi+Xg)) - Xo; + dy_dx.real = a*exp(a * (x - xtpi+Xg)); + dy_dxtp.real = g - a*exp(a * (x - xtpi+Xg)); + dy_dxtm.real = 0.0; + } + else if (x <= xtmi) { + y = -1.0 * (g * fabs(xtmi)+exp(a * (fabs(x) - fabs(xtmi)+Xg)) - Xo); + dy_dx.real = -1.0*a*exp(a * (fabs(x) - fabs(xtmi)+Xg));; + dy_dxtp.real = 0.0; + dy_dxtm.real = -1.0*(g - a*exp(a * (fabs(x) - fabs(xtmi)+Xg))); + } + else { + y = g * x; + dy_dx.real = g; + dy_dxtp.real = 0.0; + dy_dxtm.real = 0.0; + } + + /* + * Zero out the imaginary parts. + */ + dy_dx.imag = 0.0; + dy_dxtp.imag = 0.0; + dy_dxtm.imag = 0.0; + + + if (ANALYSIS != MIF_AC) { /* DC & Transient Analyses */ + OUTPUT(y) = y; + PARTIAL(y,x) = dy_dx.real; + PARTIAL(y,xtp) = dy_dxtp.real; + PARTIAL(y,xtm) = dy_dxtm.real; + } + else { /* AC Analysis */ + AC_GAIN(y,x) = dy_dx; + AC_GAIN(y,xtp) = dy_dxtp; + AC_GAIN(y,xtm) = dy_dxtm; + } +} diff --git a/src/xspice/icm/sherlockmbv/limitsmbv/ifspec.ifs b/src/xspice/icm/sherlockmbv/limitsmbv/ifspec.ifs new file mode 100644 index 000000000..d76c3941b --- /dev/null +++ b/src/xspice/icm/sherlockmbv/limitsmbv/ifspec.ifs @@ -0,0 +1,74 @@ +/* + * SUMMARY + * This file contains the interface specification file for the + * analog limit code model. + * + */ + +NAME_TABLE: + + +C_Function_Name: cm_limitsmbv +Spice_Model_Name: limitsmbv +Description: "limit block" + + +PORT_TABLE: +Port_Name: x +Description: "input" +Direction: in +Default_Type: v +Allowed_Types: [v,vd,i,id,vnam] +Vector: no +Vector_Bounds: - +Null_Allowed: no + +PORT_TABLE: +Port_Name: xtp +Description: "positive threshold" +Direction: in +Default_Type: v +Allowed_Types: [v,vd,i,id,vnam] +Vector: no +Vector_Bounds: - +Null_Allowed: no + +PORT_TABLE: +Port_Name: xtm +Description: "negative threshold" +Direction: in +Default_Type: v +Allowed_Types: [v,vd,i,id,vnam] +Vector: no +Vector_Bounds: - +Null_Allowed: no + +PORT_TABLE: +Port_Name: y +Description: "output" +Direction: out +Default_Type: v +Allowed_Types: [v,vd,i,id] +Vector: no +Vector_Bounds: - +Null_Allowed: no + +PARAMETER_TABLE: +Parameter_Name: g +Description: "linear gain" +Data_Type: real +Default_Value: 1.0 +Limits: - +Vector: no +Vector_Bounds: - +Null_Allowed: yes + +PARAMETER_TABLE: +Parameter_Name: a +Description: "exponential gain" +Data_Type: real +Default_Value: 1.0 +Limits: - +Vector: no +Vector_Bounds: - +Null_Allowed: yes diff --git a/src/xspice/icm/sherlockmbv/modpath.lst b/src/xspice/icm/sherlockmbv/modpath.lst new file mode 100644 index 000000000..83b31b70c --- /dev/null +++ b/src/xspice/icm/sherlockmbv/modpath.lst @@ -0,0 +1 @@ +limitsmbv diff --git a/src/xspice/icm/sherlockmbv/udnpath.lst b/src/xspice/icm/sherlockmbv/udnpath.lst new file mode 100644 index 000000000..e69de29bb