spice.pdf

12
Introduction to Hspice Gary A. Ybarra, H. Craig Casey, Jr., Bineyam A. Tafesse, and Kip D. Coonley 1 HSpice Initialization Procedure Before you can run Hspice you must perform two initialization procedures. There are 12 Sun SPARC stations in room 161. Login to one of these machines. In your home directory, edit your . ¯ cshrc file with a text editor (such as vi or emacs). Your .cshrc file contains a portion that resembles the following: ######################################################################### # PLACE ANY ADDITIONS BETWEEN THE "if ... then" and "endif" lines # ######################################################################### if (! ${?NoCustomization}) then set path = ( $path . ) # append working dir (".") to path endif # if (! ${?NoCustomization}) then ############################### ######################################################################### # END OF USER ADDITIONS # ######################################################################### Insert the new line source /opt/digital/setup_hspice immediately before the endif statement. If you are unfamiliar with how to edit files, see the VI editor tutorial in the EE61 Course-Pak. Once you have modified your .cshrc file and saved it to your home directory, log off and re-login. 2 General Description The name of a Hspice circuit file must be of the form name.sp (The .sp suffix is required). A circuit file for Hspice begins with a Title which contains comments such as the name of the circuit file and ends with the .END statement. After the Title, the Circuit Description is given, then the Analysis Description , and finally the Output Description . The order of the lines between the Title and .END statement is not important, but it is helpful to use a designated order to simplify file editing. The order would be; Title Circuit Description Analysis Description Output Description .END 1

Upload: stara123war

Post on 27-Dec-2015

3 views

Category:

Documents


1 download

TRANSCRIPT

Introduction to Hspice

Gary A. Ybarra, H. Craig Casey, Jr., Bineyam A. Tafesse, and Kip D. Coonley

1 HSpice Initialization Procedure

Before you can run Hspice you must perform two initialization procedures. There are 12 SunSPARC stations in room 161. Login to one of these machines. In your home directory, edit your.¯cshrc file with a text editor (such as vi or emacs). Your .cshrc file contains a portion that resemblesthe following:

#########################################################################

# PLACE ANY ADDITIONS BETWEEN THE "if ... then" and "endif" lines #

#########################################################################

if (! ${?NoCustomization}) then

set path = ( $path . ) # append working dir (".") to path

endif # if (! ${?NoCustomization}) then ###############################

#########################################################################

# END OF USER ADDITIONS #

#########################################################################

Insert the new line

source /opt/digital/setup_hspice

immediately before the endif statement. If you are unfamiliar with how to edit files, see the VIeditor tutorial in the EE61 Course-Pak. Once you have modified your .cshrc file and saved it toyour home directory, log off and re-login.

2 General Description

The name of a Hspice circuit file must be of the form name.sp (The .sp suffix is required). Acircuit file for Hspice begins with a Title which contains comments such as the name of the circuitfile and ends with the .END statement. After the Title, the Circuit Description is given, then theAnalysis Description, and finally the Output Description. The order of the lines between the Titleand .END statement is not important, but it is helpful to use a designated order to simplify fileediting. The order would be;

TitleCircuit DescriptionAnalysis DescriptionOutput Description.END

1

A brief description of the three parts of the Hspice file between the Title and .END statementwill be presented. However, only those parts needed for the application of Hspice to devices areincluded. General circuit analysis is provided in numerous books such as the four above.

Numbers for Hspice files may be expressed as integers (eg. 5,−5), floating point (eg. 5.163), orin scientific notation (eg. 5.1E−3). The suffixes for Hspice corresponding to standard engineeringnotation are:F=1E−15 (femto) P=1E−12 (pico) N=1E−9 (nano)U=1E−6 (micro) M=1E−3 (mili) K=1E3 (kilo)MEG=1E6 (Mega) G=1E9 (Giga) T=1E12 (Tera)MIL=25.4E−6 (0.001 inch).

The units used are: V (Volt), A (Amp), HZ (Hertz), OHM (Ohm), H (Henry), F (Farad) andDEG (degree). Distances are given in meters. In Hspice files, continuation of a line is preceded bya plus (+) sign and comment lines are preceded by an asterisk (*).

3 Circuit Description

The circuit description specifies the circuit elements and sources. The nodes of the circuit elementsand sources are given by integer numbers with 0 reserved for ground. Hspice identifies a circuitelement or source by the first letter on the e

¯lement or s

¯ource line. These elements and sources are

summarized in Table 1.

Table 1. First Letter of Elements and Sources.

First Letter Circuit Element or Source

B GaAs MESFETC capacitorD diodeE voltage-controlled voltage sourceF current-controlled current sourceG voltage-controlled current sourceH current-controlled voltage sourceI independent current sourceJ JFETK mutual inductors (transformers)L inductorM MOSFETQ bipolar junction transistorR resistorS voltage-controlled switchT transmission lineV independent voltage sourceW current-controlled switch

2

3.1 DC Voltage and Current Sources

The element line for a DC voltage source is given by

VXXXXXX N+ N- DC <value>,

where XXXXXX represents from 1 to 6 alphanumeric characters for the name of the voltage source.Hspice considers current to flow from the positive node N+ to the negative node N- within the ele-ment. The product of the current (through) and voltage (across) will be positive for a resistor sincethe power absorbed by a resistor is always positive. However, the current through a DC source willbe negative if it is supplying (delivering) positive power.

The element line for a DC current source is given by

IXXXXXX N+ N- DC <value>,

The current flows from the N+ node through the current source to the N- node.

Example 1: DC Sources and Avan waves Exploration

Create a file named ex1.sp with contents:

*EX1.sp

V1 1 0 10

I1 0 1 0.5

R1 1 0 5

.op

.tran 0.02 2.0

.options post

.end

This Hspice file corresponds to the circuit shown in Figure 1.

Figure 1: Circuit EX1

Execute Hspice (in the directory containing ex1.sp) by typing hspice at the UNIX prompt. Youwill be prompted for the name of the Hspice file you wish to simulate.

Enter input file name:

3

After you enter your Hspice file name, Hspice will then prompt you for the output file name.

Output file name [ex1.lis]?

You may simply hit return and a default file name will be used. Notice that the default outputfile has the same name as the input but with the suffix .lis. you’ll encounter few more prompts,but you can simply hit return and use the default options. At this point, Hspice should be runningand an execution window will appear for a few moments as the circuit is being simulated. Afterexecution is complete, the UNIX prompt will reappear. If Hspice cannot complie the input file youwill recieve the message

info: ***** hspice job aborted

This is usually caused by an error in your description of the circuit. You should go back to yourHspice input file and correct the error. Also you can open the output file using a text editor toview error messages from Hspice, which could be helpful in debugging your input file. Once yourcircuit simulates properly you’ll receive the message

info: ***** hspice job concluded

Now that Hspice has been executed, you can view your results by executing AvanWaves. Youdo this by typing awaves at the unix prompt. This will bring up the AvanWaves window. Thetext menu bar should read

Design Panels Window Configuration Tools

Move the cursor to the Design heading and press the left mouse button once. Select Open... withthe left mouse button. The open submenu should appear. Select ex1.sp and then ok. You shouldnow observe the results browser shown below

Figure 2: Results Browser

Once you select Transient:*ex1.sp you will see that you have the choice of selecting to plot thevoltage at each node of the circuit or the current through each voltage source. Under the voltage

4

option select V(1) (voltage at node 1) and double click on it. A plot of V(1) should appear onthe Avanwaves window. Select Add under the Panel heading of the text menu bar. Next fromthe results browser, double click on I(V1) to display the plot on the second panel. Your shouldnow have the following on your window. You are now ready to print. Obtain a printout of your

Figure 3: AvanWaves Plot

graph by clicking on the printer option under the Tools part of the text menu bar. Once the printwindow pops up, you have the option of selecting whether you want to obtain a hard copy or writeit to a .ps or .eps file which can be later used in a latex file. If you choose Printer, your plot isnow queued on the line printer in room 161.

You should now go back to the AvanWaves window and explore the various functions availableon both the text menu bar and the icon menu bar. Many of the commands available in the textmenu bar are also available through the icons. The icon menu bar is arranged in the following order:Results Browser, Expression Manager, Print, Point Manager, Two Points Measure,and Various Zoom Options.

For example, by clicking on the fourth icon in the menu bar, Point Manager, you shouldobserve a ”cross-hair” tracing the line on the graph following the movement of your mouse. Noticethe changing value of the coordinates shown on the upper right-hand of AvanWaves window. Onemore click will allow you to label the point located under the ”cross-hair”. You can find labelformatting features by clicking Measure Label Options on the Measure part of the text menu.Similarly the fifth icon in the menu bar Two Points Measure will allow you to measure thedifference between two points on a plot. Click once on the Two Points Measure icon. Noticethe same ”cross-hair” tracing the line on the graph. Position the ”cross-hair” on the first point andclick once with the center mouse button. Next, you’ll observe a second ”cross-hair” connected to

5

the first by a line with varying length depending on the location of the second point. Click oncemore once you place the second ”cross-hair” over the second point. You will now observe a labelwith values of the change in the x and y direction of the two points you chose.

You should be curious about the .options and .tran control lines in the Hspice program ex1.sp.The .options post line simply instructs Hspice to write the results of the analysis to a file calledex1.lis which is read by Avanwaves. Specifically, for the circuit shown above the .options postcommand line instructs Hspice to write the voltage at every node and the current flowing througheach voltage source. However, in order to obtain other parameters such as the the current flowingthrough R1, we need to utilize the .probe control line. Add the following line before the .end lineof EX1.sp file:

.probe I(R1)

After running Ex1.sp file in Hspice on more time, you will notice there is one more parameter,I(R1), in the result browser of AvanWaves which you can plot. Furthermore, as you have seen,executing the AvanWaves program invokes the graphics post-processor. The .tran control linehas five parameters (in general): tstep, tstop, tstart, tmax, and uic. The syntax for the.tran control line is

.tran tstep tstop tstart tmax uic

The first two parameters (tstep and tstop) are required. A reasonable value for tstep is tstop

100.

tstop determines the end of the analysis interval. For example

.tran 0.02 2.0

instructs Hspice to produce analysis results in the region of time 0 ≤ t ≤ 2 seconds. Sometimes theplots produced by Hspice are not smooth and additional points may be desired. If more points isdesired, the parameter tmax must be used. The use of tmax is described and illustrated in Example2. When plotting waveforms, you should question how many points are necessary to produce anaccurate plot. In the case of DC voltages and currents, only two points are required for any timeinterval!

3.1.1 Analysis of DC Circuits and .lis Files

When analyzing DC circuits using a single value for the independent sources, viewing the resultswith AvanWaves is relatively useless since all voltages and currents are constant. In order to obtainthe DC analysis results in this case, add a .op command in your input file and simply examine theoutput file (file.lis) using a text viewer. The output file contains the circuit description, DC nodevoltages, voltage source currents, total power dissipated, as well as useful error messages. Openthe file ex1.lis and examine its contents.

3.2 Piece-Wise Linear Source

A piece-wise linear description of an arbitrary voltage waveform may be represented by pairs ofvalues of time Tj and voltage Vj. The element line is given by

6

VXXXXXX N+ N- PWL(T1 V1 <T2 V2 T3 V3 · · ·>),

where the voltage at T1 is V1. For example, VGEN 1 0 PWL(0NS 5 10NS 5 10.2NS -5) is a piece-wise linear voltage source between node 1 and ground with an initial voltage of 5 V at t = 0 nsecand remains at 5V until 10 nsec. Then it goes from 5 V at 10 nsec to −5 V at 10.2 nsec. Piece-wisecurrent sources are parameterized in a similar manner as piece-wise linear voltage sources.

3.3 Pulse Source

A voltage pulse is specified by the element line:

VXXXXXX N+ N− PULSE(V1 V2 TD TR TF PW PER),

which can specify a single pulse or a pulse train. A similar expression may be used for a cur-rent pulse. The model parameters for pulse sources are given in Table 1.2. In Table 1.2, TSTEP andTSTOP are the values given in the .TRAN control line. Figure 4 illustrates these parameters.

7

Table 2: Model Parameters for Pulse Source

Parameters Default Value Units

V1 (initial value) must specify Volts or AmpsV2 (pulsed voltage) must specify Volts or AmpsTD (delay time) 0 secTR (rise time) TSTEP secTF (fall time) TSTEP secPW (pulse width) TSTOP secPER (period) TSTOP sec

Figure 4: Parameters for Pulse Waveform

3.4 Sinusoidal Source

A sinusoidal voltage waveform is specified by the element line:

VXXXXXX N+ N− SIN(VO VA FREQ TD DF PHASE),

where the parameters are given in the following table.

8

Parameter Default Value Unit

VO (offset value) Required Volt or AmpereVA (amplitude) Required Volt or AmpereFREQ (frequency) 1/TSTOP HertzTD (start delay) 0 secondDF (damping factor) 0 1/secondPHASE (phase angle) 0 degree

TSTOP refers to the stop time in the transient analysis specified by the .tran control line. Thesinusoid start time can occur after time zero. It may be exponentially damped if desired.

Example 2: Sinusoidal Sources and Goal Functions

Consider the circuit in Figure 5.

Figure 5: Circuit EX2

The angular frequency ω of the source is 1000 radians per second. Hence the frequency f is159.155 Hz and the period T is 6.283 ms. It is important to consider how much total time overwhich to perform the analysis as well as the time increment between analysis points. In order tocapture approximately three cycles of the response, we will choose tstop = 20 ms. Varying theparameter tstep has no effect. 50 points (default) will be plotted in AvanWaves. Compile thefollowing code using Hspice.

*EX2.sp

V 1 0 SIN(0 10 159.155 0 0 0)

L 1 2 10m

R 2 0 15

.tran 0.2m 20.0m

.options post

.probe v(1,2) I(L) I(R)

.end

Use AvanWaves to display all voltages and currents. Is there more than one current in thiscircuit? Notice that in order to obtain the voltage across the inductor we need to take the voltage

9

of node 1 with respect to node 2. This is accomplished by using the .probe v(1,2) control line. Alsonotice how the current through the inductor and resistor are obtained using the .probe control line.Note that the sinusoidal voltages and current are somewhat irregular near maxima and minima.You should be dissatisfied with these plots produced by AvanWaves because they are not smooth.We can reduce the time increment ∆t between analysis points using the parameter tmax. Recallthat the syntax for the .tran control line is

.tran tstep tstop tstart tmax uic

tmax is the maximum time increment between analysis points. Therefore, the minimum number ofanalysis points is

(min) numpoints = tstop−tstart

tmax

In order to illustrate the use of tmax consider the following .tran control line.

.tran 10u 20m 0 100u

The fourth parameter, 100u is tmax and causes Hspice to produce at least

(min) numpoints = tstop−tstart

tmax= 20m

100u= 200

Try this .tran control line in your Hspice code for the circuit of Example 2 and observe thetraces produced in AvanWaves. You can reduce tmax further if you wish, but be aware that as youreduce tmax, computation time increases.

Hspice can be used to determine the frequency of the sinusoids in a number of different ways.One approach is to use the Two Points Measure capability as investigated in EX1 to determinethe time difference between two successive peaks. This will provide an estimate of the period, whichcan be inverted to estimate the frequency.

There are a number of mathematical operations available in AvanWaves that can be used tomanipulate waveforms. For example, suppose you wanted to obtain a graph of the power deliveredby the voltage source in EX2: (V (1)∗I(R)). You could produce the graph by selecting Expressionsunder the Tools text menu. Also you can bring up the expressions window by using the buttonlabeled f(x,y). Make sure that you also have the results browser window open at the same timeso that you can utilize the parameters listed within it. In the expressions window, make sure thatthe cursor is in the Expression line, then in the results browser window, select V(1) with a singleclick to avoid graphing it. Using the middle mouse button, drag the v(1) into the Expression line.Next from the Operators column select ”*” with a double-click. This should add the operator tothe Expression line. Next, drag I(R) using the middle mouse button into the Expression line.In the Expressions window, type a name of the for the result (e.g ”Power”) in the ”Result:” line.Next, select your result from the Expressions column by selecting it and clicking on apply. Thisshould plot the newly created expression.

There is yet another, perhaps easier, method to perform mathematical operations to manipulatewaveforms. Inside your .sp input code ou can add the expression to the .probe line as anotherparameter to be calculated and provided for AvanWaves to read. For example, the syntax ofparameter for the calculation performed above is

10

.probe pwr=par(’v(1)*I(R))

The following lines creates a new parameter to be displayed in AvanWaves titled pwr. You can findthis new new calculation in the results browser window of AvanWaves under Types column in thegroup ”params” There are many waveform analysis features available in Hspice. You should makea habit of exploring the capability of Hspice each time you use the software.

4 Analysis Description

4.1 DC Analysis

With semiconductor devices, it is often desirable to vary a DC voltage to generate I-V character-istics. The .DC control line is given by

.DC VXXXXX1 Start Stop Inc <VXXXXX2 Start2 Stop2 inc2>,

where VXXXXX1 is the first DC independent voltage source to be varied. The initial voltage is givenby Start, the final voltage is given by Stop, and the increment size in each step is given by Inc. Asecond optional source may be specified by VXXXXX2. When two sources are specif the final voltagefor each value of the second source. Either of these voltage sources could replaced by currentsources. For example, the base current of a bipolar junction transistor could be swept from 10 µAto 50 µA in 5 µA steps while the collector voltage is swept from 0 to 5 V by,

.DC IBASE 10U 50U 5U VCE 0 5 0.05,

where U represents µA.

4.2 Transient Analysis

The transient analysis uses the .TRAN control line which is given by

.TRAN TSTEP TSTOP <TSTART <TMAX>> <UIC>,

where TSTEP is the time increment used for plotting the results of the transient analysis. The timeof the last transient analysis is STOP. The default value of TSTART is zero and designation of a valuemay be omitted. TMAX is the largest computing time step.

4.3 AC Analysis

It is often important to know how a circuit behaves as a function of frequency. The frequencyresponse of a circuit provides this information. The syntax for the .AC control line is

.AC DEC ND FSTART FSTOP

where FSTART is the lowest frequency (which may not be negative or zero), and FSTOP is thehighest frequency. DEC will make Hspice divide the frequency range into decades, with ND pointsper decade. A decade is a factor of 10 in frequency. Frequencies will be logarithmically spaced.

11

Example 3: AC Analysis and Frequency Response

Consider the circuit in EX2. Suppose we take the output as the voltage across the resistor,V(2). The circuit then becomes a low-pass filter (L is a short circuit at DC and is an open-circuitat high frequencies). In order to simulate the frequency response magnitude and phase betweenDC (f=0) and 1 kHz, the following code would be used.

*EX3.sp

V 1 0 AC 1

L 1 2 10m

R 2 0 15

.ac lin 200 1 1000

.options post

.probe mag=par(’vm(2)/vm(1)’) phase=par(’vp(2)-vp(1)’)

.end

Note that since the analysis cannot be performed at f=0, we have begun the analysis at 1 Hz.This will produce 3 decades in the plot (1-10-100-1000 Hz). Run the code through Hspice andbring up AvanWaves. Go to the Results menu and select to plot parameter ”mag”. Notice theparameter ”mag” is the calculation of the following formula

vm(2)/vm(1)

This gives you a plot of the frequency response magnitude, the magnitude of v(2) dividedby the magnitude of v(1). To obtain a plot of the phase response, plot the parameter ”phase”.Notice this calculates the following formula

vp(2) - vp(1)

the phase of v(2) minus the phase of v(1). Now that you have plots of both the magnitude andphase of the frequency response, you can use the cursors to find the coordinates of any point oneither graph. For example, suppose you wanted to determine the half-power frequency from thegraph to compare to its theoretical value. The theoretical value of the half-power frequency is

fHP = R/2πL = 238.7 Hz

Using the cursor to find the point where the magnitude is 0.7071, the corresponding frequency isfound to be 238.6 Hz. Note that at that frequency, the phase has a value of -45 degrees.

12