SPICE Simulations


The range and function of Computer-Aided Design (CAD) tools available to the analogue circuit designer is limited in comparison to those provided for digital circuit design. One is, however, widely used and, moreover, is available for the IBM PC. SPICE (from the University of California) is essentially a circuit-level simulator. Electronic circuits may be described at the transistor level and simulated with very great accuracy. The advantages of simulation have already been discussed. In the design of integrated circuits, SPICE is an essential tool for verifying the behaviour of analogue circuits and individual logic gates. Because the accuracy of SPICE is potentially very good, there is a cost in terms of the speed of simulation. Various attempts have been made to speed up circuit-level simulation, but none have been as general purpose as SPICE nor gained such wide accceptance.

For the purposes of this exercise, we will consider just one circuit and use it to explore the different simulation modes of SPICE.

The figure shows a simple differential amplifier with two NPN bipolar transistors.

This may be described by a SPICE netlist as follows:

The first line of the netlist is a title, and may consist of any text. Subsequent lines begin with either a letter signifying the type of element, a full stop ".", indicating a command to SPICE or an asterisk "*" for a comment line. Thus, lines 7 and 8 represent transistors and lines 10 and 12 represent capacitors. SPICE dates from the ancient days of punched cards, thus each line would have been punched on a single card. In order to extend data over more than one line, the second and subsequent lines must start with a plus "+".

After each initial letter, there may be up to 7 further letters and numbers which allow the user to distinguish between circuit elements. This information is ignored by SPICE. Following the identifier, each element has a list of node numbers and values or further data. Node numbers are integers; node 0 is the ground or reference node. Values such as resistance may be specified as integers (-12), floating point numbers (-12.0), in scientific notation (-12.0E4) or using the following suffixes:

F = 1E-15; P = 1E-12; N = 1E-9; U = 1E-6; M = 1E-3;

MIL = 25.4E-6; K = 1E3; MEG = 1E6; G = 1E9; T = 1E12

Some device formats are summarised here. N1, N2 represent integer numbers; N+ and N- are integer numbers for devices where polarity is important; VALUE represents a real number. YYYYYYY represents the 7 identifying characters that may be used in a device description.

Resistors: RYYYYYYY N1 N2 VALUE

Capacitors: CYYYYYYY N1 N2 VALUE

Inductors: LYYYYYYY N1 N2 VALUE

Fixed Voltage Source: VYYYYYYY N+ N- VALUE

Fixed Current Source: IYYYYYYY N+ N- VALUE

Bipolar Transistor: QYYYYYYY NC NB NE MODNAME

NC, NB, NE are the numbers of the collector, base and emitter nodes, respectively. MODNAME is the name of a model (see below).

MOSFET: MYYYYYYY ND NG NS NB MODNAME

ND, NG, NS, NB are the numbers of the drain, gate, source and base (substrate), respectively. MODNAME is the name of a model (see below).

Subcircuits: XYYYYYYY nodes SUBNAME

Several other elements may be specified:

Independent sources.

Shown above are simple, fixed voltage and current sources. The value specified is a DC value, which may be held through a transient analysis. In addition, an AC value may be specified, together with a time domain function.

e.g. a voltage source which takes an AC value of 1V and which provides a pulse which varies between 0 and 5 volts, with rise and fall times of 5ns, a width of 10s and a period of 30ns and which starts changing at time 0 might be specified as:

VIN 1 0 AC 1 PULSE (0 5 0 5N 5N 10N 30N)

Semiconductor models

A semiconductor device model can take up to 40 different parameters. To avoid retyping all parameter values for every instance of a given device, a semiconductor references a model. The model is normally defined on a line starting with ".MODEL".

Verify that the netlist corresponds to the figure. (Hint: write the node numbers from the netlist against the corresponding nodes on the circuit diagram.)

Analysis Types

Operating point.

This is the simplest analysis type. The DC operating point of the circuit is calculated. An operating point analysis is needed before transient or AC analysis and is performed by default. An operating point analysis is performed if a ".OP" line is included in the netlist file.

Create a file containing the SPICE netlist as shown using an editor. Include the command to perform an operating point analysis. HSPICE will perform the analysis if you enter the following at the Unix prompt, %, (assume the netlist file is called diff.sp).

% hspice diff

The output goes to the screen. If you wish to save the output for further analysis, direct the output to a file (with e.g. > diff.lis).

Examine the analysis results. Does the circuit work as expected? If not, have you entered the circuit correctly? Be careful to distinguish between "O" and "0"!

AC Analysis.

This analysis mode calculates the frequency response of a circuit. Include the following lines in your circuit file:

.AC DEC 10 10K 10MEG

.OPTIONS POST

The .AC line performs an analysis in the range 10kHz to 10MHz with 10 samples per decade. The .OPTIONS POST line causes the results to be saved in a file diff.ac0. Start the graphics post processor with:

% gsi diff

Select n from the options, and then hertz as the x-axis. Look at nodes 4 and 6.

DC Analysis

This analysis mode looks at the DC characteristics of the circuit. Comment out the .AC line (by putting an asterisk at the start of the line, and include

.DC VIN1 0 0.05 0.005

This steps VIN1 from 0 volts to 0.05 volts in 5mV steps. Look at nodes 4 and 6 in gsi. Note that the file name is diff.sw0

Transient Analysis

In contrast to the other analysis modes, transient analysis looks at the behaviour of the circuit in time. It is more time consuming than other modes. To perform this analysis, the input waveforms must be specified. Modify the VIN1 line to read:

VIN1 3 0 AC 1M SIN(0 0.05 100K 0 0)

which puts a 100KHz sine wave of 0.05V amplitude and a mean value of 0V into node 3.

Comment out the .DC line and include:

.TRAN 1U 100U

which performs a transient analysis for 100:s with 1:s steps. Look at nodes 3, 4 and 6 in gsi.

Fourier Analysis

The frequency components of a transient waveform can be calculated. Include

.FOUR 100K V(4)

and repeat the transient analysis. The frequency components of V(4) and the distortion are listed in the output file.

Sensitivity Analysis

The sensitivity of an output variable to changes in component values can be calculated with sensitivity analysis. Comment out the other analysis options and include:

.SENS V(4)

The sensitivity of V(4) to parameter variations is listed in the output file.

Noise Analysis

A noise analysis must be performed in conjunction with an AC analysis. Include

.NOISE V(4) VIN1 5

to examine the noise voltages at the output with respect to the input voltage. The noise figure is printed to the output file at every 5th analysis point.

Temperature Analysis

Any of the above analyses may be repeated at several different temperatures. Try the following in conjunction with an AC analysis.

.TEMP 0 25 100

This creates three output files, diff.ac0, diff.ac1, diff.ac2, one for each temperature. Start gsi with one file, and display V(4). Without leaving gsi, go to the setup menu and choose another input file. You can superimpose V(4) from the second file.


Mark Zwolinski

12 September 1997