diff --git a/examples/p-to-n-examples/switch-oscillators_inc.cir b/examples/p-to-n-examples/switch-oscillators_inc.cir index f8f867b57..8815483ed 100644 --- a/examples/p-to-n-examples/switch-oscillators_inc.cir +++ b/examples/p-to-n-examples/switch-oscillators_inc.cir @@ -3,14 +3,13 @@ .control destroy all run -plot I(vmeasure) -plot V(Osc_out) -rusage +plot I(vmeasure) ylimit 0 5m +plot V(Osc_out) +rusage .endc .ic v(N017)=0.25 -.tran 50p 40n 50p uic -*.option method=gear maxord=3 +.tran 50p 40n 50p VDD VDD2 0 DC 3 diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 1b2391b9b..f5866a061 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -8029,7 +8029,7 @@ static struct card *pspice_compat(struct card *oldcard) tfree(card->line); rep_spar(modpar); card->line = tprintf( - ".model a%s aswitch(%s %s %s %s log=TRUE)", modname, + ".model a%s aswitch(%s %s %s %s log=TRUE limit=TRUE)", modname, modpar[0], modpar[1], modpar[2], modpar[3]); } for (i = 0; i < 4; i++) @@ -8210,7 +8210,7 @@ static struct card *pspice_compat(struct card *oldcard) tfree(card->line); rep_spar(modpar); card->line = tprintf( - ".model a%s aswitch(%s %s %s %s log=TRUE)", modname, + ".model a%s aswitch(%s %s %s %s log=TRUE limit=TRUE)", modname, modpar[0], modpar[1], modpar[2], modpar[3]); } for (i = 0; i < 4; i++) diff --git a/src/xspice/icm/xtradev/aswitch/cfunc.mod b/src/xspice/icm/xtradev/aswitch/cfunc.mod index bceb507ea..d9143cc1a 100644 --- a/src/xspice/icm/xtradev/aswitch/cfunc.mod +++ b/src/xspice/icm/xtradev/aswitch/cfunc.mod @@ -150,7 +150,14 @@ void cm_aswitch(ARGS) /* structure holding parms, if ( PARAM(log) == MIF_TRUE ) { /* Logarithmic Variation in 'R' */ intermediate = log(r_off / r_on) / (cntl_on - cntl_off); r = r_on * exp(intermediate * (cntl_on - INPUT(cntl_in))); - if(r<=1.0e-9) r=1.0e-9;/* minimum resistance limiter */ + + if (PARAM(limit) == MIF_TRUE) { + if(rr_off) r=r_off;/* maximum resistance limiter */ + } + else { + if(r<=1.0e-9) r=1.0e-9;/* minimum resistance limiter */ + } pi_pvout = 1.0 / r; pi_pcntl = intermediate * INPUT(out) / r; } @@ -158,14 +165,18 @@ void cm_aswitch(ARGS) /* structure holding parms, intermediate = (r_on - r_off) / (cntl_on - cntl_off); r = INPUT(cntl_in) * intermediate + ((r_off*cntl_on - r_on*cntl_off) / (cntl_on - cntl_off)); - if(r<=1.0e-9) r=1.0e-9;/* minimum resistance limiter */ + + if (PARAM(limit) == MIF_TRUE) { + if(rr_off) r=r_off;/* maximum resistance limiter */ + } + else { + if(r<=1.0e-9) r=1.0e-9;/* minimum resistance limiter */ + } pi_pvout = 1.0 / r; pi_pcntl = -intermediate * INPUT(out) / (r*r); } - /*pi_pvout = 1.0 / r;*/ - - if(ANALYSIS != MIF_AC) { /* Output DC & Transient Values */ OUTPUT(out) = INPUT(out) / r; /* Note that the minus */ PARTIAL(out,out) = pi_pvout; /* Signs are required */ diff --git a/src/xspice/icm/xtradev/aswitch/ifspec.ifs b/src/xspice/icm/xtradev/aswitch/ifspec.ifs index 4fdde9413..87e8fcb58 100644 --- a/src/xspice/icm/xtradev/aswitch/ifspec.ifs +++ b/src/xspice/icm/xtradev/aswitch/ifspec.ifs @@ -67,11 +67,11 @@ Null_Allowed: yes yes PARAMETER_TABLE: -Parameter_Name: r_on -Description: "on resistance" -Data_Type: real -Default_Value: 1.0 -Limits: - -Vector: no -Vector_Bounds: - -Null_Allowed: yes +Parameter_Name: r_on limit +Description: "on resistance" "set upper and lower limits to resistance" +Data_Type: real boolean +Default_Value: 1.0 false +Limits: - - +Vector: no no +Vector_Bounds: - - +Null_Allowed: yes yes