0% found this document useful (0 votes)
28 views7 pages

Exp 1

VJTI , PVLSI

Uploaded by

shreya khatu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views7 pages

Exp 1

VJTI , PVLSI

Uploaded by

shreya khatu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Aim: To study the commands and usage of ngspice circuit simulation software.

Theory: SPICE is an acronym for Simulation Program with Integrated Circuit Emphasis. It
was first developed at UC Berkeley, it is the origin of most modern simulators. NGSPICE is
an open source mixed-signal circuit simulator. It is the result of combining existing SPICE
features with some extra analyses, modelling methods and device simulation features. It is
freely available for use in Linux and Windows. NGSPICE requires to describe the circuit as a
netlist. A netlist is defined as a set of circuit components and their interconnections.
The ngspice simulator supports the following different types of analysis:
1. DC Analysis (Operating Point and DC Sweep) 2. AC Small-Signal Analysis 3. Transient
Analysis 4. Pole-Zero Analysis 5. Small-Signal Distortion Analysis 6. Sensitivity Analysis 7.
Noise Analysis
We can use any text editor (say, gedit) to write our circuit netlist. The first line in an NGSPICE
file is not executed. It is used to describe the aim of the circuit being simulated. All NGSPICE
comments start with an asterix, i.e. ‘*’. The NGSPICE file comprises of the circuit netlist
followed by the details of the analysis the user wishes to do. NGSPICE files are usually saved
with the extension ‘.cir’ or ‘.spice’. Circuit components are identified by their first letter of
naming, called prefix, i.e. resistors begin with r, capacitors with c, bipolar transistors with q,
MOSFETs with m, voltage sources with v and so on. All circuit nodes are named/numbered.
The netlist requires one ground node (zero potential).
DC Analysis: The DC analysis portion of ngspice determines the dc operating point of the
circuit with inductors shorted and capacitors opened. DC analysis options are specified on the
.DC, .TF, and .OP control lines.
Transient Analysis: Transient analysis is an extension of DC analysis to the time domain. A
transient analysis first obtains a DC solution to provide a point of departure for simulating time-
varying behavior. Once the DC solution is obtained, the time-dependent aspects of the system
are reintroduced, and the two simulator algorithms incrementally solve for the time varying
behavior of the entire system
The transient time interval is specified on a .TRAN control line.
General Structure and Conventions
The circuit to be analyzed is described to ngspice by a set of element instance lines, which
define the circuit topology and element instance values, and a set of control lines, which define
the model parameters and the run controls. All lines are assembled in an input file to be read
by ngspice. Two lines are essential:
• The first line in the input file must be the title, which is the only comment line that does not
need any special character in the first place.
• The last line must be .end
The order of the remaining lines is alomost arbitrary (except, of course, that continuation lines
must immediately follow the line being continued, .subckt ... .ends, .if ... .endif, or .control ...
.endc have to enclose their specific lines). Leading white spaces in a line are ignored, as well
as empty lines.
Circuit elements (device instances):
Each element in the circuit is a device instance specified by an instance line that contains:
• the element instance name,
• the circuit nodes to which the element is connected,
• and the values of the parameters that determine the electrical characteristics of the element.
The first letter of the element instance name specifies the element type. For example, a resistor
instance name must begin with the letter R and can contain one or more characters. Hence, R,
R1, RSE, ROUT, and R3AC2ZY are valid resistor names.
Ground node: The ground node must be named ‘0’ (zero). For compatibility reason gnd is
accepted as ground node, and will internally be treated as a global node and be converted to
‘0’.
Dot commands:
.AC start an ac simulation.
.CONTROL start a .control section.
.CSPARAM define parameter(s) made available in a control section.
.DC start a dc simulation.
.DISTO start a distortion analysis simulation.
.ELSE conditional branching in the netlist.
.ELSEIF conditional branching in the netlist.
.END end of the netlist.
.ENDC end of the .control section.
.ENDIF conditional branching in the netlist.
.ENDS end of subcircuit definition.
.FOUR Fourier analysis of transient simulation output.
.FUNC define a function.
.GLOBAL define global nodes.
.IC set initial conditions.
.IF conditional branching in the netlist.
.INCLUDE include part of the netlist.
.LIB include a library.
.MEAS measurements during the simulation.
.MODEL list of device model parameters.
.NODESET set initial conditions.
.NOISE start a noise simulation.
.OP start an operating point simulation.
.OPTIONS set simulator options.
.PARAM define parameter(s).
.PLOT printer plot during batch simulation.
.PRINT tabular listing during batch simulation.
.PROBE save device currents, voltages and differential voltages.
.PSS start a periodic steady state analysis.
.PZ start a pole-zero analysis simulation.
.SAVE name simulation result vectors to be saved.
.SENS start a sensitivity analysis.
.SP S parameter analysis.
.SUBCKT start of subcircuit definitions.
.TEMP set the ciruit temperature.
.TF start a transfer function analysis.
.TITLE title of the netlist.
.TRAN start a transient simulation.
.WIDTH width of printer plot.
Basic lines:
.TITLE line:
The title line must be the first in the input file. As an alternative, you may place a .TITLE line
anywhere in your input deck. The first line of your input deck will be overridden by the contents
of this line following the .TITLE statement.
.END Line:
The .end line must always be the last in the input file.
Comments:
General Form:
* < any comment >
Examples:
* RF =1 K Gain should be 100
* Check open - loop gain and phase margin
The asterisk in the first column indicates that this line is a comment line. Comment lines may
be placed anywhere in the circuit description
.MODEL Device Models:
General form: . model mname type ( pname1 = pval1 pname2 = pval2 ... )
Examples: . model MOD1 npn ( bf =50 is =1 e -13 vbf =50)
Most simple circuit elements typically require only a few parameter values. However, some
devices (semiconductor devices in particular) that are included in ngspice require many
parameter values.
mname in the above is the model name, and type is one of the following fifteen types:

Voltage Sources:
General form: VXXXXXXX N + N - < DC / TRAN VALUE > < AC < ACMAG < ACPHASE
> > > + < DISTOF1 < F1MAG < F1PHASE > > > < DISTOF2 < F2MAG < F2PHASE > > >
Examples: VCC 10 0 DC 6
n+ and n- are the positive and negative nodes, respectively. DC/TRAN is the dc and transient
analysis value of the source.
There are nine independent source functions:
• pulse, • exponential, • sinusoidal, • piece-wise linear, • single-frequency FM, • AM, • transient
noise, • random voltages or currents, • external data (only with ngspice shared library), • and
RF port
Pulse General form:
PULSE ( V1 V2 TD TR TF PW PER NP )
Examples: VIN 3 0 PULSE ( -1 1 2 NS 2 NS 2 NS 50 NS 100 NS 5)
Sinusoidal General form:
SIN ( VO VA FREQ TD THETA PHASE)
Examples: VIN 3 0 SIN (0 1 100 MEG 1 NS 1 E10)

plot i(v2) or plot i(vout) - It plots the current values of corresponding branch. Here we have
connect 0v voltage source in series(vs or v1),to find current in particular branch.
MOSFET devices
General form:
MXXXXXXX nd ng ns nb mname + < ad = val > < as = val > < pd = val > < ps = val > < nrd
= val > + < nrs = val > < ic = vds , vgs , vbs > < temp =t >
Examples: M1 24 2 0 20 TYPE1 M31 2 17 6 10 MOSN L =5U W =2U
The instance card for MOS devices starts with the letter ’M’. nd, ng, ns, and nb are the drain,
gate, source, and bulk (substrate) nodes, respectively. mname is the model name and m is the
multiplicity parameter, which simulates ‘m’ paralleled devices. All MOS models support the
‘m’ multiplier parameter. Instance parameters l and w, channel length and width respectively,
are expressed in meters. The drain and source diffusion areas are ad and as, in square meters
(m2 ).
Windows of ngspice:

Procedure:
1. Download and Install ngspice (MS Windows, 64 Bit)
2. Download the zip file for ngspice. Expand this zip file into directory C:\. In MS Windows
10 you might need admin rights to do so. Thus you will get C:\Spice64 with several sub-
directories.
3. Put the code lines into a text file named vdiv.cir and save it to the folder C:\Spice64\bin (If
you are with MS Windows). Now start ngspice by double click onto ngspice.exe in
C:\Spice64\bin. Load the netlist into ngspice by entering the command source vdiv.cir. ngspice
is now ready for simulation, the netlist is loaded.

You might also like