SPICE Simulation and Control Statements

Contents

Overview

The NI SPICE Simulation Fundamentals series is your free resource on the internet for learning about circuit simulation. The series is a set of tutorials and information on SPICE simulation, OrCAD pSPICE compatibility, SPICE modeling, and other concepts in circuit simulation.

For more information, see the SPICE Simulation Fundamentals main page.

The series is divided among a number of in-depth detailed articles that will give you HOWTO information on the important concepts and details of SPICE simulation.

Circuit simulation is an important part of any design process. By simulating your circuits, you can detect errors early in the process, and avoid costly and time consuming prototype reworking. You can also easily swap components to evaluate designs with varying bills of materials (BOMs).

 

Available Analyses and Control Statements

SPICE is a rich and robust language capable of performing several advanced circuit analyses. The first version of SPICE provided a text-only interface, in which users were forced to manually type statements to control the simulator. Modern simulation programs like Multisim provide a graphical interface to choose these same options. This article provides a listing of the commands and analyses available in SPICE as well as their original syntax and usage.

The following analyses and commands are available in SPICE:

 

 

SPICE Analyses and Control Statement Syntax

 Operating Point Analysis

Syntax

.OP

Example

.OP

Notes

The inclusion of this line in an input file directs SPICE to determine the DC operating point of a circuit with inductors shorted and capacitors opened. Note: a DC analysis is automatically performed prior to a transient analysis to determine initial conditions, and prior to an AC small-signal, Noise, and Pole-Zero analysis to determine the linearized, small-signal models for nonlinear devices.

 

 

 DC Transfer Function

Syntax

.DC SRCname Vstart Vstop Vincr [SRC2 START2 STOP2 INCR2]

Example

.DC VIN 0.25 5.0 0.25

Notes

The DC line defines the source and sweep limits for a DC transfer curve (capacitors open and inductors shorted). SRCname is the name of an independent voltage or current source. Vstart, Vstop, and Vincr are the starting, final, and incrementing values respectively.

 

 

 Small-Signal AC Analysis

Syntax

.AC DEC ND Fstart Fstop
.AC OCT NO Fstart Fstop
.AC LIN NP Fstart Fstop

Example

.AC DEC 10 1 10K
.AC DEC 10 1K 100MEG
.AC LIN 100 1 100HZ

Notes

If this line is included in the input file, SPICE performs an AC analysis of the circuit over a specified frequency range. DEC stands for decade variation, and ND is the number of points per decade. OCT stands for octave variation, and NO is the number of points per octave. LIN stands for linear variation, and NP is the number of points. Fstart is the starting frequency, and Fstop is the final frequency. Note: In order for this analysis to be meaningful, at least one independent source must have been specified with an ac value.

 

 

 Distortion Analysis

Syntax

.DISTO DEC ND Fstart Fstop <F2OVERF1>
.DISTO OCT NO Fstart Fstop <F2OVERF1>
.DISTO LIN NP Fstart Fstop <F2OVERF1>

Example

.DISTO DEC 10 1kHz 100Mhz

Notes

The Disto simulation command does a small-signal distortion analysis of a circuit. A multi-dimensional Volterra series analysis is done using multi-dimensional Taylor series to represent the nonlinearities at the operating point. Terms of up to third order are used in the series expansions. If the optional parameter F2OVERF1 is not specified, .DISTO does a harmonic analysis. In this situationm, the distortion analysis in the circuit uses only a single input frequency, F1. F1 is then is swept over the specified frequency arguments in the .DISTO command (exactly as in the .AC command). Inputs at this frequency may be present at more than one input source, and their magnitudes and phases are specified by the arguments of the DISTOF1 keyword in the input file lines for the input sources (see the description for independent sources).

 

 

 Noise Analysis

Syntax

.NOISE V(OUTPUT <,REF>) SRC ( DEC | LIN | OCT ) PTS Fstart Fstop <PTS;_PER_SUMMARY>

Example

.NOISE V(5) VIN DEC 10 1kHZ 100Mhz
.NOISE V(5,3) V1 OCT 8 1.0 1.0e6 1

Notes

The Noise command line does a noise analysis of a circuit. OUTPUT is the node at which the total output noise is desired; if REF is specified, then the noise voltage, V(OUTPUT) - V(REF), is calculated. By default REF is assumed to be ground. SRC is the name of an independent source to which input noise is referred. PTS, Fstart and Fstop are .AC type parameters that specify the frequency range over which plots are desired. PTS_PER_SUMMARY is an optional integer that specifies the noise contributions of each noise generator for every PTS_PER_SUMMARY frequency points.

 

 

 Pole-Zero Analysis

Syntax

.PZ N1 N2 N3 N4 CUR POL
.PZ N1 N2 N3 N4 CUR ZER
.PZ N1 N2 N3 N4 CUR PZ
.PZ N1 N2 N3 N4 VOL POL
.PZ N1 N2 N3 N4 VOL ZER
.PZ N1 N2 N3 N4 VOL PZ

Example

.PZ 1 0 3 0 CUR POL
.PZ 2 3 5 0 VOL ZER
.PZ 4 1 4 1 CUR PZ

Notes

CUR stands for a transfer function of the type (output voltage)/(input current) while VOL stands for a transfer function of the type (output voltage)/(input voltage). POL stands for pole analysis only, ZER for zero analysis only and PZ for both. This feature is provided mainly for the situation of nonconvergence. This ensures that at least one of either the poles or zeros of the circuit can be determined. Finally, N1 and N2 are the two input nodes while N3 and N4 are the two output nodes. The ability to define these input and output nodes ensures complete freedom in the specification of the output and input ports, and thus the type of transfer function.

 

 

 Sensitivity Analysis (DC or Small Signal AC)

Syntax

.SENS OUTvar
.SENS OUTvar AC DEC ND Fstart Fstop
.SENS OUTvar AC OCT NO Fstart Fstop
.SENS OUTvar AC LIN NP Fstart Fstop

Example

.SENS V(1,OUT)
.SENS V(OUT) AC DEC 10 100 100k
.SENS I(VTEST)

Notes

The sensitivity of OUTvar to all non-zero device parameters is calculated when the SENS analysis is specified. OUTvar is a circuit variable (node voltage or voltage-source branch current). The first form of this analysis calculates the sensitivity of the DC operating-point value of OUTvar The second form calculates sensitivity of the AC values of OUTvar. The parameters listed for AC sensitivity are the same as in an AC analysis (see "".AC"" above for more details). The output values are in the dimensions of change in output per unit change of input (as opposed to percent change in output per percent change of input).

 

 

 Transfer Function Analysis

Syntax

.TF OUTvar inSRC

Example

.TF V(5, 3) VIN
.TF I(VLOAD) VIN

Notes

The TF command defines the small-signal output and input for the DC small-signal analysis. OUTvar is the small-signal output variable and inSRC is the small-signal input source. If this line is included, SPICE computes the DC small-signal value of the transfer function (output/input), input resistance and the output resistance.

 

 

 Transient Analysis

Syntax

.TRAN Tstep Tstop <Tstart <TMAX>>

Example

.TRAN 1NS 100NS

Notes

In a Transient Analysis, Tstep is the printing or plotting increment for the line-printer output. For use with the post-processor, Tstep is the suggested computing increment. Tstart is the initial time (if omitted it is assumed to be zero) and Tstop is the final time. The transient analysis always begins at time zero, so in the interval <zero, Tstart> the circuit is analyzed to reach a steady state but no outputs are stored. In the interval <Tstart, Tstop> the circuit is analyzed and outputs are stored. TMAX is the maximum stepsize that SPICE uses; for default the program will choose the smaller of either Tstep or (Tstop-Tstart)/50.0. TMAX is useful when one wishes to guarantee a computing interval which is smaller than the printer increment, Tstep.

 

 

 PRINT Output

Syntax

.PRINT PRtype OV1 <OV2; ... OV8>

Example

.PRINT TRAN V(4) I(VIN)

Notes

The PRINT line defines the contents of a tabular listing of one to eight output variables. PRtype is the type of analysis (DC, AC, TRAN, NOISE, or DISTO) for which the specified outputs are desired.

 

 

 PLOT Output

Syntax

.PLOT PLtype OV1 <(PLO1, PHI1)> <OV2; <(PLO2, PHI2)> ... OV8>

Example

.PLOT DC V(4) V(5) V(1)

Notes

The PLOT line defines the contents of one plot for one to eight output variables from the analysis defined by the PLtype parameter (DC, AC, TRAN, NOISE, or DISTO). The syntax for the OVI is identical to that for the .PRINT line and for the plot command in the interactive mode. There is no limit on the number of .PLOT lines specified for each type of analysis.

 

 

 SAVE Output

Syntax

.SAVE vector <...>

Example

.SAVE i(vin) input output

Notes

The vectors listed on the .SAVE line are recorded in the rawfile for later use with spice3. The standard vector names are accepted. If no .SAVE line is given then the default set of vectors are saved (node voltages and voltage source branch currents). If .SAVE lines are given, only those vectors specified are saved.

 

 

 Fourier Analysis of Transient Analysis Output

Syntax

.FOUR FREQ OV1 <OV2; OV3 ...>

Example

.FOUR 100K V(5)

Notes

The FOUR (or Fourier) line controls whether SPICE performs a Fourier analysis as a part of the transient analysis. FREQ is the fundamental frequency, and OV1, ..., are the output variables for which the analysis is desired. The Fourier analysis is performed over the interval <Tstop-period;, Tstop> where Tstop is the final time specified for the transient analysis and the period is one period of the fundamental frequency. The DC component and the first nine harmonics are determined. For maximum accuracy TMAX (see the .TRAN line) should be set to period/100.0 (or less for very high-Q circuits).

 

 

 Specify Initial Node Voltage Guesses

Syntax

.NODESET V(n1)=VAL V(n2)=VAL <...>

Example

.NODESET V(12)=4.5 V(4)=2.23

Notes

The NODESET line helps the program find the DC or initial transient solution by making a preliminary pass with the specified nodes held to the given voltages. The restriction is then released and the iteration continues to the true solution. The .NODESET line may be necessary for convergence on bistable or a-stable circuits. In general this line should not be necessary.

 

 

 Set Initial Conditions

Syntax

.IC V(n1)=VAL <V(n2)=VAL> <...>

Example

.IC V(11)=5 V(4)=-5 V(2)=2.2

Notes

The IC line is for setting initial transiet conditions. It has two different interpretations depending on whether the UIC parameter is specified on the .TRAN control line. One should not confuse this line with the .NODESET line. The .NODESET line is only to help DC convergence, and does not affect final bias solution (except for multi-stable circuits).