[eispice] Re: behavior test case problems

  • From: Charles Eidsness <charles@xxxxxxxxxxxxxxxxxxxxx>
  • To: eispice@xxxxxxxxxxxxx
  • 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

Other related posts: