Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generator for bin based plots for FETs #237

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3f11b65
Added initial script for generating plots from FET simulator
glatosinski Nov 10, 2020
508c21f
Added script for generating nfet and pfet plots from libraries directory
glatosinski Nov 11, 2020
5ea3ea9
Added grid to plots
glatosinski Nov 12, 2020
414b809
Added closing plots after saving to file
glatosinski Nov 12, 2020
3e57ce2
Comment out not working fet
glatosinski Nov 12, 2020
c64020c
FET simulator code cleanup
glatosinski Nov 12, 2020
2aed534
Added ngspice to environment.yml and PySpice to requirements.txt
glatosinski Nov 16, 2020
ee63e6c
Added grouping FET plots by W
glatosinski Nov 16, 2020
c8b18d8
Changed extension for FET plots from PNG to SVG
glatosinski Nov 16, 2020
f177fa7
Wrapped script in main function
glatosinski Nov 16, 2020
222572a
Added fetching FETs by regular expression
glatosinski Nov 17, 2020
7c4d2fa
Added proper closing of plots
glatosinski Nov 17, 2020
3f0a64b
Fixed directory generation
glatosinski Nov 18, 2020
1c0eeda
Added releasing memory after plotting the FET graphs
glatosinski Nov 18, 2020
6709fdf
Added not failing on invalid bins.csv file
glatosinski Nov 18, 2020
7f0f405
Added notification on successful finish of the script
glatosinski Nov 18, 2020
8d734f0
fet_simulator: added docstrings
glatosinski Nov 24, 2020
d760ac4
fet_simulator: moved fet modules to simulation/analog
glatosinski Nov 25, 2020
77bad0d
fet_simulator: used more elaborate variable names
glatosinski Nov 25, 2020
ee006e4
base: added method for parsing bins.csv files
glatosinski Nov 25, 2020
a4f7529
fet: added using bins.csv parser from skywater_pdk.base
glatosinski Nov 25, 2020
a512ddf
fet: added docstrings for modules
glatosinski Nov 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added fetching FETs by regular expression
Signed-off-by: Grzegorz Latosinski <glatosinski@antmicro.com>
  • Loading branch information
glatosinski committed Nov 25, 2020
commit 222572af4d5311dad32d03dc8cfcd6f8c7ac1585
Original file line number Diff line number Diff line change
Expand Up @@ -108,32 +108,35 @@ def read_bins(fname):


def generate_fet_plots(
fet_type,
corner_path,
bins_csv,
outdir,
outprefix,
only_W=None,
ext='svg'):
print(f'[generate_fet_plots] {fet_type} {corner_path} {bins_csv}' +
print(f'[generate_fet_plots] {corner_path} {bins_csv}' +
f'{outdir} {outprefix} {only_W}')
iparam = f'@m.xm1.m{fet_type}[%s]'
# fet_W and fet_L values here are only for initialization, they are
# later changed in the for loop
c = create_test_circuit(fet_type, iparam, 0.15, 1, corner_path)

bins = read_bins(bins_csv)

bins_by_W = defaultdict(list)
# group bins by W
for line in bins:
bins_by_W[line[2]].append(line)
bins_by_W[(line[0], float(line[2]))].append(line)

Ws = only_W if only_W is not None else list(bins_by_W.keys())
Ws = [key for key in bins_by_W.keys() if only_W is None or key[1] in only_W]

for fet_type, W in Ws:
if outprefix is None:
outprefix = fet_type
print(f'======> {fet_type}: {W}')
iparam = f'@m.xm1.m{fet_type}[%s]'
# fet_W and fet_L values here are only for initialization, they are
# later changed in the for loop
c = create_test_circuit(fet_type, iparam, 0.15, 1, corner_path)

for W in Ws:
figs, plts = init_plots(fet_type, W)
for dev, bin, fet_W, fet_L in bins_by_W[W]:
for dev, bin, fet_W, fet_L in bins_by_W[(fet_type, W)]:
fet_W, fet_L = float(fet_W), float(fet_L)
if only_W is not None and fet_W not in only_W:
continue
Expand All @@ -151,7 +154,7 @@ def generate_fet_plots(
fg.tight_layout()
fg.savefig(
Path(outdir) / (
outprefix + f'_{name}_W{str(W).replace(".", "_")}.{ext}'),
outprefix + f'_{fet_type}_{name}_W{str(W).replace(".", "_")}.{ext}'),
bbox_extra_artists=(lg,),
bbox_inches='tight'
)
Expand All @@ -162,10 +165,6 @@ def main(argv):
import argparse

parser = argparse.ArgumentParser(prog=argv[0])
parser.add_argument(
'fet_type',
help='FET type to simulate'
)
parser.add_argument(
'corner_path',
help='Path to corner SPICE file containing FET definition',
Expand Down Expand Up @@ -198,11 +197,7 @@ def main(argv):
)
args = parser.parse_args(argv[1:])

if args.outprefix is None:
args.outprefix = args.fet_type

generate_fet_plots(
args.fet_type,
args.corner_path,
args.bins_csv,
args.outdir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,58 +20,91 @@
import argparse
from pathlib import Path
import sys
import contextlib
import traceback

from fet_simulator import generate_fet_plots

glatosinski marked this conversation as resolved.
Show resolved Hide resolved

def main(argv):
parser = argparse.ArgumentParser(prog=argv[0])
parser.add_argument(
'fd_pr_dir',
help='Path to the particular version of the primitive library',
'libraries_dir',
help='Path to the libraries directory of skywater-pdk',
type=Path
)
parser.add_argument(
'device_details_dir',
help='Path to the directory with device details to save images to',
'corner_file',
help='Path to the corner SPICE file',
type=Path
)
parser.add_argument(
'output_dir',
help='Path to the output directory',
type=Path
)
parser.add_argument(
'--libname',
help='Library name to generate the Symbolator diagrams for',
type=str
)
parser.add_argument(
'--version',
help='Version for which the Symbolator diagrams should be generated',
type=str
)
parser.add_argument(
'--create-dirs',
help='Create directories for output when not present',
action='store_true'
)
parser.add_argument(
'--failed-inputs',
help='Path to files for which Symbolator failed to generate diagram',
type=Path
)

args = parser.parse_args(argv[1:])

typicalcorner = args.fd_pr_dir / 'models/corners/tt.spice'
fetbins = list(args.libraries_dir.rglob('*fet*bins.csv'))

nc = contextlib.nullcontext()

with open(args.failed_inputs, 'w') if args.failed_inputs else nc as err:
for fetbin in fetbins:
outdir = (args.output_dir /
fetbin.resolve()
.relative_to(args.libraries_dir.resolve()))
if args.libname and args.libname != outdir.parts[0]:
continue
if args.version and args.version != outdir.parts[1]:
continue
print(f'===> {str(fetbin)}')
try:
if not outdir.exists():
if args.create_dirs:
outdir.mkdir(parents=True)
else:
print('The output directory {str(outdir)} is missing')
print('Run the script with --create-dirs')
return errno.ENOENT

fets = [
['esd_nfet', 'esd_nfet_01v8', None],
['nfet_01v8', 'nfet_01v8', None],
['nfet_01v8_lvt', 'nfet_01v8_lvt', None],
['nfet_03v3_nvt', 'nfet_03v3_nvt', None],
['nfet_03v3_nvt-and-nfet_05v0_nvt', 'nfet_05v0_nvt', None],
['nfet_03v3_nvt-and-nfet_05v0_nvt', 'nfet_03v3_nvt', None],
['nfet_05v0_nvt', 'nfet_05v0_nvt', None],
# ['nfet_20v0'], TODO provide
# ['nfet_20v0_iso', 'nfet_20v0_nvt_iso', None], TODO invalid bins.csv
# ['nfet_20v0_nvt', 'nfet_20v0_nvt', None], TODO invalid bins.csv file
# ['nfet_20v0_zvt', 'nfet_20v0_zvt', None], TODO invalid bins.csv file
# ['nfet_g11v0d16v0'], TODO provide
['nfet_g5v0d10v5', 'nfet_g5v0d10v5', None],
['pfet_01v8', 'pfet_01v8', None],
['pfet_01v8_hvt', 'pfet_01v8_hvt', None],
['pfet_01v8_lvt', 'pfet_01v8_lvt', None],
# ['pfet_20v0', 'pfet_20v0', None], TODO some plot issues
['pfet_g5v0d10v5', 'pfet_g5v0d10v5', None],
# ['pfet_g5v0d16v0', 'pfet_g5v0d16v0', None] TODO invalid bins.csv file
]
prefix = fetbin.name.replace('.bins.csv', '')
generate_fet_plots(
args.corner_file,
fetbin,
outdir,
f'{prefix}_',
ext='sim.svg'
)
except Exception:
print(
f'Failed to generate FET plot for {str(fetbin)}',
file=sys.stderr
)
traceback.print_exc()
err.write(f'{fetbin}\n')

for outdir, fetname, onlyw in fets:
generate_fet_plots(
f'sky130_fd_pr__{fetname}',
typicalcorner,
args.fd_pr_dir/f'cells/{fetname}/sky130_fd_pr__{fetname}.bins.csv',
args.device_details_dir/outdir,
f'sim_{fetname}_',
onlyw
)
return 0


Expand Down