SPICE MOSFET level 6 CMOS inverter

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

model v vsource
model r resistor
model c capacitor

model nm sp_mos6 ( type=1 
  phi=0.600000 tox=2.1200e-08
  tpg=1 vto=1 lambda0=0.06 lambda1=0.004
  ld=1.6470e-07 uo=591.7 
  rsh=8.5450e+01 gamma=0.5863 nsub=1.6160e+16
  cgdo=4.0241e-10 cgso=4.0241e-10
  cgbo=3.6144e-10 cj=3.8541e-04 mj=1.1854
  cjsw=1.3940e-10 mjsw=0.125195 pb=0.800000
)

model pm sp_mos6 ( type=-1
  phi=0.600000 tox=2.1200e-08
  tpg=1 vto=-1 lambda0=0.06 lambda1=0.004
  ld=1.6470e-07 uo=591.7 
  rsh=8.5450e+01 gamma=0.5863 nsub=1.6160e+16
  cgdo=4.0241e-10 cgso=4.0241e-10
  cgbo=3.6144e-10 cj=3.8541e-04 mj=1.1854
  cjsw=1.3940e-10 mjsw=0.125195 pb=0.800000
)

vdd (1 0) v dc=5
m1 (out in 0 0) nm w=200u l=50u $mfactor=2 nrs=1 nrd=1
m2 (out in 1 1) pm w=200u l=50u $mfactor=2 nrs=1 nrd=1
r1 (out 0) r r=100k
vin (in 0) v dc=0 type="pulse" val0=0 val1=5 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('Level 6 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


