HDL Manual

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 11

EECE 321 Lab 1: Circuit Simulation with PSPICE

Page 1 of 11

Laboratory Goals

 Introduce text-based PSPICE as a design tool


 Create transistor circuits using PSPICE
 Simulate output response for the designed circuits
 Introduce the Tektronics 571 Curve Tracer functionality.

Pre-lab reading

 Read the pre-lab introduction below


 Visit the Cadence website (maker of PSPICE)

Equipment needed

 Lab notebook, pen


 Workstation PC, with PSPICE application

Parts needed

 No electronic parts are needed for this lab

Lab safety concerns

 There are no specific safety concerns for this lab


EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 2 of 11

1. Pre-Lab Introduction

SPICE is an acronym for Simulation Program with Integrated Circuit Emphasis. The
original SPICE program was developed at the University of California Berkley in the
1970s. Computer aided simulation is common practice in industry and is a very
useful tool. SPICE is useful way of verifying your lab test results, and experimenting
with changes to your own circuit designs. It is also widely used in industry for
simulating designs prior to production Internal numerical accuracy of programs such
as SPICE is very high with errors that seldom exceeding 1%.

Transistor circuit analysis is burdensome as the number of transistors increases


beyond more than a few. Consequently SPICE is used to test and simulate complex
transistor circuits. There are several versions of the SPICE software now available.
Aim Spice and PSPICE are two versions. PSPICE is a graphical simulator, whereas
Aim Spice is text based. All SPICE programs are based on the core SPICE
programming.

While PSPICE makes extensive use of part libraries, Aim Spice uses text entries.
Circuits may contain passive components such as resistors, capacitors, and inductors,
and active devices such as transistors and diodes as well as independent voltage and
current sources. To write code describing a circuit, nodes must be defined in the
code. With nodes clearly defined, various elements are then connected between
nodes to specified values. SPICE allows the user to perform various analysis of the
circuit such as nonlinear dc, large-signal time domain (transient), small-signal
frequency domain, nonlinear transient, and linear ac analyses. The dc and transient
analysis capabilities are of greatest interest for digital circuit studies. In addition to
performing the differing analysis types, SPICE also generates graphical outputs for
which the various nodes and inputs can be graphed individually or together. SPICE
software is based on the same logic core in which the code is either manually
generated as with Aim Spice, or converted from a graphical representation by the
software as PSPICE does. A netlist file is manually written when using Aim Spice,
whereas PSPICE generates the netlist file containing the circuit elements and their
interconnections for you based on the graphical representation.

Despite the accuracy of computer simulation, hand analysis is still necessary. SPICE
simulation is a tool to enhance circuit analysis not replaces hand computations. For
instance, hand calculations are the best method for developing appropriate simulation
time intervals or rise times for a given circuit.

A curve tracer is a special type instrument similar to an oscilloscope designed to


display voltage-current characteristics of three terminal devices such as transistors.
The graphical display of an oscilloscope enables a user to easily view and identify the
operating regions for a specific transistor and see how quickly the transistor saturates.
EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 3 of 11
2. Pre-Lab Circuit Analysis

 Calculate voltages and currents by hand for Circuit 1 shown below


 Calculate Id, VGS AND VDS if Kn = 500 A/V2, and W/L = 1, VTN = 1V for Circuit 2
shown below
 Calculate Id, VGS AND VDS if Kp = 250 A/V2, and W/L = 1, VTN = -1V for Circuit 4
shown below

3. PSPICE Design and Simulation for Circuit 1

(Refer to Figure 1 below)

Figure 1 – PSPICE Schematic of a Resistive Network

You will be following along with your teaching assistant’s presentation during this lab

 Create a folder in My Documents for your PSPICE designs to be stored. Use


your last name in the folder name
 Open the PSPICE application called Pspice AD located under the Cadence menu
from the Program Menu of the Start Button
 Rather than graphically drawing a circuit, you are now presented with a plain text
notepad to write code describing the circuit (if a blank page does not
automatically load create one by selecting “File New Text File” or by clicking the
“New” icon in the upper left corner below the File drop down menu
 Save your circuit by selecting the “Save As” option from the File drop down
menu and save the file in your directory as a .cir file
 SPICE requires the first line be a text title in which you can identify the circuit
you are modeling
 Standard C language commenting may be incorporated in your netlist as well as a
* to indicate the line is for commenting purposes only
 Type the following line:
.lib "nom.lib"
EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 4 of 11
Directing the software to load the standard PSICE libraries
 Next, create your voltage source by entering vin 1 0 dc 10v
 SPICE identifies each element in a circuit by node numbers and values with
ground usually given a zero node number
 Enter resistor r1 by typing r1 1 2 .47k which identifies the resistor to connect
nodes one and two with a resistance of 470 ohms.
 Likewise for the remaining resistors enter the following lines of code:
r2 2 0 1.5k
r3 2 3 .56k
r4 3 0 2.2k
.op
 The .op line indicates that an dc analysis of the circuit should be performed
 In order to run the analysis, click on the simulation queue button on the left side
of the screen. If not already available from the file drop down menu add the
simulation file you have just created and click on the run simulation button (in
order to view your saved file you may have to change the file type to a circuit
file). Once the circuit is available in the circuit simulation queue, either click the
run queued items button or select Run from the Simulation drop down menu
 After running the simulation, the Simulation Queue menu will tell you if your
simulation is complete as well as if there any errors
 The results of the analysis can be seen by selecting the “View Output File” button
or by selecting Output File from the View drop down menu
 The Output File will display the circuit code, as well as node voltages
 Currents can be calculated using Ohm’s law using the generated node voltages
 To print your circuit analysis select the Print option from the File drop down
menu
 Compare the simulation results to your hand computed analysis from the pre-lab

4. PSPICE Design and Simulation for Circuit 2

(Refer to Figure 2 below)


EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 5 of 11
Figure 2 NMOS Circuit
 Using the same techniques as for the simple circuit, more complicated circuits can
also be analyzed using SPICE.
 Open a new page and once again save the file as a .cir file
 For circuit two shown above, the physical parameters are Kn = 500 A/V2, and
W/L = 1, VTN = 1V
 The nodes are labeled as shown with the ground of the circuit node zero
 Enter a text line identifying the circuit
 Both Vdd and V- must be identified in the circuit as follows:
vdd 5 0 dc 5
v- 1 0 dc –5
 As before each resistor must be entered. Resistor labels do not have to consist
entirely of numbers and can directly be entered as labeled Rd and Rs
rd 5 4 2k
r1 5 2 60k
r2 2 1 40k
rs 3 1 1k
 Just as r identifies and element as a resistor, other circuit elements must also be
identified. A transistor can be labeled by m. The given transistor is coded as:
m1 4 2 3 3 ntype l=1.0u w=1.0u
.model ntype nmos level=2 vto=1 kp=1e-3
The two lines of text identify all of the transistor parameter values
 More than one transistor may be included in a circuit just as more than one
resistor, and multiple transistors are numbered accordingly m1, m2, etc. A
transistor is a three terminal device and its connecting nodes are identified as the
drain, gate, source, and body. By convention the source and body are shorted
together. The .model line specifies the ntype label identifies an NMOS. The level
corresponds to various transistor circuit parameters, and the rest of the line
identifies the turn on voltage and Kn values
 As before a DC analysis is performed on the transistor giving a list of the various
node voltages
 Using the node voltages, the desired Vgs and Vds values can be obtained by
subtracting appropriate nodes
 As before Id may also be obtained by using the specified node voltages and
applying ohm’s law
 Print the circuit code as well as simulation results to be included with your lab
report
EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 6 of 11
5. PSPICE Design and Simulation for Circuit 3

(Refer to Figure 3 below)

Figure 3 2 Input NAND Circuit


 A two input NAND circuit combines four transistors to perform the logic
function. SPICE modeling may be used to verify the circuit function as opposed
to analyzing the circuit by hand
 Open a new page
 For circuit three shown above, the transistor parameters are Kn = 50 A/V2, and
l=2u, w=8u, VTN = 0.6V and VTP = -0.6V.
 The nodes are labeled as shown with the ground of the circuit node zero
 Enter a text line identifying the circuit
 The circuit voltage Vdd may be identified in the circuit as follows:
vdd 1 0 dc 5
 In addition to the voltage, source pulses must be generated to correspond to the
various logic states
 This can be done as follows:
vina 2 0 dc pulse(0 5 0us 0.001us 0.001us 40us 80us)
vinb 3 0 dc pulse(0 5 20us 0.001us 0.001us 40us 80us)
 The first two pulse properties are the low and high voltages respectively. The
following number specifies the time delay, which allows you to offset the two
pulses so they do not occur simultaneously. The following two numbers identify
the rise and fall times of the transistors respectively. The final two numbers are
the pulse width and period. These two parameters can be set to distinguish
between different input pulses.
EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 7 of 11
 All four transistors must be identified with their connecting nodes labeled which
is accomplished by:
m1 4 2 5 5 cmosn l=2u w=8u
m2 5 3 0 0 cmosn l=2u w=8u
m3 4 2 1 1 cmosp l=2u w=8u
m4 4 3 1 1 cmosp l=2u w=8u
 Two .models are required to describe both the NMOS and PMOS transistors
included in the circuit:
.MODEL cmosn nmos LEVEL=2 VTO=0.6 KP=50u
.MODEL cmosp pmos LEVEL=2 VTO=-0.6 KP=50u
as well as their parameters
 However, before the .models are specified an output capacitance is required to
accurately model the gate. The included capacitor is specified in SPICE as
c1 4 0 100f
For a capacitor between nodes 4 and 0 with a capacitance of 100fF
 For the NAND circuit, a transient analysis is performed with a step size of 1u and
a final time of 80u.
 Node voltages may be plotted individually or all on the same graph for
comparison
 The following directions apply to circuits 3 through 6
 To graph the results on the screen in SPICE you must add the line of code after
the .probe statement but before the .end statement:
.TRAN | print step value | final time value | no print value | step ceiling value

This is the parameters for .tran. You will need to figure out what the values for the
parameters are, and the default units is seconds for these parameters.
After using this line, a blank screen graph plot will pop up on the screen. To graph
your plots, you must press the add trace button on the menu. Once you press
this button, the screen below will pop up:

On the box to the left, each voltage you click on will represent one item being
plotted on the previous graph. The result should look something like this:
EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 8 of 11

This is, of course, is just an example graph but your circuit inputs and outputs should
look something like a square wave. To print this graph you can simply use print,
or if you like you may use the Microsoft paint program to capture a screenshot by
pressing print screen, then cut and paste it into your report.
 Print the circuit code as well as simulation results to be included with your lab
report
 In order to print the plots, they first must be saved by choosing the save plots
option from the file drop down menu
 The saved plots may then be opened and printed or screenshots may also be taken
and saved in a Word document

6. Curve Tracer Tutorial

For this portion of the lab, you will be directed to watch the teaching assistant present a
curve tracer tutorial introducing you to the features and functionality of a curve tracer.
Using a sample transistor you will be shown how to generate an I-V curve for the
transistor so that you will be able to use the curve tracer in future labs to verify your
results.
EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 9 of 11
7. PSPICE Design and Simulation for Circuit 4

(Refer to Figure 4 below)

Figure 4 PMOS Circuit


 Write the code to perform a SPICE simulation of the given circuit. In this PMOS
circuit, calculate Id, VGS AND VDS if Kp = 250 A/V2, and W/L = 1, VTP = -1V.
Label the nodes and enter the device parameters and then perform a dc analysis
 Print your source code as well as voltage outputs and use these results to compute
the desired information. Include both your simulation results and computations in
your lab report

8. PSPICE Design and Simulation for Circuit 5

(Refer to Figure 5 below)

Figure 5 3 Input NOR Circuit


EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 10 of 11

 Write the code to perform a SPICE simulation of the given circuit


 As before label each node and transistor
 As shown in Circuit 3, input pulses must be generated to correspond to the
various logic levels. Use the same transistor parameters as before
 Perform a transient analysis plotting the output voltage as well as the input
waveforms
 Include in your lab report a diagram indicating how you labeled the nodes and
transistors, your source code as well as the simulation outputs
 It is not necessary to understand the logic, which enables this circuit to work, but
rather the purpose is to become proficient in modeling and simulating transistor
circuits using SPICE.

9. PSPICE Design and Simulation for Circuit 6

(Refer to Figure 6 below)

Figure 6 2 Input XOR Circuit

 Write the code to perform a SPICE simulation of the given circuit


 As before label each node and transistor
 Input pulses must be generated to correspond to the various logic levels. Use the
same transistor parameters as before
 Perform a transient analysis plotting the output voltage as well as the input
waveforms
 Include in your lab report print outs of your source code with a circuit schematic
labeling your nodes and transistors as well as the simulation output graphs
EECE 321 Lab 1: Circuit Simulation with PSPICE
Page 11 of 11
 It is not necessary to understand the logic, which enables this circuit to work, but
rather the purpose is to become proficient in modeling and simulating transistor
circuits using SPICE

10. Analysis

Write a brief summary report for this lab. Be sure to also include the following
topics:

Compare the results from your pre-lab computations to the PSPICE models you
created. Record your findings in your lab notebook

Include print outs of the code, circuit diagrams with nodes labeled and simulation
results.

Explain any difficulties you had with this lab. (Please include suggestions to improve
the lab, if you have them).

You might also like