A number of changes, mostly to the SPICE libraries and netlists in support
of Xyce (without compromising support for ngspice).  Also:  Additional Monte
Carlo parameters were found in PSPICE format in the models and have been
converted to something ngspice-compatible.  The 11V NPN GDS cell name was
changed to allow correct extraction from magic and prevent shadowing the
model name.  The Monte Carlo switch parameter behavior was changed again to
make a separate set of library sections for mismatch-enabled corners vs.
the original corners, which have been configured to have mismatch disabled.
This avoids any requirement to add a parameter definition to every testbench
for sky130.  Xyce compatibility includes changing '$' comments to ';', which
is also ngspice compatible, and adding the library section name after '.endl',
which is also ngspice-compatible.  Complete Xyce support requires a change
to the all.spice file and calls to function agauss(), the solution to which
has not yet been determined.
diff --git a/VERSION b/VERSION
index 81e489d..c9131ed 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.174
+1.0.176
diff --git a/common/change_gds_string.py b/common/change_gds_string.py
old mode 100644
new mode 100755
diff --git a/sky130/Makefile.in b/sky130/Makefile.in
index 847ccb9..ace3f01 100644
--- a/sky130/Makefile.in
+++ b/sky130/Makefile.in
@@ -764,7 +764,7 @@
 	# Install base device library from vendor files
 	${STAGE} -source ${SKYWATER_LIBS_PATH} -target ${STAGING_PATH}/${SKY130A} \
 		-gds %l/latest/cells/*/*.gds \
-			exclude=sky130_fd_pr__pnp_05v5_W3p40L3p40.gds \
+			exclude=sky130_fd_pr__pnp_05v5_W3p40L3p40.gds,sky130_fd_pr__npn_11v0_W1p00L1p00.gds \
 			compile-only \
 			options=custom/scripts/gds_import_setup.tcl \
 		-cdl %l/latest/cells/*/*.cdl compile-only \
@@ -813,14 +813,15 @@
 		2>&1 | tee -a ${SKY130A}_make.log || true
 	./custom/scripts/montecarlo_hack.py \
 		2>&1 | tee -a ${SKY130A}_make.log || true
-	# Custom:  Add "mc" section to sky130.lib.spice
-	head -n-1 ${STAGING_PATH}/${SKY130A}/libs.tech/ngspice/sky130.lib.spice \
-		| ${SED} -e '/^\.lib/a.param mc_pr_switch=0' \
-		> ${STAGING_PATH}/${SKY130A}/libs.tech/ngspice/sky130.lib.spice.head
-	cat ${STAGING_PATH}/${SKY130A}/libs.tech/ngspice/sky130.lib.spice.head \
-		custom/models/sky130.lib.spice.extra > \
-		${STAGING_PATH}/${SKY130A}/libs.tech/ngspice/sky130.lib.spice
-	rm ${STAGING_PATH}/${SKY130A}/libs.tech/ngspice/sky130.lib.spice.head
+	# Custom:  Change vt to local_vt in one file for Xyce compatibilty
+	./custom/scripts/xyce_hack.py \
+		${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE}/sky130_fd_pr__res_iso_pw.model.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 \
+		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.
 	./custom/scripts/add_bipolar_ids.py \
diff --git a/sky130/custom/models/sky130.lib.spice.extra b/sky130/custom/models/sky130.lib.spice.extra
index e97075f..390366c 100644
--- a/sky130/custom/models/sky130.lib.spice.extra
+++ b/sky130/custom/models/sky130.lib.spice.extra
@@ -1,4 +1,3 @@
-
 * Monte Carlo process variation
 
 .lib mc
@@ -9,4 +8,4 @@
 .include "parameters/critical.spice"
 .include "parameters/montecarlo.spice"
 
-.endl
+.endl mc
diff --git a/sky130/custom/scripts/build_lib_spice.py b/sky130/custom/scripts/build_lib_spice.py
new file mode 100755
index 0000000..df19d68
--- /dev/null
+++ b/sky130/custom/scripts/build_lib_spice.py
@@ -0,0 +1,99 @@
+#!/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)
+
diff --git a/sky130/custom/scripts/mismatch_params.py b/sky130/custom/scripts/mismatch_params.py
index eda8462..b6616d7 100755
--- a/sky130/custom/scripts/mismatch_params.py
+++ b/sky130/custom/scripts/mismatch_params.py
@@ -69,6 +69,13 @@
 print('') 
 
 #--------------------------------------------------------------------
+# Create regexp for the alternative PSPICE "dev/gauss" syntax used in
+# a number of places in the models.
+#--------------------------------------------------------------------
+
+gaussrex = re.compile('\'[ \t]+dev\/gauss=\'', re.IGNORECASE)
+
+#--------------------------------------------------------------------
 # Step 2.  Make replacements
 #--------------------------------------------------------------------
 
@@ -86,19 +93,25 @@
 
     for line in infile:
         line_number += 1
+        newline = line
+
+        gmatch = gaussrex.search(newline)
+        if gmatch:
+            newline = gaussrex.sub('+' + mm_switch_param + '*AGAUSS(0,1.0,1)*', newline)
+            replaced_something = True
+            print("  Line {}: Found PSPICE dev/gauss and replaced.".format(line_number))
 
         if state == 'before_mismatch':
-            outfile.write(line)
-            mmatch = mmrex.match(line)
+            outfile.write(newline)
+            mmatch = mmrex.match(newline)
             if mmatch:
                 state = 'in_mismatch'
         elif state == 'in_mismatch':
-            outfile.write(line)
-            ematch = endrex.match(line)
+            outfile.write(newline)
+            ematch = endrex.match(newline)
             if ematch:
                 state = 'after_mismatch'
         elif state == 'after_mismatch':
-            newline = line
             for (param, replacement) in mismatch_params:
                 if param in newline:
                     newline = newline.replace(param, replacement)
diff --git a/sky130/custom/scripts/rename_cells.py b/sky130/custom/scripts/rename_cells.py
index 5692c41..b288a25 100755
--- a/sky130/custom/scripts/rename_cells.py
+++ b/sky130/custom/scripts/rename_cells.py
@@ -36,6 +36,14 @@
         fixedline = re.sub('\.\./\.\./models/', '../../../libs.tech/ngspice/', line)
         fixedline = re.sub('\.\./[^/\.]+/', '', fixedline)
 
+        # This substitution fixes a single error in the file
+        # sky130_fd_pr__nfet_05v0_nvt.pm3.spice
+        fixedline = re.sub('^include.*', '', fixedline)
+
+        # This subsitution makes SPICE files compatible with Xyce without
+        # breaking ngspice compatibility ('$' comments changed to ';')
+        fixedline = re.sub('(.*[ \t]+)\$([ \t+].*)', '\g<1>;\g<2>', fixedline)
+
         fixedlines.append(fixedline)
         if fixedline != line:
             modified = True
diff --git a/sky130/custom/scripts/rename_models.py b/sky130/custom/scripts/rename_models.py
index 1eea3dc..80e153c 100755
--- a/sky130/custom/scripts/rename_models.py
+++ b/sky130/custom/scripts/rename_models.py
@@ -34,6 +34,11 @@
 
         # Fix: Replace "../cells/<name>/" with "../../libs.ref/sky130_fd_pr/spice/"
         fixedline = re.sub('\.\./cells/[^/]+/', '../../libs.ref/sky130_fd_pr/spice/', line)
+
+        # This subsitution makes SPICE files compatible with Xyce without
+        # breaking ngspice compatibility ('$' comments changed to ';')
+        fixedline = re.sub('(.*[ \t]+)\$([ \t+].*)', '\g<1>;\g<2>', fixedline)
+
         fixedlines.append(fixedline)
         if fixedline != line:
             modified = True
diff --git a/sky130/custom/scripts/xyce_hack.py b/sky130/custom/scripts/xyce_hack.py
new file mode 100755
index 0000000..480e3ae
--- /dev/null
+++ b/sky130/custom/scripts/xyce_hack.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+#
+#--------------------------------------------------------------------
+# Workaround for the problem that xyce does not like having "vt"
+# as a subcircuit parameter name, because it is a xyce reserved
+# name.  Change the parameter name in the one file that uses it.
+# This script is not robust, and depends on the fact that the
+# one file that declares "vt" does not have any corner model files,
+# and the characters "vt" do not appear in any other context.
+#--------------------------------------------------------------------
+
+import os
+import re
+import sys
+
+if len(sys.argv) <= 1:
+    print('Usage: xyce_hack.py <path_to_file>')
+    sys.exit(1)
+
+else:
+    infile_name = sys.argv[1]
+
+    filepath = os.path.split(infile_name)[0]
+    outfile_name = os.path.join(filepath, 'temp')
+
+    infile = open(infile_name, 'r')
+    outfile = open(outfile_name, 'w')
+
+    line_number = 0
+    replaced_something = False
+    for line in infile:
+        line_number += 1
+
+        if 'vt' in line:
+            newline = re.sub('vt', 'local_vt', line)
+            replaced_something = True
+        else:
+            newline = line
+
+        outfile.write(newline)
+
+    infile.close()
+    outfile.close()
+    if replaced_something:
+        print("Something was replaced in '{}'".format(infile_name))
+        os.rename(outfile_name, infile_name)
+    else:
+        print("Nothing was replaced in '{}'.".format(infile_name))
+        os.remove(outfile_name)
+
diff --git a/sky130/custom/sky130_fd_pr/sky130_fd_pr__rf_npn_11v0_W1p00L1p00.gds b/sky130/custom/sky130_fd_pr/sky130_fd_pr__rf_npn_11v0_W1p00L1p00.gds
new file mode 100644
index 0000000..7691e7f
--- /dev/null
+++ b/sky130/custom/sky130_fd_pr/sky130_fd_pr__rf_npn_11v0_W1p00L1p00.gds
Binary files differ