Complete implementation of monte carlo simulation. Enables the scripts that convert the statistics blocks in the model files into ngspice-compatible syntax, both for mismatch parameters (inside the model definitions) and process variation (in .param lines outside the model definitions). Added new block name "mc" for use with the ".lib" command to enable the models with process variation instead of a corner model. Use of ngspice now requires that every testbench set ".param mc_mm_switch=0|1" to disble or enable the parameter mismatch, since the mismatch setting is independent of the corner model used.
diff --git a/VERSION b/VERSION index 5ea67cd..aa8006b 100644 --- a/VERSION +++ b/VERSION
@@ -1 +1 @@ -1.0.155 +1.0.156
diff --git a/sky130/Makefile.in b/sky130/Makefile.in index 34354fa..2bded28 100644 --- a/sky130/Makefile.in +++ b/sky130/Makefile.in
@@ -749,14 +749,21 @@ 2>&1 | tee -a ${SKY130A}_make.log || true # Custom: Parse the (commented out) statistics blocks and generate # ngspice-compatible monte carlo parameters for mismatch and process - # (currently under test) - # ./custom/scripts/mismatch_params.py \ - # 2>&1 | tee -a ${SKY130A}_make.log || true - # ./custom/scripts/mismatch_params.py \ - # ${STAGING_PATH}/${SKY130A}/libs.tech/ngspice \ - # 2>&1 | tee -a ${SKY130A}_make.log || true - # ./custom/scripts/process_params.py \ - # 2>&1 | tee -a ${SKY130A}_make.log || true + ./custom/scripts/mismatch_params.py \ + 2>&1 | tee -a ${SKY130A}_make.log || true + ./custom/scripts/mismatch_params.py \ + ${STAGING_PATH}/${SKY130A}/libs.tech/ngspice \ + 2>&1 | tee -a ${SKY130A}_make.log || true + ./custom/scripts/process_params.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: Add "spinit" file cat ./custom/models/spinit >> \
diff --git a/sky130/custom/models/sky130.lib.spice.extra b/sky130/custom/models/sky130.lib.spice.extra new file mode 100644 index 0000000..e97075f --- /dev/null +++ b/sky130/custom/models/sky130.lib.spice.extra
@@ -0,0 +1,12 @@ + +* 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
diff --git a/sky130/custom/scripts/mismatch_params.py b/sky130/custom/scripts/mismatch_params.py index 1cb5ad8..eda8462 100755 --- a/sky130/custom/scripts/mismatch_params.py +++ b/sky130/custom/scripts/mismatch_params.py
@@ -109,8 +109,10 @@ infile.close() outfile.close() if replaced_something: - print("Something was replaced in '{}', backed up original file and replaced with processed one.".format(infile_name)) - os.rename(infile_name, infile_name + '.orig') + # print("Something was replaced in '{}', backed up original file" + # + " and replaced with processed one.".format(infile_name)) + print("Something was replaced in '{}'.".format(infile_name)) + # os.rename(infile_name, infile_name + '.orig') os.rename(outfile_name, infile_name) else: print("Nothing was replaced in '{}'.".format(infile_name))
diff --git a/sky130/custom/scripts/process_params.py b/sky130/custom/scripts/process_params.py index 1e59136..ca0f95a 100755 --- a/sky130/custom/scripts/process_params.py +++ b/sky130/custom/scripts/process_params.py
@@ -116,8 +116,10 @@ infile.close() outfile.close() if replaced_something: - print("Something was replaced in '{}', backed up original file and replaced with processed one.".format(infile_name)) - os.rename(infile_name, infile_name + '.orig') + # print("Something was replaced in '{}', backed up original file" + # + " and replaced with processed one.".format(infile_name)) + print("Something was replaced in '{}'".format(infile_name)) + # os.rename(infile_name, infile_name + '.orig') os.rename(outfile_name, infile_name) else: print("Nothing was replaced in '{}'.".format(infile_name))
diff --git a/sky130/custom/scripts/rename_cells.py b/sky130/custom/scripts/rename_cells.py index 8057ad3..5692c41 100755 --- a/sky130/custom/scripts/rename_cells.py +++ b/sky130/custom/scripts/rename_cells.py
@@ -33,7 +33,7 @@ for line in spilines: # These substitutions are for files originating from cells/*/*.spice - fixedline = re.sub('\.\./\.\./models/', '../../libs.tech/ngspice/', line) + fixedline = re.sub('\.\./\.\./models/', '../../../libs.tech/ngspice/', line) fixedline = re.sub('\.\./[^/\.]+/', '', fixedline) fixedlines.append(fixedline)