SPICE VDMOS CMOS inverter

load "spice/vdmos.osdi"
load "resistor.osdi"
load "capacitor.osdi"

model v vsource
model r resistor
model c capacitor

model nm sp_vdmos ( type=1 
  vto=4 kp=5.9 lambda=0.001 theta=0.015 ksubthres=0.27
  rd=61m rs=18m rg=3 rds=1e7
  cgdmax=2.45n cgdmin=10p a=0.3 cgs=1.2n
  is=60p n=1.1 rb=14m xti=3
  cjo=1.5n vj=0.8 m=0.5
  tcvth=0.0065 mu=-1.27 texp0=1.5
  rthjc=0.4 cthj=5e-3
  mtriode=0.8 vq=100 rq=0.5
  kf=0.032f af=1
)

model pm sp_vdmos ( type=-1 
  vto=-4 kp=5.9 lambda=0.001 theta=0.015 ksubthres=0.27
  rd=61m rs=18m rg=3 rds=1e7
  cgdmax=2.45n cgdmin=10p a=0.3 cgs=1.2n
  is=60p n=1.1 rb=14m xti=3
  cjo=1.5n vj=0.8 m=0.5
  tcvth=0.0065 mu=-1.27 texp0=1.5
  rthjc=0.4 cthj=5e-3
  mtriode=0.8 vq=100 rq=0.5
  kf=0.032f af=1
)

vdd (1 0) v dc=10
m1 (out in 0) nm $mfactor=2
m2 (out in 1) pm $mfactor=2
r1 (out 0) r r=100k
vin (in 0) v dc=0 type="pulse" val0=0 val1=10 delay=1u rise=100n fall=100n width=1u period=2u

control
  analysis tran1 tran step=1n stop=5u maxstep=1n
 
  postprocess(PYTHON, "runme.py")
endc

embed "runme.py" <<<FILE
from rawfile import rawread
import numpy as np
import matplotlib.pyplot as plt
import sys

raw = rawread('tran1.raw')
plot = raw.get()

fig1 = plt.figure(figsize=(8,8), dpi=100)
fig1.suptitle('VDMOS CMOS inverter')
ax_dict = fig1.subplot_mosaic("""
A
B
C
""")

ax_dict["A"].set_title('Input')
ax_dict["A"].set_ylabel('Vin [V]')
ax_dict["A"].set_xlabel('time [us]')
ax_dict["A"].plot(plot['time']*1e6, plot['in'])

ax_dict["B"].set_title('Output')
ax_dict["B"].set_ylabel('Vout [V]')
ax_dict["B"].set_xlabel('time [us]')
ax_dict["B"].plot(plot['time']*1e6, plot['out'])

ax_dict["C"].set_title('Supply current')
ax_dict["C"].set_ylabel('Idd [A]')
ax_dict["C"].set_xlabel('time [us]')
ax_dict["C"].plot(plot['time']*1e6, plot['vdd:flow(br)'])

fig1.tight_layout()

plt.show()
>>>FILE


