HSPICE - Introduction
SPICE is a general purpose analog circuit simulator that is used to verify circuit designs and to predict circuit behavior. This is of particular importance for “integrated circuits”. It was for this reason that SPICE was originally developed at the Electronics Research Laboratory of the University of California, Berkeley (1975), as its name implies:
Simlulation Program for Integrated Circuit Emphasis
HSPICE is a commercial and very powerful version of SPICE that has fewer bugs than the freely avaliable Berkeley SPICE. HSPICE is a relatively comprehensive program that can be used to simulate very large circuits comprising many different types of components. HSPICE is able to handle hierarchical circuit structures (i.e., you can define subcircuits) and supports both local and global variables/parameters.
Circuit analyses supported by HSPICE:
- Non-linear DC analysis: calculates the DC transfer curves from any input to any output.
- Non-linear transient analysis: calculates the voltages the currents as a function of time when a signal is applied.
- Linear AC Analysis: calculates the frequency response from the input to all specified node voltages and currents. Bode plots can be generated using a graphical post processor, such as AWAVES.
- Noise analysis
- Sensitivity analysis
- Distortion analysis
- Fourier analysis: calculates and plots the frequency spectrum
- Monte Carlo Analysis
Components supported by HSPICE:
- Independent and dependent voltage and current sources
- Resistors
- Capacitors
- Inductors
- Mutual Inductors
- Transmission Lines
- Operational Amplifiers
- Switches
- Diodes
- Bipolar Transistors
- MOSFET Transistors
- MESFET Transistors
- JFET Transistors
- etc.
HSPICE - Files
HSPICE Input Files
- source (nelist): filename.sp
- design configuration: filename.cfg
- initialization: hspice.ini
HSPICE Output Files
- run status: filename.st0
- output listing: filename.lis
- graph data, transient: filename.tr# (.tr0)
- graph data, dc: filename.sw# (.sw0)
- graph data, ac: filename.ac# (.ac0)
- measure output: filename.m*# (.mt0)
Source file (.sp)
The source file is your input file. This file contains your circuits description and all options and analysis you wish HSPICE to deal with. The structure looks like this:
1 | title - Implicit first line, must be there |
Design configuration (.cfg)
Configuration files are used by HSPICE, AWAVES and HSPLOT to describe the available terminals and hardcopy devices.
Initialization (hspice.ini)
The initialization file deals primarily with setting up HSPICE itself and has no need to be modified by users.
Run status (.st0)
The run status file is a transcript of what operations HSPICE performs on a source file. The file sometimes offers help when debugging as shows steps not preformed by HSPICE.
Output listing - important (.lis)
This is one of the most important files in HSPICE as this file lists all results obtained from simulation. This file contains (in order of listing in the file):
- HSPICE licensing info
- Listing of the circuit
- Results from the analysis of the circuit (.op, .print, .plot, .measure, .ac, and .tran in order of their appearance in the source file)
Graph data files (.tr#, .sw#, .ac#)
Graph date files are created by .OPTION POST
command and contain the date to graphed by HSPLOT, AWAVES, HSPICE. Basically these files retain the data to be graphed from the .lis file in a different graphing format.
Measure output (.m*#)
The measure output file hold the result from .MEASURE
commands. These files are not very useful because the data is hard to read and already exits in a nicely formatted way in the .lis file.
HSPICE - Source File
The HSPICE source file consists of five parts.
- Title statement: the first line is the circuits title; it may be anything, but not neglected.
- Data statements: description of the components and the interconnections.
- Control statements: tells SPICE what type of analysis to perform on the circuit.
- Output statements: specifies what outputs are to be printed or plotted.
- End statement: on the very last line: .END followed by a carriage return.
1 | TITLE STATEMENT |
Comment statements: can be anywhere in the source file:
- ‘*‘ - indicates a full line comment
- ‘$’ - indicates and end-of-line comment
Continuation: ‘+’ - indicates a continuation of the previous line.
NOTATION
HSPICE notation is relatively simple. Both upper and lower case letters are allowed, but no distinction is made (HSPICE converts everything to upper-case characters before any interpretation is attempted).
The statements have a free format and consist of fields separated by a blank. Each line is interpreted as a separate statement.
- All statements begining with a ‘.’ are commands (.OPTION, .PRINT, .AC, etc.)
- Statements that begin with an alphabetic character are treated as elements, the first character determines the type of element:
- R for resistors
- C for capacitors
- L for inductors:
- D for diodes
- Q for bipolar junction transistors
- M for MOS transistors
- V for voltage sources
- I for current sources
- G for voltage-controlled current sources (tranconductance amplifiers)
- F for current-controlled current sources (current amplifiers)
- E for voltage controlled voltage sources (voltage amplifiers)
- H for current-controlled voltage sources (tranresistance amplifiers)
- X for subcircuits (hierarchical circuit structure)
Topology Rules
- Every node must have a DC path to ground.
- No dangling nodes (all nodes must have at least two connections).
- No loops of only ideal voltage sources and capacitors.
- No nodes connected to only ideal current sources and inductors.
Naming conventions
- Node Identification:
- 0 is ALWAYS ground
- It’s best to start all node names (besides ground) with an alphabetic character.
HSICE units
- f=1e-15
- p=1e-12
- n=1e-9
- u=1e-6
- m=1e-3
- k=1e3
- meg=x=1e6
- g=1e9
- t=1e12
Global Variables
- Syntax
.global node1 node2 node3
: globally defined nodes.global vbias vcc
: globally defined sources
- Usage
- when subcircuits are included in the data file
- assign common node name to subsircuit nodes
- power supply connection of all subcircuits is often done this way:
.global vcc
: connects all nodes named vcc (all circuits have a common node)
Essential globals are used most often for subcircuits, though they are great for sources. Notice that ground (node 0) always is a global node.
HSPICE - Devices
General Element Statements
The element statement specifies the type of element or independent source used.
It has a field for the element name, the connecting nodes, a value for the
component, and optional parameters.
General Form:
1 | NAME node1 node2 ... nodeN <model reference> value <optional parameters> |
NAME
Specifies the type and name of element. The first letter in the name field
identifies the element as a specific type, the remaining letters give the element
a unique name.
node
Specifies how the element is connected in the netlist.
value
Gives the values of the element
Refers to the model when the basic element value does not provide an adequate
description.
Used to modify existing values within a.model
for this paricular element.
In order to words a.model
might have a temperature of 27 degrees when you
what 40 degrees Centigrade.
.model
Statements
.model
statements allow extra device descriptions are required for accuracy.
For instance, a .model
statement can be used to give resistors operating
temperatures, L and W values to MOSFET’s, or even insulator thickness on a
capacitor. .model
statements can be included any within the .lis
, though
they are usually placed before the netlist for convenience.
General Form:
1 | .model mname modeltype<keyword=value> |
mname
The model reference name specified in the associated element statement.
modeltype
Specifies the model type to be used, i.e., R for a resistro, C for a capacitor,
and L for inductor.
.param
Statements
.param
statements allow the user to define local variables.
The variables can be defined as values, equations, or even functions.
General Form:
1 | .param variable = 'expression' |
variable
Represents the name of the variable or function to be defined.
expression
Represents the value, equation, or function to be assigned to the variable.
Devices
Passive
Resistors
The resistor elements use the following formats:
1 | Rxxx n1 n2 Rval |
AC
AC resistance used in the AC analysis.
default=Reff
C
Capacitance connected from node n2 to bulk.
default=0.0
DTEMP
Element and circuit temperature difference.
default=0.0
equation
The resistor can be described as a function of any node voltage, branch currents
and any independent variables such as TIME, frequency (HERTZ), or temperature
(TEMPER)
L
Resistor length.
default=0.0
M
Multiplier used to simulate parallel resistors.
default=1
mname
Model name.
n1
Positive terminal node name.
n2
Negative terminal node name.
R
Resistance.
Rxxx
resistor element name. Must begin with ‘R’.
SCALE
Element scale factor for resistance and capacitance.
default=1
TC1
1st order Temp. Coeff. for resistor.
TC2
2nd order Temp. Coeff. for resistor.
W
Resistor width.
default=0.0
Capacitors
The capacitor elements use the following formats:
1 | Cxxx n1 n2 capval |
Cxxx
Capacitor element name. Must begin with an ‘C’.
C
Capacitance in farads at room temperature.
CTYPE
For capacitance, if C is a function of v(n1,n2),then CTYPE=0 else =1.
The capacitance charge is calculated differently depending on the value of
CTYPE.
IV
Initial voltage across the capacitor in volts.
The rest can refer to resistor which the definitions are the same.
Note: Inductor is skipped since I don’t use it in my design.
Active
Diodes
Diodes in HSPICE can be anywhere from very complex realistic diodes to simple
ideal ones depending on the circuit designer. In general all diodes will have a
model name and be defined by a .model
statement. Since most models are
provided, .model
descriptions will not be given in any detail.
The diode element uses the following formats:
1 | Dxxx nplus nminus mname <options> |
AREA
Represents the area of the diode.
default=1
Dxxx
Diode element name, must begin with an ‘D’.
nplus
Positive terminal name (arrow end) of the diode.
nminus
Negative terminal name (line end) of the diode.
PJ
Periphery of junction.
WP
Polysilicon capacitor width (in meters).
LP
Polysilicon capacitor length (in meters).
WM
Metal capacitor width (in meters).
LM
Metal capacitor length (in meters).
OFF
Sets the diode initially to the off operation region (DC analysis).
default=ON
IC
Initial diode voltage.
The rest options can be refer to resistor.
BJT is skipped.
MOSFETS
MOSFETs are another device within HSPICE that requires a .model
statement.
The .model
statement is required to define whether or not the circuit designer
want to deal with a p- or n-channel device. The syntax for the .model
statement
is shown below:
1 | .model mname NMOS <or PMOS> <parameters> |
Only the model name and the NMOS (or PMOS) are required. The MOSFET transistor element uses the following formats:
1 | Mxxx nd ng ns mname |
nd
Node name for drain terminal.
nd
Node name for gate terminal.
ns
Node name for source terminal.
nb
Node name for the bulk terminal.
AD
Diffusion area of the drain.
AS
Diffusion area of the source.
PD
Drain junction perimeter (including channel edge).
default=0
PS
Source junction perimeter (including channel edge).
default=0
NRD
Number of resistance squares of drain diffusion.
default=0
NRS
Number of resistance squares of source diffusion.
default=0
RDC
Contact resistance on the drain.
default=0
RSC
Contact resistance on the source.
default=0
OFF
Sets the transistor initially to the off operation region (DC analysis).
default=ON
vbs,vds,vgs
- vbs: initial bulk-source voltage
- vds: initial drain-source voltage
- vgs: initial gate-source voltage
DELVTO
Zero-bias threshold voltage shift.
default=0
GEO
Source-drain sharing selector (only use for ACM=3 in.model
).
default=0
Independent sources
General Form
In general, voltage and current sources in HSPICE can be very almost anything
from simple dc sources to incredibly complex piecewise linear ones. The general
form for both current and voltage sources are shown below:
1 | * Voltage |
tranfun
Transient source function (i.e. PULSE, PU, SIN, EXP, PWL, PL).
Pulse Function
The pulse function can create either a linear rectangular or linear trapazoidal
pulse with an initial time delay. The function also has user defined rise, fall,
and high times. The functions are placed in the tranfun position listed above.
The pulse function has the form:
1 | PULSE (v1 v2 <td> <tr> <tf> <pw> <per>) |
v1
Initial value of voltage or current before the pulse.
v2
Pulse current or voltage value.
td
Time delay for the start of the transient interval to the up ramp.
default=0
tr
Rise time.
default=TSTEP
tf
Fall time.
default=TSTEP
pw
Pulse width.
default=TSTEP
per
Pulse repetition period in seconds.
default=TSTEP (transient timestep)
Sin Function
The HSPICE sin function can produce a sin wave input with user defined delay,
magnitude and phase. Also, HSPICE can also produce exponentially damped sin
sources.
1 | sin (vo va freq td damp<pd>) |
vo
Wave offset.
va
wave amplitude.
freq
Wave frequency in Hz.
default=1/TSTOP
td
Wave time delay in seconds.
default=0
damp
Wave damping factor in 1/seconds.
default=0
pd
Phase delay in degrees (not radians).
default=0
Exponential Function
The exp function produces an exponential with user definable rise time and fall
time constants and delay values.
1 | exp (v1 v2 <td1> <t1> <td2> <t2>) |
v1
Starting voltage or current.
v2
Pulse value of voltage or current.
td1
Rise delay time in seconds.
default=0
t1
Rise time constant in seconds.
default=TSTEP
td2
Fall delay time in seconds.
default=td1+TSTEP
t2
Fall time constant in seconds.
default=TSTEP
Piecewise Linear Function
The HSPICE piecewise linear function is a collection of user defined pulses and
steps. All plateaus and rise and fall times are also user definable. In addition,
when moving between differing voltages or currents, the function will always
proceed linearly.
1 | PWL (v1 t1, <v2 t2, v3 t3, ...> <R=<repeat>> <TD=delay>) |
R
Forces the function to repeat.
repeat
The start time for the function to repeat in seconds.
t1…
The time value in seconds.
TD
Keyword for the function time delay.
delay
Actual time delay in seconds.
v1…
Current or voltage values.
Note: each voltage and time come in pairs.
HSPICE - Commands
Commands or Control Statements to Specify the Type of Analysis
.op
Statement
This statement instructs SPICE to compute the DC operating points:
- voltage at the nodes
- current in each voltage source
- operating point for each element
In HSPICE it is usually not necessary to specify .op
as it gives you
automatically the DC node voltages. However, HSPICE does not give the DC voltages
unless you have specified a certain analysis type, such as for instance .tran
or .ac
analysis (SPICE automatically does a DC analysis before doing a
transient or AC analysis). Thus, if you are only interested in the DC voltages in
HSPICE, you should specify the .op
option, or the .dc
option.
.dc
Statement
This statement allows you to increment (sweep) an independent source over a
certain range with a specified step. The format is as follows:
1 | .dc SRCname START STOP STEP |
in which SRCname
is the name of the source you want to vary; START
and STOP
are the starting and ending value, respectively; and STEP
is the size of the
increment.
.tf
Statement
The .tf
statement instructs HSPICE to calculate the following small signal
characteristics:
- the ratio of output variable to input variable (gain or transfer gain)
- the resistance with respect to the input source
- the resistance with respect to the output terminals
.tf outvar insrc
in which outvar
is the name of the output variable andinsrc
is the input source.
.sens
Statement
This instructs HSPICE to calculate the DC small-signal sensitivities of each
specified output variable with respect to every circuit parameter.
1 | .sens variable |
.tran TSTEP TSTOP <TSTART
1 |
|
.ic Vnode1 = value Vnode2 = value
1 |
|
.ac LIN NP FSTART FSTOP
.ac DEC ND FSTART FSTOP
.ac OCT NO FSTART FSTOP
1 | in which `LIN` stands for a linear frequency variation, `DEC` and `OCT` for a |
.print TYPE OV1 OV2 OV3
.plot TYPE OV1 OV2 OV3
in which `TYPE` specifies the type of analysis to be printed or ploted and can
be:
- DC
- TRAN
- AC
The output variables are OV1, OV2 and can be voltage or currents. Node voltages
and device currents can be specified as magnitude (M), phase (P), real (R) or
imaginary (I) parts by adding the suffix to V or I as follows:
- M: magnitude
- DB: magnitude in dB (deciBells)
- P: phase
- R: real part
- I: imaginary part
# NOTES
1. Know what to expect from the simulation before running it.
2. Simulation is NO substitute for THINKING.
## Other helpful hints
1. You can measure the voltage at any node, or the voltage between any two nodes.
However, you can only measure the current passing through a voltage source. To
measure a current through a branch, insert a dummy voltage source of value 0 in
the branch (like an ammeter) and measure the current through this dummy voltage
source.
2. To extract the data from the `.lis` file, have `.print` statements. Use
`.options ingold` so that the data is in the exponent notation. Just edit the
`.lis` file that you get to have the data suitable for MatLab.