Aim Spice Tutorial v3
Aim Spice Tutorial v3
Aim Spice Tutorial v3
SPICE is the standard circuit simulator in the industry. You can code in your circuit schematic and SPICE
will compute a number of variables, such as DC node voltages, transfer curves, frequency response curves,
and transient analysis showing timing response of the circuit to pulsed or otherwise time varying input. It is
an invaluable tool in design and will also allow a student to probe the mysteries of electronics by giving you
the answers. We will download a SPICE version that is suitable for PCs (sorry Mac lovers like me).
There is a readme.txt file to help you, and there is a help icon within SPICE. Searching google for AIM
SPICE returns many sources of information.
1. Download AIM SPICE from a web site. You can find this site by typing “aim spice” on
the google search engine. Or you can go to http://www.aimspice.com/. Click on ‘download
software’. Click on the install file. If you are installing on the computers in Room ECE 211, install
to this directory “C\documents and settings (your profile)\Aimspice” You are ready to learn SPICE.
2. Creating a SPICE program of the circuit called a netlist. We will learn by example.
We will go to SPICE examples. Running one example successfully gets you 90% to the final goal. A bit of
practice setting up and running SPICE programs will make you an expert in a short time. Daily practice is a
good idea even if you’re just doing simple things.
Example-1
This is the simplest of circuits using a power supply and two series resistors. The schematic is below, and
the SPICE code is written below the circuit. SPICE requires that the first line be a title text. Each element in
the circuit (vdd, R1, and R2) is identified by node numbers and a value. Ground is usually given a zero node
number. You will type in the SPICE netlist inside the simulator program in a text editor similar to WORD.
The netlist is shown next to the schematic.
2V
Getting into SPICE and Writing the Code:
Double click on the file ‘aimspice.exe’. An untitled file will appear. Go to ‘save as’ in the file menu on top.
Save it as any name you want to give it. You will then notice that the file picked up an extension of ‘.cir’ A
*.cir is required for running SPICE. Now type in the lines of code as shown above for the circuit. Save the
file so you don’t lose your work.
The ‘OP’ icon on the top stands for operation, or operating (DC) voltages The AIM-Spice Toolbars in the
help section explain all of the icons. Click on the ‘OP’ icon. A dialog box showing the simulation statistics
will pop up, followed by an EXCEL looking file showing the computed node voltages. Congratulations!
You have just run your first SPICE circuit. Other icons give graphical outputs that can be used as is or copied
to a WORD, PowerPoint, or EXCEL file for more presentation flexibility.
OUTPUT
Example1 using vdd and resistors
Variables in circuit Values
v(1) 2V
v(2) 1.33333 V
i(vdd) -0.000133333 A
EXAMPLE –2
The SPICE code for the ac circuit below is given to the right of the circuit. Simulate a frequency
response curve.
1 R1 2 AC circuit
vin 1 0 1 ac
r1 1 2 10k
vin r2 2 0 50k
R2 C2
c2 2 0 1n
Click on the ‘AC’ icon. Several dialog boxes will pop up. For the “AC Analysis Parameters” box, enter the
following parameters and click on “run”:
LIN
Number of points=1000
Start frequency=0
End Frequency=200k
Click on “OK.” A second dialog box asks for the variables to plot. Look at your schematic and netlist and
select “magnitude plot” and “v(2) voltage” for the variable. You will get an x-y plot with no data. You will
get the plot in a moment. Now go under the “Control” menu at the top and click on “Start Simulation’. A
popup box appears giving run “Simulation Statistics.” Click on “OK” and the curve appears on the plot. The
‘format’ menu allows you to adjust the axis data marks or the legend. Auto-scale also does a good job.
You can plot the curve by double clicking inside the figure and it will expand to screen full scale. There are
two ways to copy the curve: (1) go to the ‘edit’ menu, click ‘copy’ for the plot graphic, and paste into a
WORD file, or (2) Go to the ‘file’ menu and click on ‘export to spreadsheet’ to put the data into an EXCEL
type file. Copy the data in the file (using keyboard commands -control-a and control-c) and paste into an
EXCEL file (control-v) for your further manipulation.
mag('v(2)')
1.0
0.8
0.6
Vout [V]
0.4
0.2
0.0
0.0K 50.0K 100.0K 150.0K 200.0K
Frequency [Hz]
EXAMPLE-3
Run the following nMOS circuit using the “OP” tool to give you a DC analysis. The number code for a
MOSFET is D G S B (that is m2 2 1 0 0 below)
Having Problems? The letter “l” is virtually identical to the number “1.” The line code for the nmos uses
length (l=1.0u) The processing constant kp in SPICE is not defined with a divide by two as your long channel
model does in the book. Divide the kp in SPICE by two, and your answer for transistor current should match
12.5 µ A. SPICE is doing a long channel analysis for Level=2.
OUTPUT
v(3) 3V
v(1) 1V
v(2) 2.375 V
i(vin) 0A
i(vdd) -1.25E-005 A
EXAMPLE-4
The simple CMOS inverter has two transistors, but great complexity. The voltage transfer curve plotting
VOUT versus VIN is fundamental. Write the SPICE netlist below (and watch your “l”), click on “DC” icon,
and plot the results.
OUTPUT Voltage Transfer Curve (Double click on the plot. Make the plot “pretty”, and then go to ‘edit’
menu, and ‘copy’. Then paste into a report.
'v(2)'
2.0
1.5
VOUT1.0
[V]
0.5
0.0
0.0 0.5 1.0 1.5 2.0
VIN [V]
SPICE trick: Plot v(2) and vin and you will get the transfer curve and a 45o line. The intersection defines the
logic threshold voltage (Vthr).
Final Time=60ns
'v(1)' 'v(2)'
2.5
2.0
1.5
vOUT [V]
1.0
0.5
0.0
-0.5
0n 20n 40n 60n
Tme [ns]
Observe that no capacitors were inserted in the transistor model description so no real timing analysis
occurred. Your delay in the curve is the increment defined in the plot. You will be emailed a model
description for p- and n-MOS transistors that includes capacitance and other parameters that make the
calculation more accurate.
Detailed Level=2 transistor parameters and CMOS inverter curve
'v(1)' 'v(2)'
4.0
3.0
VOUT [V]
2.0
1.0
0.0
-1.0
0n 5n 10n 15n 20n 25n
time [sec]