[eispice] Re: behavior test case problems

Charles,

   Actually, you don't even need a solver to calculate this and I didn't 
tell you in my last email that this was the first thing I did before even 
setting up the circuit. Writing a Python program was merely done just to 
confirm that I could solve circuit voltages using a Newton-Raphson iteration 
technique on a circuit. See the analytical solution below:
      Ip + In = 0
     -Ip = In
    0.5*Bp*(Vsup-V-Vtp)^2 = 0.5*Bn*(V-Vtn)^2

  Substituting Vsup=3.3V and Vtp=Vtn=0.7, one gets:

      0.5*Bp*(2.6-V)^2 = 0.5*Bn*(V-0.7)^2

       which reduces to:

      sqrt(Bp/Bn) = (V-0.7)/(2.6-V)

     sqrt(2/5) = (V-0.7)/(2.6-V)
      V*(1+sqrt(2/5)) = sqrt(2/5)*2.6 +0.7
      V = (sqrt(2/5)*2.6+0.7)/(1+sqrt(2/5))=1.436

     And solve for V.  I know that 0.7 you got cannot be the correct answer 
because that would suggest that there is zero current going through the nmos 
device while current going through the pmos. The equations above confirm 
this as well. I still might have had a setup error in your tool; but I know 
what the answer ought to be.

  Jon


>From: Charles Eidsness <charles@xxxxxxxxxxxxxxxxxxxxx>
>Reply-To: eispice@xxxxxxxxxxxxx
>To: eispice@xxxxxxxxxxxxx
>Subject: [eispice] Re: behavior test case problems
>Date: Wed, 27 Dec 2006 12:13:38 -0500
>
>Hi Jon,
>
>I think you may have forgotten to include the resistor in your analysis.
>Based on my hand-analysis eipsice returns the correct result (I also
>tried using the MathCAD root-solver and got the same result). Of course
>I could have just as easily made an error, if you see one please let me
>know.
>
>Bn = 5e-6 x 2 / 1
>Bp = 2e-6 x 2 / 1
>Vt = 0.7
>Vct = 3.3 - 0.7
>R = 100e3
>
>In(Vg) = (Vg > Vt) ? (0.5 x Bn x (Vg-Vt)^2) : 0.0
>Ip(Vg) = (3.3 - Vg > Vt) ? (-0.5 x Bp x (Vct-Vg)^2) : 0.0
>Ir(Vg) = Vg/R
>
>Need to find the root of:
>In(Vg) + Ip(Vg) + Ir(Vg)
>
>Using the world famous quadratic equation (assuming 2.6 > Vg > 0.7):
>x = (-b +/- sqrt(b^2 - 4*ac)) / 2a
>a = 0.5 x Bn - 0.5 x Bp
>b = (0.5 x Bn x -2 x Vt) - (0.5 x Bp x -2 x Vct) + 1/R
>c = 0.5 x Bn x Vt^2 - 0.5 x Bp x Vct^2
>
>I get x = 0.107 and -34.6, neither falls into the 2.6 to 0.7 range so
>one on the FETs must be off.
>
>Assuming only the NMOS device is on, (can just set Bp to 0.0), 3.3 > Vg
>  > 2.6:
>x = -0.026 and x = -18.574, neither falls in the range.
>
>Assuming only the PMOS device is on, (can just set Bn to 0.0), 0.7 > Vg
>  > 0.0:
>x = 55.077 and x = 0.123
>0.123 V falls in the range, and is the value that eispice calculates.
>
>The reason that I'm guessing that you may have forgotten to include the
>resistor in your analysis is because if I substitute 1Gig-Ohm in the
>equations above, and in eispice I get 1.436V, which is what you were
>calculating.
>
>Let me know if you think I'm on the right-track or have over-looked
>something.
>
>Thanks for the great discussion! Analysis / discussion like this one is
>a great way to improve eispice!
>
>Cheers,
>Charles
>
>Jon Choy wrote:
> >   Charles,
> >
> >     You are right about the sign error; but the solution is incorrect. 
>The
> > answer is around 1.4V. I ran this circuit with an Excel spreadsheet and
> > writing down the equations as well as writing a Python program that
> > calculates the DC point using a Newton - Raphson iteration technique it
> > get's a similar answer of about 1.43V.
> >
> >   Jon
> >
> >
> >
> >> From: Charles Eidsness <charles@xxxxxxxxxxxxxxxxxxxxx>
> >> Reply-To: eispice@xxxxxxxxxxxxx
> >> To: eispice@xxxxxxxxxxxxx
> >> Subject: [eispice] Re: behavior test case problems
> >> Date: Tue, 19 Dec 2006 15:46:15 -0500
> >>
> >> Hi Jon,
> >>
> >> I don't have a lot of experience modelling semi-conductor devices in
> >> this way  so I may be wrong, but shouldn't the current through the PMOS
> >> device run in the opposite direction w.r.t. the NMOS device? If it's
> >> turned around, i.e.:
> >> return -0.5*self.betap*(Vs - Vg - self.vtp)**self.power
> >> the simulation runs, but gives in an output of 0.7Vs. Which may not be
> >> what you were expecting?
> >>
> >> Cheers!
> >> Charles
> >>
> >> Jon Choy wrote:
> >>
> >>>   Charles,
> >>>
> >>>     Thanks for the feedback. I did notice the typos after I sent the
> >>>
> >> case on
> >>
> >>> to you; but they still failed and now I know why.  No problem about
> >>>
> >> working
> >>
> >>> through the bugs. I anticipated this being sort of an alpha user. Work
> >>>
> >> on it
> >>
> >>> when you get a chance, I'm sure you've got your day job as well.
> >>>
> >>>   Jon
> >>>
> >>>
> >>>
> >>>
> >>>> From: Charles Eidsness <charles@xxxxxxxxxxxxxxxxxxxxx>
> >>>> Reply-To: eispice@xxxxxxxxxxxxx
> >>>> To: eispice@xxxxxxxxxxxxx
> >>>> Subject: [eispice] Re: behavior test case problems
> >>>> Date: Mon, 18 Dec 2006 18:47:03 -0500
> >>>>
> >>>> Hi Jon,
> >>>>
> >>>> You're not abusing, you're stretching. :) It was intended to be used 
>in
> >>>> that way, but you're the first to try it.
> >>>>
> >>>> It looks like I have some work to do on error messages. They're way 
>to
> >>>> cryptic, especially for the new PyB device. I'll see what I can do.
> >>>>
> >>>> Your B-Element based model uncovered a bug in the calculon library's
> >>>> parser. It requires a space between the '-' sign and constants. I've
> >>>> fixed it in my stream and it will be fixed for the next release but 
>for
> >>>> now you can just add a space. Also, the B element doesn't recognize 
>the
> >>>> 'GND' identifier, it only recognizes 0 as a ground indicator. I can 
>add
> >>>> GND as well but I'm hoping that as soon as we get this PyB element
> >>>> working the only use for the old B element will be for porting in
> >>>>
> >> Spice3
> >>
> >>>> decks which only use 0.
> >>>>
> >>>> If you change:
> >>>> d.pmosx = dev.B('4', GND, 'i',"0.5*2e-6*(v(1,4)-0.7)^2")
> >>>> to:
> >>>> d.pmosx = dev.B('4', GND, 'i',"0.5*2e-6*(v(1,4) - 0.7)^2")
> >>>>
> >>>> and:
> >>>> d.nmosx = dev.B(4, GND, 'i',"0.5*5e-6*(v(4,GND)-0.7)^2")
> >>>> to:
> >>>> d.nmosx = dev.B(4, GND, 'i',"0.5*5e-6*(v(4,0) - 0.7)^2")
> >>>>
> >>>> The simulation runs, until it fails to linearize. I'll have to fiddle
> >>>> with the simulator to get it working further than that, which will 
>take
> >>>> a little bit longer. I'll post again once I get it working.
> >>>>
> >>>> The two PyB based models had a couple of typos. The lines:
> >>>> def model(self, Vg, Vs)
> >>>> should have a 4th argument (because you defined 3 input arguments), 
>you
> >>>> can change them to something like:
> >>>> def model(self, Vg, Vs, Vp)
> >>>> Also, for the second model the if statement references vtp but it
> >>>>
> >> should
> >>
> >>>> reference vtn, i.e.:
> >>>> if ((Vg - Vs)> self.vtp):
> >>>> should be:
> >>>> if ((Vg - Vs)> self.vtn):
> >>>>
> >>>> Once you make those two changes it should run as far as the 'failed 
>to
> >>>> linearize' as well.
> >>>>
> >>>> I'm sure with some useful messages those two typos would have popped
> >>>> right out. It's tough to debug when every error message is 
>"TypeError:
> >>>> bad argument type for built-in operation". I'm guessing it's really
> >>>> referring to some bug in the way I'm passing error messages between C
> >>>> and Python, I'll look into it.
> >>>>
> >>>> Thanks for having patience as we work through the bugs, and I'll get
> >>>> back to you on those 'failed to linerise's'
> >>>>
> >>>> Cheers,
> >>>> Charles
> >>>>
> >>>>
> >>>> Jon Choy wrote:
> >>>>
> >>>>
> >>>>>   I've tried a couple of behavior cases that don't seem to run. I 
>hope
> >>>>>
> >> I
> >>
> >>>>> haven't abused the capability. I'm simply seeing if a mos divider
> >>>>>
> >>>>>
> >>>> circuit
> >>>>
> >>>>
> >>>>> will work. I have two devices and behavioral nmos and pmos with the
> >>>>>
> >>>>>
> >>>> gate,
> >>>>
> >>>>
> >>>>> drain of both the pmos and nmos tied together. I have tried three
> >>>>>
> >>>>>
> >>>> different
> >>>>
> >>>>
> >>>>> cases. Let me know what you think.
> >>>>>
> >>>>> #!/usr/bin/python
> >>>>>
> >>>>> from eispice import *
> >>>>>
> >>>>> # -- PyB Defined Model --
> >>>>> class pmos_sat(dev.PyB):
> >>>>>
> >>>>>   def __init__(self, p, n, g,  s, b, kp=2e-6,wp=2,lp=1,power=2.0):
> >>>>>     dev.PyB.__init__(self, p, n, Current, v(g), v(s), v(b))
> >>>>>     self.kp = kp
> >>>>>     self.wp = wp
> >>>>>     self.lp = lp
> >>>>>     self.vtp= 0.7
> >>>>>     self.betap = kp*wp/lp
> >>>>>     self.power=power
> >>>>>   def model(self, Vg, Vs):
> >>>>>     if ((Vs - Vg)> self.vtp):
> >>>>>       return 0.5*self.betap*(Vs - Vg - self.vtp)**self.power
> >>>>>     else :
> >>>>>       return 0
> >>>>> class nmos_sat(dev.PyB):
> >>>>>
> >>>>>   def __init__(self, p, n, g,  s, b, kn=5e-6,wn=2,ln=1,power=2.0):
> >>>>>     dev.PyB.__init__(self, p, n, Current, v(g), v(s), v(b))
> >>>>>     self.kn = kn
> >>>>>     self.wn = wn
> >>>>>     self.ln = ln
> >>>>>     self.vtn= 0.7
> >>>>>     self.betan = kn*wn/ln
> >>>>>     self.power=power
> >>>>>   def model(self, Vg, Vs):
> >>>>>     if ((Vg - Vs)> self.vtp):
> >>>>>       return 0.5*self.betan*(Vg - Vs - self.vtn)**self.power
> >>>>>     else :
> >>>>>       return 0
> >>>>>
> >>>>> # Now to use the model
> >>>>> kp = 2e-6
> >>>>> wp = 2
> >>>>> lp = 1
> >>>>> vtp= 0.7
> >>>>> betap = kp*wp/lp
> >>>>> power=2
> >>>>> kn = 5e-6
> >>>>> wn = 2
> >>>>> ln = 1
> >>>>> vtn= 0.7
> >>>>> betan = kn*wn/ln
> >>>>>
> >>>>> d = Deck('PyB Defined Behavioral MOS divider')
> >>>>>
> >>>>> d.V0 = dev.V(1, GND, 3.3)
> >>>>> #d.pmosx = pmos_sat(4, GND, 4, 1, 1)
> >>>>> #d.pmosx = dev.B('4', GND, 'i',"0.5*betap*(v(1,4)-vtp)^2")
> >>>>> d.pmosx = dev.B('4', GND, 'i',"0.5*2e-6*(v(1,4)-0.7)^2")
> >>>>> #d.nmosx = nmos_sat(4, GND, 4, GND, GND)
> >>>>> #d.nmosx = dev.B(4, GND, 'i',"0.5*betan*(v(4,GND)-vtn)^2")
> >>>>> d.nmosx = dev.B(4, GND, 'i',"0.5*5e-6*(v(4,GND)-0.7)^2")
> >>>>> d.rout = dev.R(4,GND, 100000)
> >>>>>
> >>>>> d.op()
> >>>>>
> >>>>> d.plot()
> >>>>>
> >>>>> _________________________________________________________________
> >>>>> Get live scores and news about your team: Add the Live.com Football
> >>>>>
> >> Page
> >>
> >>>>> www.live.com/?addtemplate=football&icid=T001MSN30A0701
> >>>>>
> >>>>> ------------------------------------------------------------------
> >>>>> To unsubscribe from the eispice list send an email to:
> >>>>> eispice-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject 
>field
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> ------------------------------------------------------------------
> >>>> To unsubscribe from the eispice list send an email to:
> >>>> eispice-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field
> >>>>
> >>>>
> >>> _________________________________________________________________
> >>> Experience the magic of the holidays. Talk to Santa on Messenger.
> >>>
> >>>
> >> 
>http://clk.atdmt.com/MSN/go/msnnkwme0080000001msn/direct/01/?href=http://imagine-windowslive.com/minisites/santabot/default.aspx?locale=en-us
> >>
> >>> ------------------------------------------------------------------
> >>> To unsubscribe from the eispice list send an email to:
> >>> eispice-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field
> >>>
> >>>
> >>>
> >>>
> >> ------------------------------------------------------------------
> >> To unsubscribe from the eispice list send an email to:
> >> eispice-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field
> >>
> >
> > _________________________________________________________________
> > Your Hotmail address already works to sign into Windows Live Messenger! 
>Get
> > it now
> > 
>http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01/?href=http://get.live.com/messenger/overview
> >
> > ------------------------------------------------------------------
> > To unsubscribe from the eispice list send an email to:
> > eispice-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field
> >
> >
> >
>------------------------------------------------------------------
>To unsubscribe from the eispice list send an email to:
>eispice-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field

_________________________________________________________________
The MSN Entertainment Guide to Golden Globes is here.  Get all the scoop. 
http://tv.msn.com/tv/globes2007/

------------------------------------------------------------------
To unsubscribe from the eispice list send an email to:
eispice-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field

Other related posts: