Modified a number of custom scripts (and corresponding calls to the scripts in the sky130 Makefile) to do the following: (1) Revert the change to use the "tempfile" library because this just causes an additional error when the /tmp directory is not in the same filesystem as the staging area (especially as the original method was working fine except for problem #2), and (2) Fix a number of custom scripts to use the correct path to either sky130A or sky130B depending, when needed, on an option passed to the script. Standalone scripts need the option; filter scripts can divine the name of the PDK from the target path.
diff --git a/common/foundry_install.py b/common/foundry_install.py index 9a4625e..a9493ef 100755 --- a/common/foundry_install.py +++ b/common/foundry_install.py
@@ -415,10 +415,9 @@ # Make sure this file is writable (as the original may not be) makeuserwritable(outfile) + arguments = [filterscript, targetroot, outfile] if ef_format: - arguments = [filterscript, targetroot, outfile, '-ef_format'] - else: - arguments = [filterscript, targetroot, outfile] + arguments.append('-ef_format') subprocess_run('filter', arguments)
diff --git a/sky130/Makefile.in b/sky130/Makefile.in index db8e314..8d25736 100644 --- a/sky130/Makefile.in +++ b/sky130/Makefile.in
@@ -711,10 +711,13 @@ fi cp -rp custom/scripts/seal_ring_generator ${MAGIC_STAGING_$*}/. cp -rp custom/scripts/bump_bond_generator ${MAGIC_STAGING_$*}/. - cp custom/scripts/generate_fill.py ${MAGIC_STAGING_$*}/. - cp custom/scripts/check_density.py ${MAGIC_STAGING_$*}/. cp custom/scripts/run_standard_drc.py ${MAGIC_STAGING_$*}/. - cp custom/scripts/check_antenna.py ${MAGIC_STAGING_$*}/. + ${CPP} ${SKY130$*_DEFS} custom/scripts/generate_fill.py \ + ${MAGIC_STAGING_$*}/generate_fill.py + ${CPP} ${SKY130$*_DEFS} custom/scripts/check_density.py \ + ${MAGIC_STAGING_$*}/check_density.py + ${CPP} ${SKY130$*_DEFS} custom/scripts/check_antenna.py \ + ${MAGIC_STAGING_$*}/check_antenna.py ${CPP} ${SKY130$*_DEFS} magic/${TECH}.tech ${MAGIC_STAGING_$*}/${SKY130$*}.tech ${CPP} ${SKY130$*_DEFS} magic/${TECH}gds.tech ${MAGIC_STAGING_$*}/${SKY130$*}-GDS.tech ${CPP} ${SKY130$*_DEFS} magic/${TECH}.magicrc ${MAGIC_STAGING_$*}/${SKY130$*}.magicrc @@ -1129,14 +1132,14 @@ 2>&1 | tee -a ${SKY130$*}_make.log || true # Custom: Parse the (commented out) statistics blocks and generate # ngspice-compatible monte carlo parameters for mismatch and process - ./custom/scripts/mismatch_params.py ${EF_FORMAT} \ + ./custom/scripts/mismatch_params.py ${EF_FORMAT} -variant=${SKY130$*} \ 2>&1 | tee -a ${SKY130$*}_make.log || true - ./custom/scripts/mismatch_params.py ${EF_FORMAT} \ + ./custom/scripts/mismatch_params.py \ ${STAGING_PATH}/${SKY130$*}/libs.tech/ngspice \ 2>&1 | tee -a ${SKY130$*}_make.log || true - ./custom/scripts/process_params.py \ + ./custom/scripts/process_params.py ${EF_FORMAT} -variant=${SKY130$*} \ 2>&1 | tee -a ${SKY130$*}_make.log || true - ./custom/scripts/montecarlo_hack.py \ + ./custom/scripts/montecarlo_hack.py -variant=${SKY130$*} \ 2>&1 | tee -a ${SKY130$*}_make.log || true # Custom: Change vt to local_vt in one file for Xyce compatibilty ./custom/scripts/xyce_hack.py \ @@ -1159,7 +1162,7 @@ 2>&1 | tee -a ${SKY130$*}_make.log || true # Custom: Add special device ID layers to bipolar layouts in magic # to make the extraction models correct. - ./custom/scripts/add_bipolar_ids.py ${EF_FORMAT} \ + ./custom/scripts/add_bipolar_ids.py ${EF_FORMAT} -variant=${SKY130$*} \ 2>&1 | tee -a ${SKY130$*}_make.log || true # Custom: Add "spinit" file
diff --git a/sky130/custom/scripts/add_bipolar_ids.py b/sky130/custom/scripts/add_bipolar_ids.py index 611cc71..73e991b 100755 --- a/sky130/custom/scripts/add_bipolar_ids.py +++ b/sky130/custom/scripts/add_bipolar_ids.py
@@ -10,7 +10,6 @@ import os import re import sys -import tempfile options = [] arguments = [] @@ -20,10 +19,17 @@ else: arguments.append(item) -magpath = 'sky130A/libs.ref/sky130_fd_pr/mag' +variant = 'sky130A' +magpath = variant + '/libs.ref/sky130_fd_pr/mag' + if len(options) > 0: - if options[0] == 'ef_format': - magpath = 'sky130A/libs.ref/mag/sky130_fd_pr' + for option in options: + if option.startswith('variant'): + variant = option.split('=')[1] + magpath = variant + '/libs.ref/sky130_fd_pr/mag' + for option in options: + if option == 'ef_format': + magpath = variant + '/libs.ref/mag/sky130_fd_pr' elif len(arguments) > 0: magpath = arguments[0] @@ -51,6 +57,7 @@ for idx, device in enumerate(devlist): infile_name = magpath + '/' + device + '.mag' + outfile_name = magpath + '/' + device + '_temp.mag' if not os.path.exists(infile_name): print('Error: Cannot find file ' + infile_name) @@ -61,8 +68,7 @@ type = typelist[idx] is_baserect = False infile = open(infile_name, 'r') - handle, outfile_name = tempfile.mkstemp() - outfile = os.fdopen(handle, 'w') + outfile = open(outfile_name, 'w') line_number = 0 replaced_something = False
diff --git a/sky130/custom/scripts/check_antenna.py b/sky130/custom/scripts/check_antenna.py index 031fa5e..e7eb89f 100755 --- a/sky130/custom/scripts/check_antenna.py +++ b/sky130/custom/scripts/check_antenna.py
@@ -53,8 +53,8 @@ myenv = os.environ.copy() myenv['MAGTYPE'] = 'mag' - if os.path.isfile('/usr/share/pdk/sky130A/libs.tech/magic/sky130A.magicrc'): - rcfile = '/usr/share/pdk/sky130A/libs.tech/magic/sky130A.magicrc' + if os.path.isfile('/usr/share/pdk/TECHNAME/libs.tech/magic/TECHNAME.magicrc'): + rcfile = '/usr/share/pdk/TECHNAME/libs.tech/magic/TECHNAME.magicrc' elif os.path.isfile(magpath + '/.magicrc'): rcfile = magpath + '/.magicrc' elif os.path.isfile(os.getcwd() + '/.magicrc'):
diff --git a/sky130/custom/scripts/check_density.py b/sky130/custom/scripts/check_density.py index f439355..7e540eb 100755 --- a/sky130/custom/scripts/check_density.py +++ b/sky130/custom/scripts/check_density.py
@@ -95,7 +95,7 @@ # Searching for rcfile - rcfile_paths=[gdspath+'/.magicrc','/$PDK_PATH/libs.tech/magic/sky130A.magicrc','/usr/share/pdk/sky130A/libs.tech/magic/sky130A.magicrc'] + rcfile_paths=[gdspath+'/.magicrc','/$PDK_PATH/libs.tech/magic/TECHNAME.magicrc','/usr/share/pdk/TECHNAME/libs.tech/magic/TECHNAME.magicrc'] rcfile=''
diff --git a/sky130/custom/scripts/fix_spice_includes.py b/sky130/custom/scripts/fix_spice_includes.py index 8469057..f70079b 100755 --- a/sky130/custom/scripts/fix_spice_includes.py +++ b/sky130/custom/scripts/fix_spice_includes.py
@@ -11,7 +11,6 @@ import os import re import sys -import tempfile newdevs = [] newdevs.append('sky130_fd_pr__pnp_05v5_W3p40L3p40') @@ -39,10 +38,10 @@ filepath = os.path.split(infile_name)[0] filename = os.path.split(infile_name)[1] fileroot = os.path.split(filename)[0] + outfile_name = os.path.join(filepath, fileroot + '_temp') infile = open(infile_name, 'r') - handle, outfile_name = tempfile.mkstemp() - outfile = os.fdopen(handle, 'w') + outfile = open(outfile_name, 'w') line_number = 0 replaced_something = False
diff --git a/sky130/custom/scripts/generate_fill.py b/sky130/custom/scripts/generate_fill.py index 08209b3..38ecc39 100755 --- a/sky130/custom/scripts/generate_fill.py +++ b/sky130/custom/scripts/generate_fill.py
@@ -119,7 +119,7 @@ # Searching for rcfile - rcfile_paths=[magpath+'/.magicrc','/$PDK_PATH/libs.tech/magic/sky130A.magicrc','/usr/share/pdk/sky130A/libs.tech/magic/sky130A.magicrc'] + rcfile_paths=[magpath+'/.magicrc','/$PDK_PATH/libs.tech/magic/TECHNAME.magicrc','/usr/share/pdk/TECHNAME/libs.tech/magic/TECHNAME.magicrc'] rcfile=''
diff --git a/sky130/custom/scripts/mismatch_params.py b/sky130/custom/scripts/mismatch_params.py index c8a8fef..0053542 100755 --- a/sky130/custom/scripts/mismatch_params.py +++ b/sky130/custom/scripts/mismatch_params.py
@@ -9,7 +9,6 @@ import os import re import sys -import tempfile mm_switch_param = 'MC_MM_SWITCH' @@ -21,11 +20,17 @@ else: arguments.append(item) -walkpath = 'sky130A/libs.ref/sky130_fd_pr/spice' +variant = 'sky130A' +walkpath = variant + '/libs.tech/ngspice' if len(options) > 0: - if options[0] == 'ef_format': - walkpath = 'sky130A/libs.ref/spi/sky130_fd_pr' + for option in options: + if option.startswith('variant'): + variant = option.split('=')[1] + walkpath = variant + '/libs.ref/sky130_fd_pr/spice' + for option in options: + if option == 'ef_format': + walkpath = variant + '/libs.ref/spi/sky130_fd_pr' elif len(arguments) > 0: walkpath = arguments[0] @@ -96,10 +101,10 @@ filepath = os.path.split(infile_name)[0] filename = os.path.split(infile_name)[1] fileroot = os.path.splitext(filename)[0] + outfile_name = os.path.join(filepath, fileroot + '_temp') infile = open(infile_name, 'r') - handle, outfile_name = tempfile.mkstemp() - outfile = os.fdopen(handle, 'w') + outfile = open(outfile_name, 'w') state = 'before_mismatch' line_number = 0
diff --git a/sky130/custom/scripts/montecarlo_hack.py b/sky130/custom/scripts/montecarlo_hack.py index 81a47aa..cff5576 100755 --- a/sky130/custom/scripts/montecarlo_hack.py +++ b/sky130/custom/scripts/montecarlo_hack.py
@@ -11,14 +11,28 @@ import os import re import sys -import tempfile -searchpath = ['sky130A/libs.tech/ngspice/parameters/critical.spice', - 'sky130A/libs.tech/ngspice/parameters/montecarlo.spice'] +options = [] +arguments = [] +for item in sys.argv[1:]: + if item.find('-', 0) == 0: + options.append(item[1:]) + else: + arguments.append(item) -if len(sys.argv) > 1: +variant = 'sky130A' + +if len(options) > 0: + for option in options: + if option.startswith('variant'): + variant = option.split('=')[1] + searchpath = [variant + '/libs.tech/ngspice/parameters/critical.spice', + variant + '/libs.tech/ngspice/parameters/montecarlo.spice'] + +elif len(arguments) > 0: searchpath = sys.argv[1] + # Flag all parameters that have the same name as devices. # These parameters are unused and must be deleted. @@ -55,10 +69,10 @@ filepath = os.path.split(infile_name)[0] filename = os.path.split(infile_name)[1] fileroot = os.path.splitext(filename)[0] + outfile_name = os.path.join(filepath, fileroot + '_temp') infile = open(infile_name, 'r') - handle, outfile_name = tempfile.mkstemp() - outfile = osfdopen(handle, 'w') + outfile = open(outfile_name, 'w') line_number = 0 replaced_something = False
diff --git a/sky130/custom/scripts/process_params.py b/sky130/custom/scripts/process_params.py index 657a635..c27840a 100755 --- a/sky130/custom/scripts/process_params.py +++ b/sky130/custom/scripts/process_params.py
@@ -9,14 +9,30 @@ import os import re import sys -import tempfile pr_switch_param = 'MC_PR_SWITCH' -walkpath = 'sky130A/libs.tech/ngspice' +options = [] +arguments = [] +for item in sys.argv[1:]: + if item.find('-', 0) == 0: + options.append(item[1:]) + else: + arguments.append(item) -if len(sys.argv) > 1: - walkpath = sys.argv[1] +variant = 'sky130A' +walkpath = variant + '/libs.ref/sky130_fd_pr/spice' + +if len(options) > 0: + for option in options: + if option.startswith('variant'): + variant = option.split('=')[1] + walkpath = variant + '/libs.ref/sky130_fd_pr/spice' + for option in options: + if option == 'ef_format': + walkpath = variant + '/libs.ref/spi/sky130_fd_pr' +elif len(arguments) > 0: + walkpath = arguments[0] process_params = [] @@ -87,10 +103,10 @@ filepath = os.path.split(infile_name)[0] filename = os.path.split(infile_name)[1] fileroot = os.path.splitext(filename)[0] + outfile_name = os.path.join(filepath, fileroot + '_temp') infile = open(infile_name, 'r') - handle, outfile_name = tempfile.mkstemp() - outfile = os.fdopen(handle, 'w') + outfile = open(outfile_name, 'w') state = 'before_process' line_number = 0
diff --git a/sky130/custom/scripts/text2m5.py b/sky130/custom/scripts/text2m5.py index e91bc21..8351b00 100755 --- a/sky130/custom/scripts/text2m5.py +++ b/sky130/custom/scripts/text2m5.py
@@ -25,6 +25,10 @@ print('text2m5.py: failed to open ' + inname + ' for reading.', file=sys.stderr) return 1 + # The library is based on sky130A only. Pick up the name of the PDK variant + # from the input name (which is four directory levels up from inname) + variant = inname.split('/')[-5] + # Process input with regexp fixedlines = [] @@ -34,7 +38,7 @@ # These substitutions are for files originating from cells/*/*.spice fixedline = re.sub('<< metal1 >>', '<< metal5 >>', line) - fixedline = re.sub('tech sky130A', 'tech sky130A\nmagscale 12 1', fixedline) + fixedline = re.sub('tech sky130A', 'tech ' + variant + '\nmagscale 12 1', fixedline) fixedlines.append(fixedline) if fixedline != line:
diff --git a/sky130/custom/scripts/xyce_hack.py b/sky130/custom/scripts/xyce_hack.py index 6fcc914..ecedb7d 100755 --- a/sky130/custom/scripts/xyce_hack.py +++ b/sky130/custom/scripts/xyce_hack.py
@@ -12,7 +12,6 @@ import os import re import sys -import tempfile if len(sys.argv) <= 1: print('Usage: xyce_hack.py <path_to_file>') @@ -24,10 +23,10 @@ filepath = os.path.split(infile_name)[0] filename = os.path.split(infile_name)[1] fileroot = os.path.splitext(filename)[0] + outfile_name = os.path.join(filepath, fileroot + '_temp') infile = open(infile_name, 'r') - handle, outfile_name = tempfile.mkstemp() - outfile = os.fdopen(handle, 'w') + outfile = open(outfile_name, 'w') line_number = 0 replaced_something = False
diff --git a/sky130/custom/scripts/xyce_hack2.py b/sky130/custom/scripts/xyce_hack2.py index 9442ad5..9308dad 100755 --- a/sky130/custom/scripts/xyce_hack2.py +++ b/sky130/custom/scripts/xyce_hack2.py
@@ -10,7 +10,6 @@ import os import re import sys -import tempfile plist = ["ldif", "hdif", "rd", "rs", "rsc", "rdc", "nqsmod"] regexps = [] @@ -27,10 +26,10 @@ filepath = os.path.split(infile_name)[0] filename = os.path.split(infile_name)[1] fileroot = os.path.splitext(filename)[0] + outfile_name = os.path.join(filepath, fileroot + '_temp') infile = open(infile_name, 'r') - handle, outfile_name = tempfile.mkstemp() - outfile = os.fdopen(handle, 'w') + outfile = open(outfile_name, 'w') line_number = 0 replaced_something = False