Corrected the PNP model patch (again, differently, and moved it back
to its original location). Added a few lines that remove the
extraneous statistics block from the 3.4x3.4 PNP model file, so that
the mismatch parameter handling script won't fail on it.
diff --git a/sky130/Makefile.in b/sky130/Makefile.in
index 2072b50..1c92512 100644
--- a/sky130/Makefile.in
+++ b/sky130/Makefile.in
@@ -738,10 +738,19 @@
patch -p1 -f -d ${STAGING_PATH}/${SKY130A} \
< custom/patches/sky130_fd_pr_2.patch \
2>&1 | tee -a ${SKY130A}_make.log || true
+ # Custom: Patch the models to remove the substrate pin from the PNP
+ # device, which has no independent substrate pin (collector=substrate)
+ patch -p4 -f -d ${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE} \
+ < custom/patches/sky130_fd_pr_3.patch \
+ 2>&1 | tee -a ${SKY130A}_make.log || true
# Custom: Patch the ngspice models to add the HV diffusion resistor subcircuits
patch -p2 -f -d ${STAGING_PATH}/${SKY130A}/libs.tech/ngspice \
< custom/patches/sky130_fd_pr_5.patch \
2>&1 | tee -a ${SKY130A}_make.log || true
+ # Fix up the PNP model file before running the next modification
+ head -15 ${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE}/sky130_fd_pr__pnp_05v5_W3p40L3p40.model.spice > ${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE}/temp
+ tail -39 ${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE}/sky130_fd_pr__pnp_05v5_W3p40L3p40.model.spice >> ${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE}/temp
+ mv ${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE}/temp ${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE}/sky130_fd_pr__pnp_05v5_W3p40L3p40.model.spice
# Custom: Parse the (commented out) statistics blocks and generate
# ngspice-compatible monte carlo parameters for mismatch and process
./custom/scripts/mismatch_params.py \
@@ -751,11 +760,6 @@
2>&1 | tee -a ${SKY130A}_make.log || true
./custom/scripts/process_params.py \
2>&1 | tee -a ${SKY130A}_make.log || true
- # Custom: Patch the models to remove the substrate pin from the PNP
- # device, which has no independent substrate pin (collector=substrate)
- patch -p4 -f -d ${STAGING_PATH}/${SKY130A}/libs.ref/${PR_SPICE} \
- < custom/patches/sky130_fd_pr_3.patch \
- 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' \
diff --git a/sky130/custom/patches/sky130_fd_pr_3.patch b/sky130/custom/patches/sky130_fd_pr_3.patch
index ec6a262..8b11dab 100644
--- a/sky130/custom/patches/sky130_fd_pr_3.patch
+++ b/sky130/custom/patches/sky130_fd_pr_3.patch
@@ -9,8 +9,8 @@
+.subckt sky130_fd_pr__pnp_05v5_W0p68L0p68 c b e
+
.param mult = 1.0
- + sky130_fd_pr__pnp_05v5_W0p68L0p68__bf_mm = {(19.35*dkbfpp*MC_MM_SWITCH*AGAUSS(0,0.05537,1)/sqrt(mult))}
- + sky130_fd_pr__pnp_05v5_W0p68L0p68__is_mm = {(1.5075e-018*dkispp*MC_MM_SWITCH*AGAUSS(0,0.01662,1)/sqrt(mult))}
+ + sky130_fd_pr__pnp_05v5_W0p68L0p68__bf_mm = {(19.35*dkbfpp*sky130_fd_pr__pnp_05v5_W0p68L0p68__bf_slope/sqrt(mult))}
+ + sky130_fd_pr__pnp_05v5_W0p68L0p68__is_mm = {(1.5075e-018*dkispp*sky130_fd_pr__pnp_05v5_W0p68L0p68__is_slope/sqrt(mult))}
-qsky130_fd_pr__pnp_05v5_W0p68L0p68 c b e s sky130_fd_pr__pnp_05v5_W0p68L0p68__model
+qsky130_fd_pr__pnp_05v5_W0p68L0p68 c b e c sky130_fd_pr__pnp_05v5_W0p68L0p68__model
.model sky130_fd_pr__pnp_05v5_W0p68L0p68__model pnp level = 1.0