0% found this document useful (0 votes)
14 views11 pages

Tutorial 1

The document provides an overview of NGSPICE, an open source circuit simulator. It discusses downloading and installing NGSPICE, the general structure of a netlist, and provides examples of using NGSPICE for DC, transient, and subcircuit analyses. The document also outlines some quick keys for using NGSPICE.

Uploaded by

Girija M Hegde
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)
14 views11 pages

Tutorial 1

The document provides an overview of NGSPICE, an open source circuit simulator. It discusses downloading and installing NGSPICE, the general structure of a netlist, and provides examples of using NGSPICE for DC, transient, and subcircuit analyses. The document also outlines some quick keys for using NGSPICE.

Uploaded by

Girija M Hegde
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/ 11

CMOS Digital Design

Tutorial - NGSPICE

TAs:
Adithya Sunil Edakkadan
Ishan Acharyya

Instructor: Prof. Abhishek Srivastava


About NGSPICE, download and install
SPICE : Simulation Program with Integrated Circuit Emphasis
NGSPICE is an open source mixed-signal circuit simulator which
can be used to perform different analysis on a circuit
For SPICE, any circuit is described as an interconnection of
various active, passive elements. This interconnection of elements
is also called Net-List
Parameters to capture physical behaviour of active devices can be
included as Model File. For example BSIM1 to BSIM6 are
SPICE models for various types of transistors developed by UC
Berkley (Berkeley Short-channel IGFET Model)
DC, transient, AC, pole-zero, noise, PSS - analysis can be
performed using NGSPICE
Result plots can be viewed and saved
Download NGSPICE from following path and install:
http://ngspice.sourceforge.net/download.html
NGSPICE manual can be also downloaded from the same site
1 / 10
General structure of a Net-List

Circuit description
Models used to describe circuit elements may be included
Type of analysis to be done on the circuit
Control commands to run the simulation and plot/save the results
Note: Commands in NGSPICE are case insensitive

2 / 10
Example to illustrate NGSPICE usage

Net list of simple RC circuit


R1
Simple RC low pass configuration in out
* First line is the title. ‘*’ used for comments + +
* Circuit discription Vin C2 Vout
R1 in out 1k
C2 out 0 1nf - -
* input pulse
vin in 0 pulse 0 5 0ns 100ns 100ns 10us 20us V v(out) v(in)

5.0

* Type of analysis is transient


.tran 10n 60u 4.0

.control 3.0

run
plot v(in) v(out) 2.0

* Saving plots to ps file 1.0

hardcopy rc_ckt_tr_out_1.eps v(in) v(out)


.endc 0.0
0.0 10.0 20.0

time
30.0

us
40.0 50.0 60.0

3 / 10
Example to illustrate DC analysis
MOS IDS -VGS curve
IDS

G D
MN + V
(1.8u/0.18u) − DS
VGS
Netlist to evaluate MOS ID -VGS characteristics S
.include TSMC_180nm.txt
.param SUPPLY=1.8
.param LAMBDA=0.09u uA -vds#branch

.param width_N={20*LAMBDA} 1000.0


.global gnd vdd
VGS G gnd ‘SUPPLY’
VDS D gnd 1V 800.0

M1 D G gnd gnd CMOSN W={width_N} L={2*LAMBDA} +


AS={5*width_N*LAMBDA} PS={10*LAMBDA+2*width_N}
AD={5*width_N*LAMBDA} 600.0

PD={10*LAMBDA+2*width_N}
.dc VGS 0 1.8 0.05 400.0

.control
run
plot -VDS#branch 200.0

set hcopypscolor = 1 *White background


hardcopy mos_id_vg.eps -VDS#branch
.endc 0.0
0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8

v-sweep V

4 / 10
Figure: I Vs V
Example to illustrate Transient analysis
Vdd
CMOS Inverter transient analysis
MP
(1.8u/0.18u)
Vin Vout
CMOS inverter transient response x y
.include TSMC_180nm.txt
.param SUPPLY=1.8 MN
.param LAMBDA=0.09u (0.9u/0.18u) 100 fF
.param width_P=20*LAMBDA
.param width_N=10*LAMBDA
.global gnd vdd V v(y) v(x)

Vdd vdd gnd ’SUPPLY’ 2.0

vin x gnd pulse 0 1.8 0ns 1ns 1ns 10ns 20ns


M1 y x gnd gnd CMOSN W={width_N} L={2*LAMBDA} + 1.5

AS={5*width_N*LAMBDA} PS={10*LAMBDA+2*width_N}
AD={5*width_N*LAMBDA} PD={10*LAMBDA+2*width_N}
M2 y x vdd vdd CMOSP W={width_P} L={2*LAMBDA} + 1.0

AS={5*width_P*LAMBDA} PS={10*LAMBDA+2*width_P}
AD={5*width_P*LAMBDA} PD={10*LAMBDA+2*width_P}
0.5

Cout y gnd 100f


.tran 0.1n 200n .control
0.0

run
plot v(y) v(x)
set hcopypscolor = 1 -0.5
0.0 50.0 100.0 150.0 200.0

hardcopy inv_transient_resp.eps v(x) v(y) time ns

Figure: Transient response of


CMOS Inverter 5 / 10
Example to illustrate .SUBCKT usage
Describing CMOS inverter using subckt
Vdd
CMOS inverter transient response
.include TSMC_180nm.txt (1.8u/0.18u)
VDD
.param SUPPLY=1.8 MP
.param LAMBDA=0.09u
.global gnd vdd a b
Vdd vdd gnd ’SUPPLY’ x y
vin a gnd pulse 0 1.8 0ns 1ns 1ns 10ns 20ns MN
100 fF
.subckt inv y x vdd gnd width_P=20*LAMBDA (0.9u/0.18u)
GND
width_N=10*LAMBDA
.param width_P=20*LAMBDA
.param width_N=10*LAMBDA V v(y) v(x)

2.0
M1 y x gnd gnd CMOSN W={width_N} L={2*LAMBDA} +
AS={5*width_N*LAMBDA} PS={10*LAMBDA+2*width_N}
AD={5*width_N*LAMBDA} PD={10*LAMBDA+2*width_N} 1.5

M2 y x vdd vdd CMOSP W={width_P} L={2*LAMBDA} +


AS={5*width_P*LAMBDA} PS={10*LAMBDA+2*width_P}
AD={5*width_P*LAMBDA} PD={10*LAMBDA+2*width_P} 1.0

.ends inv
x1 b a vdd gnd inv width_P=20*LAMBDA width_N=10*LAMBDA 0.5

Cout b gnd 100f


.tran 0.1n 200n .control 0.0

run
plot v(b) v(a) -0.5
0.0 50.0 100.0 150.0 200.0
set hcopypscolor = 1 time ns

hardcopy inv_transient_resp_subckt.eps v(b) v(a)

Figure: Transient response of 6 / 10


Quick keys I

To launch NGSPICE
ngspice : It will take you to ngspice shell
ngspice file_name.<cir or sp> : It will execute the specified
net-list
Type quit or exit to end the ngspice shell
To execute a net-list in ngspice shell
ngspice —> source filename
To edit in ngspice shell
ngspice —> edit file_name ; :wq! to save and quit editing
To run an analysis specified in net-list in ngspice shell
ngspice —> run
To plot in ngspice shell
use ‘plot’ command

7 / 10
Quick keys II

To plot voltages
ngspice —> plot v(node_name)
Ex. plot v(out) v(in)
To plot branch currents
plot voltage_source_name#btranch
Ex. plot VDS#branch
– Note that direction of current is entering into the positive
terminal of a voltage source
– If required a dummy 0 V DC source can be inserted in the
net-list to plot branch current
To save plots as ps
hardcopy file_name.eps variables_to_plot
Ex. hardcopy inv_transient_resp.eps v(x) v(y)
To change background colour of saved plot
set hcopypscolor = 1 *White background
8 / 10
Quick keys III

To change background colour plot window


set color0=white ** color0 is used to set the background of the
plot (manual sec:17.7))
set color1=black ** color1 is used to set the grid color of the plot
(manual sec:17.7))
Specifying pulse
vin in+ in- pulse VLow VHigh delay rise-time fall-time on-period
time-period
vin in 0 pulse 0 5 0ns 100ns 100ns 10us 20us
Specifying sinusoidal signal
SIN(VO VA FREQ TD THETA PHASE)
Ex. vin a 0 sin(.849 0.25 50Meg 0 0)
DC analysis
.dc voltage_to_be_swept Vinitial Vf inal step_size
Ex: .dc vgs 0v 1.8v 0.1
9 / 10
Quick keys IV

Transient analysis
.tran step_size stop_time < start_time >
Ex: .tran 10n 60u
AC analysis
.ac lin number_of_points start stop
.ac lin 100 1 100Hz
Measure statement example (sec 15.4.5):
.measure tran tpdf
+ TRIG v(1) VAL=’SUPPLY/2’ RISE=1
+ TARG v(2) VAL=’SUPPLY/2’ Fall=1
measures the time difference between v(1) reaching ’SUPPLY/2’ V
for the first time on its first rising slope (TRIG) versus v(2)
reaching ’SUPPLY/2’ V for the first time on its first falling slope
(TARG), i.e. it measures the fall time delay between v(1) and v(2).
Refer NGSPICE manual for more details
10 / 10

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy