Removed the various scripts and edits around the sky130.lib.spice file and just included a complete sky130.lib.spice file to replace the original wholesale. This includes a simplication to include a corner file, e.g., corners/tt.spice, instead of including the contents of that file individually; especially since the individual list was missing the 20V nFET and pFET devices.
diff --git a/sky130/Makefile.in b/sky130/Makefile.in index 9c791cf..f2a2c46 100644 --- a/sky130/Makefile.in +++ b/sky130/Makefile.in
@@ -986,10 +986,9 @@ ${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE}/sky130_fd_pr__special_nfet_latch.pm3.spice \ 2>&1 | tee -a ${SKY130A}_make.log || true - # Custom: Make corrections/additions so sky130.lib.spice - ./custom/scripts/build_lib_spice.py \ - ${STAGING_PATH}/${SKY130A}/libs.tech/ngspice/sky130.lib.spice \ - custom/models/sky130.lib.spice.extra \ + # Install custom corrected/enhanced sky130.lib.spice + cp custom/models/sky130.lib.spice \ + ${STAGING_PATH}/${SKY130A}/libs.tech/ngspice \ 2>&1 | tee -a ${SKY130A}_make.log || true # Custom: Add special device ID layers to bipolar layouts in magic # to make the extraction models correct.
diff --git a/sky130/custom/models/sky130.lib.spice b/sky130/custom/models/sky130.lib.spice new file mode 100644 index 0000000..f73a113 --- /dev/null +++ b/sky130/custom/models/sky130.lib.spice
@@ -0,0 +1,358 @@ +* Copyright 2020 The SkyWater PDK Authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* https://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + +******* SkyWater sky130 model library ********* + + +* Typical corner (tt) +.lib tt +.param mc_mm_switch=0 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl tt + +* Slow-Fast corner (sf) +.lib sf +.param mc_mm_switch=0 +.param mc_pr_switch=0 +* MOSFET +.include "corners/sf.spice" +.include "corners/sf/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/sf/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/sf/rf.spice" +.endl sf + +* Fast-Fast corner (ff) +.lib ff +.param mc_mm_switch=0 +.param mc_pr_switch=0 +* MOSFET +.include "corners/ff.spice" +.include "corners/ff/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/ff/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/ff/rf.spice" +.endl ff + +* Slow-Slow corner (ss) +.lib ss +.param mc_mm_switch=0 +.param mc_pr_switch=0 +* MOSFET +.include "corners/ss.spice" +.include "corners/ss/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/ss/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/ss/rf.spice" +.endl ss + +* Fast-Slow corner (fs) +.lib fs +.param mc_mm_switch=0 +.param mc_pr_switch=0 +* MOSFET +.include "corners/fs.spice" +.include "corners/fs/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/fs/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/fs/rf.spice" +.endl fs + +* Low-Low corner (ll) +.lib ll +.param mc_mm_switch=0 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_low__cap_low.spice" +.include "r+c/res_low__cap_low__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl ll + + +* High-High corner (hh) +.lib hh +.param mc_mm_switch=0 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_high__cap_high.spice" +.include "r+c/res_high__cap_high__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl hh + + +* High-Low corner (hl) +.lib hl +.param mc_mm_switch=0 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_high__cap_low.spice" +.include "r+c/res_high__cap_low__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl hl + + +* Low-High corner (lh) +.lib lh +.param mc_mm_switch=0 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_low__cap_high.spice" +.include "r+c/res_low__cap_high__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl lh +* Typical corner with mismatch (tt_mm) +.lib tt_mm +.param mc_mm_switch=1 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl tt_mm + +* Slow-Fast corner with mismatch (sf_mm) +.lib sf_mm +.param mc_mm_switch=1 +.param mc_pr_switch=0 +* MOSFET +.include "corners/sf.spice" +.include "corners/sf/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/sf/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/sf/rf.spice" +.endl sf_mm + +* Fast-Fast corner with mismatch (ff_mm) +.lib ff_mm +.param mc_mm_switch=1 +.param mc_pr_switch=0 +* MOSFET +.include "corners/ff.spice" +.include "corners/ff/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/ff/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/ff/rf.spice" +.endl ff_mm + +* Slow-Slow corner with mismatch (ss_mm) +.lib ss_mm +.param mc_mm_switch=1 +.param mc_pr_switch=0 +* MOSFET +.include "corners/ss.spice" +.include "corners/ss/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/ss/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/ss/rf.spice" +.endl ss_mm + +* Fast-Slow corner with mismatch (fs_mm) +.lib fs_mm +.param mc_mm_switch=1 +.param mc_pr_switch=0 +* MOSFET +.include "corners/fs.spice" +.include "corners/fs/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_typical__cap_typical.spice" +.include "r+c/res_typical__cap_typical__lin.spice" +* Special cells +.include "corners/fs/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/fs/rf.spice" +.endl fs_mm + +* Low-Low corner with mismatch (ll_mm) +.lib ll_mm +.param mc_mm_switch=1 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_low__cap_low.spice" +.include "r+c/res_low__cap_low__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl ll_mm + + +* High-High corner with mismatch (hh_mm) +.lib hh_mm +.param mc_mm_switch=1 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_high__cap_high.spice" +.include "r+c/res_high__cap_high__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl hh_mm + + +* High-Low corner with mismatch (hl_mm) +.lib hl_mm +.param mc_mm_switch=1 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_high__cap_low.spice" +.include "r+c/res_high__cap_low__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl hl_mm + + +* Low-High corner with mismatch (lh_mm) +.lib lh_mm +.param mc_mm_switch=1 +.param mc_pr_switch=0 +* MOSFET +.include "corners/tt.spice" +.include "corners/tt/nonfet.spice" +* Resistor/Capacitor +.include "r+c/res_low__cap_high.spice" +.include "r+c/res_low__cap_high__lin.spice" +* Special cells +.include "corners/tt/specialized_cells.spice" +* All models +.include "all.spice" +* Corner +.include "corners/tt/rf.spice" +.endl lh_mm + + +* Monte Carlo process variation + +.lib mc + +.param mc_mm_switch=0 +.param mc_pr_switch=1 + +.include "parameters/critical.spice" +.include "parameters/montecarlo.spice" + +.endl mc
diff --git a/sky130/custom/models/sky130.lib.spice.extra b/sky130/custom/models/sky130.lib.spice.extra deleted file mode 100644 index 390366c..0000000 --- a/sky130/custom/models/sky130.lib.spice.extra +++ /dev/null
@@ -1,11 +0,0 @@ -* Monte Carlo process variation - -.lib mc - -.param mc_mm_switch=0 -.param mc_pr_switch=1 - -.include "parameters/critical.spice" -.include "parameters/montecarlo.spice" - -.endl mc
diff --git a/sky130/custom/scripts/build_lib_spice.py b/sky130/custom/scripts/build_lib_spice.py deleted file mode 100755 index df19d68..0000000 --- a/sky130/custom/scripts/build_lib_spice.py +++ /dev/null
@@ -1,99 +0,0 @@ -#!/usr/bin/env python3 -# -#----------------------------------------------------------------------- -# build_lib_spice.py --- -# -# Generate a complete "sky130.lib.spice" file given: -# (1) The name of the original file -# (2) The name of an addendum file. -# -# The tasks done by this script are: -# (1) Add "mc_pr_switch" and "mc_mm_switch" parameters to each -# section -# (2) Duplicate the entire set of sections and rename each section -# in the new set with "_mm" and set "mc_mm_switch" to 1 in those -# sections. -# (3) Add the addendum file to the bottom -# (4) Add the name of each section after the ".endl" line, for Xyce -# compatibility. -# -#----------------------------------------------------------------------- -# -# Usage: -# -# build_lib_spice.py <lib_spice_file> <addendum_file> -# -# The output will replace <lib_spice_file> with the modified version. - -import os -import re -import sys - -if len(sys.argv) != 3: - print('Usage: build_lib_spice.py <lib_spice_file> <addendum_file>') - sys.exit(1) - -inputfile = sys.argv[1] -addendumfile = sys.argv[2] - -cornerrex = re.compile('.*\((.*)\)') - -with open(inputfile, 'r') as ifile: - spicelines = ifile.read().splitlines() - -with open(addendumfile, 'r') as ifile: - addlines = ifile.read().splitlines() - -# The header is the first 16 lines (copyright notice) -header = spicelines[0:16] -spicelines = spicelines[16:] - -# After each ".lib", add the monte carlo parameters -# Add the name of the corner after ".endl" - -newlines = [] -for line in spicelines: - if line.startswith('.lib'): - corner = line.split()[1] - newlines.append(line) - newlines.append('.param mc_mm_switch=0') - newlines.append('.param mc_pr_switch=0') - elif line.startswith('.endl'): - newlines.append(line + ' ' + corner) - else: - newlines.append(line) - -# Duplicate all sections with mismatch analysis versions - -altlines = [] -for line in spicelines: - cmatch = cornerrex.match(line) - if cmatch: - corner = cmatch.group(1) - newline = re.sub(corner, corner + '_mm', line) - newline = re.sub('\(', 'with mismatch (', newline) - newlines.append(newline) - elif line.startswith('.lib'): - corner = line.split()[1] - newlines.append(line + '_mm') - newlines.append('.param mc_mm_switch=1') - newlines.append('.param mc_pr_switch=0') - elif line.startswith('.endl'): - newlines.append(line + ' ' + corner + '_mm') - else: - newlines.append(line) - -# Now overwrite the original file. -with open(inputfile, 'w') as ofile: - for line in header: - print(line, file=ofile) - print('', file=ofile) - for line in newlines: - print(line, file=ofile) - print('', file=ofile) - for line in altlines: - print(line, file=ofile) - print('', file=ofile) - for line in addlines: - print(line, file=ofile) -