Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Introduction to Hspice

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

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 le with a text editor (such as vi or emacs). Your .cshrc le 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 les, see the VI editor tutorial in the EE61 Course-Pak. Once you have modied your .cshrc le and saved it to your home directory, log o and re-login.

General Description

The name of a Hspice circuit le must be of the form name.sp (The .sp sux is required). A circuit le for Hspice begins with a Title which contains comments such as the name of the circuit le and ends with the .END statement. After the Title, the Circuit Description is given, then the Analysis Description, and nally 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 le editing. The order would be; Title Circuit Description Analysis Description Output Description .END 1

A brief description of the three parts of the Hspice le between the Title and .END statement will be presented. However, only those parts needed for the application of Hspice to devices are included. General circuit analysis is provided in numerous books such as the four above. Numbers for Hspice les may be expressed as integers (eg. 5,5), oating point (eg. 5.163), or in scientic notation (eg. 5.1E3). The suxes for Hspice corresponding to standard engineering notation are: F=1E15 (femto) P=1E12 (pico) N=1E9 (nano) U=1E6 (micro) M=1E3 (mili) K=1E3 (kilo) MEG=1E6 (Mega) G=1E9 (Giga) T=1E12 (Tera) MIL=25.4E6 (0.001 inch). The units used are: V (Volt), A (Amp), HZ (Hertz), OHM (Ohm), H (Henry), F (Farad) and DEG (degree). Distances are given in meters. In Hspice les, continuation of a line is preceded by a plus (+) sign and comment lines are preceded by an asterisk (*).

Circuit Description

The circuit description species the circuit elements and sources. The nodes of the circuit elements and sources are given by integer numbers with 0 reserved for ground. Hspice identies a circuit element or source by the rst letter on the e lement or source 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 MESFET C capacitor D diode E voltage-controlled voltage source F current-controlled current source G voltage-controlled current source H current-controlled voltage source I independent current source J JFET K mutual inductors (transformers) L inductor M MOSFET Q bipolar junction transistor R resistor S voltage-controlled switch T transmission line V independent voltage source W current-controlled switch

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 ow from the positive node N+ to the negative node N- within the element. The product of the current (through) and voltage (across) will be positive for a resistor since the power absorbed by a resistor is always positive. However, the current through a DC source will be 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 ows from the N+ node through the current source to the N- node.

Example 1: DC Sources and Avan waves Exploration


Create a le 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 le 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. You will be prompted for the name of the Hspice le you wish to simulate. Enter input file name: 3

After you enter your Hspice le name, Hspice will then prompt you for the output le name. Output file name [ex1.lis]? You may simply hit return and a default le name will be used. Notice that the default output le has the same name as the input but with the sux .lis. youll encounter few more prompts, but you can simply hit return and use the default options. At this point, Hspice should be running and an execution window will appear for a few moments as the circuit is being simulated. After execution is complete, the UNIX prompt will reappear. If Hspice cannot complie the input le you will 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 your Hspice input le and correct the error. Also you can open the output le using a text editor to view error messages from Hspice, which could be helpful in debugging your input le. Once your circuit simulates properly youll receive the message info: ***** hspice job concluded

Now that Hspice has been executed, you can view your results by executing AvanWaves. You do this by typing awaves at the unix prompt. This will bring up the AvanWaves window. The text 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... with the left mouse button. The open submenu should appear. Select ex1.sp and then ok. You should now 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 the voltage 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 on the Avanwaves window. Select Add under the Panel heading of the text menu bar. Next from the results browser, double click on I(V1) to display the plot on the second panel. Your should now 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 print window pops up, you have the option of selecting whether you want to obtain a hard copy or write it to a .ps or .eps le which can be later used in a latex le. If you choose Printer, your plot is now queued on the line printer in room 161. You should now go back to the AvanWaves window and explore the various functions available on both the text menu bar and the icon menu bar. Many of the commands available in the text menu 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 should observe a cross-hair tracing the line on the graph following the movement of your mouse. Notice the changing value of the coordinates shown on the upper right-hand of AvanWaves window. One more click will allow you to label the point located under the cross-hair. You can nd label formatting features by clicking Measure Label Options on the Measure part of the text menu. Similarly the fth icon in the menu bar Two Points Measure will allow you to measure the dierence between two points on a plot. Click once on the Two Points Measure icon. Notice the same cross-hair tracing the line on the graph. Position the cross-hair on the rst point and click once with the center mouse button. Next, youll observe a second cross-hair connected to 5

the rst by a line with varying length depending on the location of the second point. Click once more once you place the second cross-hair over the second point. You will now observe a label with 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 le called ex1.lis which is read by Avanwaves. Specically, for the circuit shown above the .options post command line instructs Hspice to write the voltage at every node and the current owing through each voltage source. However, in order to obtain other parameters such as the the current owing through R1, we need to utilize the .probe control line. Add the following line before the .end line of EX1.sp le: .probe I(R1) After running Ex1.sp le 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 line has ve parameters (in general): tstep, tstop, tstart, tmax, and uic. The syntax for the .tran control line is .tran tstep tstop tstart tmax uic The rst two parameters (tstep and tstop) are required. A reasonable value for tstep is 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 the plots produced by Hspice are not smooth and additional points may be desired. If more points is desired, the parameter tmax must be used. The use of tmax is described and illustrated in Example 2. When plotting waveforms, you should question how many points are necessary to produce an accurate plot. In the case of DC voltages and currents, only two points are required for any time interval! 3.1.1 Analysis of DC Circuits and .lis Files
tstop 100 .

When analyzing DC circuits using a single value for the independent sources, viewing the results with AvanWaves is relatively useless since all voltages and currents are constant. In order to obtain the DC analysis results in this case, add a .op command in your input le and simply examine the output le (le.lis) using a text viewer. The output le contains the circuit description, DC node voltages, voltage source currents, total power dissipated, as well as useful error messages. Open the le 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 of values of time Tj and voltage Vj . The element line is given by

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 piecewise linear voltage source between node 1 and ground with an initial voltage of 5 V at t = 0 nsec and remains at 5V until 10 nsec. Then it goes from 5 V at 10 nsec to 5 V at 10.2 nsec. Piece-wise current sources are parameterized in a similar manner as piece-wise linear voltage sources.

3.3

Pulse Source

A voltage pulse is specied 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 current pulse. The model parameters for pulse sources are given in Table 1.2. In Table 1.2, TSTEP and TSTOP are the values given in the .TRAN control line. Figure 4 illustrates these parameters.

Table 2: Model Parameters for Pulse Source Parameters V1 (initial value) V2 (pulsed voltage) TD (delay time) TR (rise time) TF (fall time) PW (pulse width) PER (period) Default Value must specify must specify 0 TSTEP TSTEP TSTOP TSTOP Units Volts or Amps Volts or Amps sec sec sec sec sec

Figure 4: Parameters for Pulse Waveform

3.4

Sinusoidal Source

A sinusoidal voltage waveform is specied by the element line: VXXXXXX N+ N SIN(VO VA FREQ TD DF PHASE), where the parameters are given in the following table.

Parameter VO (oset value) VA (amplitude) FREQ (frequency) TD (start delay) DF (damping factor) PHASE (phase angle)

Default Value Required Required 1/TSTOP 0 0 0

Unit Volt or Ampere Volt or Ampere Hertz second 1/second degree

TSTOP refers to the stop time in the transient analysis specied by the .tran control line. The sinusoid 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 is 159.155 Hz and the period T is 6.283 ms. It is important to consider how much total time over which to perform the analysis as well as the time increment between analysis points. In order to capture approximately three cycles of the response, we will choose tstop = 20 ms. Varying the parameter tstep has no eect. 50 points (default) will be plotted in AvanWaves. Compile the following 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 this circuit? 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. Also notice 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 dissatised 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. Recall that 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 of analysis points is (min) numpoints =
tstoptstart 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 =
tstoptstart tmax

20m 100u

= 200

Try this .tran control line in your Hspice code for the circuit of Example 2 and observe the traces produced in AvanWaves. You can reduce tmax further if you wish, but be aware that as you reduce tmax, computation time increases. Hspice can be used to determine the frequency of the sinusoids in a number of dierent ways. One approach is to use the Two Points Measure capability as investigated in EX1 to determine the time dierence between two successive peaks. This will provide an estimate of the period, which can be inverted to estimate the frequency. There are a number of mathematical operations available in AvanWaves that can be used to manipulate waveforms. For example, suppose you wanted to obtain a graph of the power delivered by the voltage source in EX2: (V (1) I (R)). You could produce the graph by selecting Expressions under the Tools text menu. Also you can bring up the expressions window by using the button labeled f(x,y). Make sure that you also have the results browser window open at the same time so that you can utilize the parameters listed within it. In the expressions window, make sure that the cursor is in the Expression line, then in the results browser window, select V(1) with a single click 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 to the 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. This should plot the newly created expression. There is yet another, perhaps easier, method to perform mathematical operations to manipulate waveforms. Inside your .sp input code ou can add the expression to the .probe line as another parameter to be calculated and provided for AvanWaves to read. For example, the syntax of parameter 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 nd this new new calculation in the results browser window of AvanWaves under Types column in the group params There are many waveform analysis features available in Hspice. You should make a habit of exploring the capability of Hspice each time you use the software.

4
4.1

Analysis Description
DC Analysis

With semiconductor devices, it is often desirable to vary a DC voltage to generate I -V characteristics. The .DC control line is given by .DC VXXXXX1 Start Stop Inc <VXXXXX2 Start2 Stop2 inc2>, where VXXXXX1 is the rst DC independent voltage source to be varied. The initial voltage is given by Start, the nal voltage is given by Stop, and the increment size in each step is given by Inc. A second optional source may be specied by VXXXXX2. When two sources are specif the nal voltage for each value of the second source. Either of these voltage sources could replaced by current sources. For example, the base current of a bipolar junction transistor could be swept from 10 A to 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 time of the last transient analysis is STOP. The default value of TSTART is zero and designation of a value may 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 frequency response 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 the highest frequency. DEC will make Hspice divide the frequency range into decades, with ND points per 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 lter (L is a short circuit at DC and is an open-circuit at high frequencies). In order to simulate the frequency response magnitude and phase between DC (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 and bring up AvanWaves. Go to the Results menu and select to plot parameter mag. Notice the parameter 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) divided by 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 and phase of the frequency response, you can use the cursors to nd the coordinates of any point on either graph. For example, suppose you wanted to determine the half-power frequency from the graph to compare to its theoretical value. The theoretical value of the half-power frequency is fHP = R/2L = 238.7 Hz

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

12

You might also like