Updated 3 min readSynopsys HSPICE
Synopsys HSPICE simulation automation
Automating Synopsys HSPICE corner runs: a deck with .lib, .alter and .measure, batch and multithreaded runs, and a Python parser for .mt0 measure files.
By the SkyCadEda engineering teamHow these notes are written
On this page
HSPICE (now PrimeSim HSPICE) is Synopsys' signoff-accuracy SPICE simulator. Automating it is mostly about three things: writing decks that cover every corner without copy-paste, running them in parallel on the farm, and parsing the .measure results into a table someone can review. Below is a minimal version of each.
A deck that covers the corners
.lib selects a section of the foundry model file, .measure records the numbers you care about, and each .alter block reruns the whole deck with changed models, temperature or parameters. One deck then produces one measure file per corner.
* inv_delay.sp : inverter delay, three corners
.option post
.lib '/pdk/models/hspice/models.lib' tt
.include 'inv.sp'
.temp 25
.param vsup=0.80 cload=5f
Vdd vdd 0 'vsup'
Vin in 0 pulse(0 'vsup' 100p 20p 20p 480p 1n)
X1 in out vdd 0 inv
Cl out 0 'cload'
.tran 1p 2n
.measure tran tpd_r trig v(in) val='vsup/2' fall=1 targ v(out) val='vsup/2' rise=1
.measure tran tpd_f trig v(in) val='vsup/2' rise=1 targ v(out) val='vsup/2' fall=1
.alter ss_hot
.lib '/pdk/models/hspice/models.lib' ss
.temp 125
.param vsup=0.72
.alter ff_cold
.lib '/pdk/models/hspice/models.lib' ff
.temp -40
.param vsup=0.88
.endThe section names (tt, ss, ff) come from the foundry model file; check the PDK's model documentation for the exact corner sections and supply ranges. For mismatch and process variation, .tran 1p 2n sweep monte=200 runs Monte Carlo with the statistical models the PDK provides.
Running it
hspice -mt 8 -i inv_delay.sp -o run/inv_delay
# writes run/inv_delay.lis, .tr0/.tr1/.tr2 and .mt0/.mt1/.mt2On a farm, wrap that line in your scheduler's submit command (bsub or sbatch), request as many cores as you pass to -mt, and give each run its own output directory. Before trusting any measure file, grep the .lis for errors and convergence warnings: a run that aborted can still leave a partial .mt0 behind.
Parsing the .mt0 files
A measure file starts with $ comment lines and a .TITLE line, then the column names (ending with alter#), then the values in the same order. Failed measurements are written as failed. This parser handles column lists that wrap over several lines; keep a measure file from your own HSPICE version as a test fixture for it:
import glob, re
def read_mt(path):
tokens = []
with open(path) as f:
for line in f:
if line.startswith("$") or line.upper().startswith(".TITLE"):
continue
tokens.extend(line.split())
end = tokens.index("alter#") + 1
names, values = tokens[:end], tokens[end:]
rows = []
for i in range(0, len(values), len(names)):
row = dict(zip(names, values[i:i + len(names)]))
rows.append({k: (None if v == "failed" else float(v) if k != "alter#" else v)
for k, v in row.items()})
return rows
for mt in sorted(glob.glob("run/inv_delay.mt*")):
for row in read_mt(mt):
print(mt, row)From there it is a small step to a CSV or dashboard per block: one row per corner, one column per measurement, a pass/fail column against the spec, and the model file path and HSPICE version recorded with every run so a result can be traced back to its inputs.
Netlists from Virtuoso or Custom Compiler
Production decks usually include a netlist exported from the schematic or from extraction (a DSPF or SPICE netlist from StarRC or Quantus for post-layout runs) rather than hand-written subcircuits. Keep the testbench, stimulus and measurements in your own template and .include the generated netlist, so a netlist regeneration never overwrites the measurements. Netlist format differences are covered in CDL, SPICE and Verilog netlists.
We build HSPICE deck templates, corner matrices, regression launchers and measurement parsers for custom IC teams, aimed at fewer manual reruns and faster debug; see our EDA automation services.
Frequently asked questions
What is Synopsys HSPICE used for?
HSPICE is a transistor-level SPICE circuit simulator. It is used where accuracy matters more than speed: standard-cell and IO characterisation, SRAM bit-cell and sense-amp analysis, analog blocks, and foundry model validation. It is now sold as PrimeSim HSPICE, part of the Synopsys PrimeSim simulator family.
What files does HSPICE write?
The .lis listing (log, operating points, errors), waveform files (.tr0 for transient, .sw0 for DC, .ac0 for AC when .option post is set) and measure tables (.mt0, .ms0, .ma0 for transient, DC and AC .measure results). The trailing digit increments for each .alter run: .mt1, .mt2 and so on.
How do you run HSPICE in batch mode?
hspice -i deck.sp -o outdir/deck runs a deck from the command line, and -mt N enables multithreading. For corner and Monte Carlo campaigns, each deck or alter set is usually submitted as a separate job to LSF or Slurm and the measure files are collected afterwards.
Related reading
- noteCDL, SPICE and Verilog netlists
- noteSynopsys Custom Compiler Tcl automation
- notePython EDA automation
- serviceEDA automation services
More engineering notes
Working through a problem like this?
Tell us about your flow: the tools, the PDK, what is failing and when it needs to be clean.