blob: 8c05a1b0ee12079aa6fbd4a7bf9dee7e867e7613 [file] [log] [blame] [edit]
#!/usr/bin/env python3
#
# Plot MOSFET I/V curve from devicename + '.data' from running ngspice
# on 'mosfet_test.spice'
import sys
import matplotlib.pyplot as plt
def make_mosfet_vth_plot(devicename, version, corner):
with open('results/' + devicename + '_vth.data', 'r') as ifile:
idata = ifile.read().split()
# Reformat data
nrows = int(len(idata) / 6)
allVth = list(float(idata[p + 1]) for p in range(0, len(idata), 6))
allVgs = list(float(idata[p + 3]) for p in range(0, len(idata), 6))
allVds = list(float(idata[p + 5]) for p in range(0, len(idata), 6))
# Generate X/Y plots
plt.figure()
for i in range(0, len(allVth), 181 * 10):
Vth = allVth[i : i + 181]
Vgs = allVgs[i : i + 181]
Vds = allVds[i : i + 181]
plt.plot(Vds, Vth)
title = 'SkyWater sky130 PDK ' + version + ' ' + devicename + ' threshold voltage (Vth vs. Vds) at corner ' + corner
plt.title(title)
plt.xlabel('Vds (V)')
plt.ylabel('Vth (V)')
plt.axis('on')
plt.grid('on')
plt.savefig('results/' + devicename + '_vth_v_vds.svg')
plt.figure()
for i in range(0, 181, 18):
Vth = allVth[i : len(allVth): 181]
Vgs = allVgs[i : len(allVgs): 181]
Vds = allVds[i : len(allVds): 181]
plt.plot(Vgs, Vth)
title = 'SkyWater sky130 PDK ' + version + ' ' + devicename + ' threshold voltage (Vth vs. Vgs) at corner ' + corner
plt.title(title)
plt.xlabel('Vgs (V)')
plt.ylabel('Vth (V)')
plt.axis('on')
plt.grid('on')
plt.savefig('results/' + devicename + '_vth_v_vgs.svg')
if __name__ == '__main__':
if len(sys.argv) < 2:
print("No device name given to plot_mosfet_vth")
sys.exit(1)
devicename = sys.argv[1]
make_mosfet_vth_plot(devicename, version, corner)