A Tool for Modeling and Analysis of Electronic Circuits and Systems

advertisement
A Tool for Modeling and Analysis of Electronic
Circuits and Systems
Ons Lahiouel, Henda Aridhi, Mohamed H. Zaki, and Sofiène Tahar
Department of Electrical and Computer Engineering,
Concordia University, Montreal, Canada
{lahiouel,h aridh,mzaki,tahar}@ece.concordia.ca
Technical Report
October, 2011
Abstract
Analog circuit models provided by the circuit simulator Simulation Program with Integrated
Circuit Emphasis offer the most accurate behavior of electronic circuits and systems. However,
those models as well as the program that performs the device characterization are not available for
researchers who need to have access to a mathematical description to perform optimization and
verification of circuits. Consequently, we need to automatically generate analog circuits mathematical models and provide means to change their model parameters and verify their effects. In
this report we present a tool for modeling and analysis of analog circuit implemented in MATLAB
Object Oriented. This tool takes as input a Netlist file and generates a circuit object that contains
all the circuit elements, their attributes and their connectivity. This circuit object together with
a set of library Mfiles that model devices and some user defined parameters and constraints are
input to an equations formulation step that implements Modified Nodal Analysis formulation and
generates MATLAB Mfiles, used for different circuit analysis. We show the application of our
proposed tool on a Differential Amplifier and a Rambus ring oscillator.
Key words : SPICE, Modified Nodal Analysis, Ordinary Differential Equation
1
Table of Contents
1 Introduction
3
2 Tool Description
2.1 Circuit Object Generation . . . . . . . . . . . .
2.1.1 Class Circuit . . . . . . . . . . . . . . .
2.1.2 Parser Implementation . . . . . . . . . .
2.1.3 Flat Circuit Object Generation . . . . .
2.2 MNA Object Generation . . . . . . . . . . . .
2.2.1 DC Analysis Preparation . . . . . . . . .
2.2.2 AC Analysis Preparation . . . . . . . .
2.2.3 Class MNA . . . . . . . . . . . . . . . .
2.2.4 Modified Nodal Analysis Implementation
2.3 Equations Generation . . . . . . . . . . . . . . .
2.3.1 DC Equations . . . . . . . . . . . . . . .
2.3.2 Differential Algebraic Equation . . . . .
2.3.3 Transfer Function . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
3
5
7
7
7
8
8
9
12
12
13
13
3 Applications
3.1 Rambus Ring Oscillator . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Differential amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
14
16
4 Conclusions
20
References
21
2
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
Introduction
SPICE [4](Simulation Program with Integrated Circuit Emphasis) is the industrystandard way to model and verify circuit operation at the transistor level before manufacturing an integrated circuit. The models of individual device components, algebraic
and differential equations that describe analog circuit behavior, are hard coded into the
SPICE tool. In fact, analog circuits mathematical model are just a set of Differential
Algebraic Equation (DAE) that can be transformed using certain techniques to Ordinary Differential Equations (ODE). The DC, transient, frequency or whatever type of
analysis of these circuits consist in applying numerical methods to the set of equations.
In this work a tool for modeling and analysis of analog circuit implemented in Matlab
Object Oriented (MOO) [3] is described. The tool parses Netlist file, recognizes circuit
components and generates a set of Ordinary Differential Equations through the application of Modified Nodal Analysis (MNA) [2]. In section 2 we illustrate our proposed
methodology and we give an overview about the parser that creates a circuit object
out of a SPICE Netlist file. Then, we detail the class MNA that is responsible for the
generation of the mathematical models of the circuit in different domains. Finally, we
provide the form of equations that we generate. In section 3 we show our experimental
results on a Differential Amplifier [5], a Rambus ring oscillator [6] and in section 4 we
present our conclusions.
2
Tool Description
Figure 1 provides the main components of the proposed tool. The necessary steps to
generate the circuit models are :
• Circuit object generation : it consists in reading the Netlist file content, recognizing the SPICE syntax (composed of elements and sub-circuits) and generating a
compact version of the circuit object that is structurally equivalent to the Netlist
description. After that, a flat circuit object is generated using the flattening
function.
• MNA object generation : this step modifies the flat circuit object to generate the
equivalent object for each type of analysis (DC, AC, noise analysis). The modified
flat circuit object is input to the generation of MNA object that implements MNA
formulation and generates the MNA object.
• Equation generation : this part takes the MNA object and generates MATLAB
Mfiles containing the mathematical models, taht can be used for different circuit
analysis.
2.1
2.1.1
Circuit Object Generation
Class Circuit
3
F ( x) = 0
H (s )
x = f ( x, t)
H (s )
Fig. 1: Proposed tool functionalities
The class circuit (Figure 2) is a MOO class used to define circuit, sub-circuits and
elements objects as they share the same properties defined as follows :
• Name : This field contains the name of the circuit written in the first line of the
input file.
• Node : This field is a cell array that contains the node of the circuit.
• Component : This field is a cell array of objects of type circuit. This property is
empty in case of elements.
• Parameter : This field is a cell array that can include parameter of nonlinear
components, parameter analysis, characteristic values, physical characteristics,
the current model name, list of dependent sources parameters...
4
Fig. 2: Class circuit definition
2.1.2
Parser Implementation
The parser is a part of the circuit class constructor that reads the input netlist and
outputs an object of type circuit, that we detail its property in the previous section.
Fig. 3: Parser function
Figure 3 shows a description of the parser implementation. We have 5 types of processus
for different circuit components as they are uniquely defined according to the SPICE
syntax.
In the following subsections we detail the get element functions.
2.1.2.1
GetElement function
If the element encountering during the the parsing of the Netlist line statement is an
elementary component that is different of a subcircuit definition, then the function
GetElement refers to the Get element functions described in the following subsections.
2.1.2.1.1
GetComponent function
In case of a resistor, an inductor or a capacitor, we can notice that their syntax in
5
SPICE is similar that is why a single function GetComponent deals with those type of
element. The name of the element is stored in the name property. Both nodes n1 and
n2 are placed in the node property. The characteristic value is placed in the parameter
cell field of the component.
[name n1 n2 value] R,L,C
2.1.2.1.2 GetM function
In case of a transistor, the function GetM stores the name of the Mosfet and its nodes
respectively in the name and node property of the component. The property parameter
is filled in with the name of the Mosfet model and all parameters’name and value.
[Mxxx nd ng ns nb mname L=length W=width AD=val AS=val PD=val PS=val ] M
2.1.2.1.3 GetD function
The function GeD puts the name and node of the diode respectively in the name and
node property and puts the diode model name reference in the parameter cell filed of
the diode component. The property parameter involves parameters’ name and value
of the diode model.
[Dxxx nplus nminus mname ] D
2.1.2.1.4 GetCV function
The GetCV function deals with independent sources : AC, DC, transient and mixed
sources. The source name and node are stored in their respective properties. The cell
parameter property is filled depending on the type of the source. We can find in it the
DC source value, the transient source function and the magnitude and phase of the
AC source.
[name n+ n- DC= dcval tranfun AC=acmag acphase ] I,V
2.1.2.1.5 GetCCVS, GetCCVS, GetCCVS, GetVCVS functions
The function GetCCVS is called to treat polynomial and linear type of current controlled voltage source. For both types of CCVS, the GetCCVS function puts the
connecting node and name of the controlled source in the name and node property of
the component and determines whether it is a linear or polynomial one. In case of
a linear CCVS, the function puts in the parameter cell, the name of voltage sources,
through which controlling current flows and the transresistance which is the current-tovoltage conversion factor. In case of a polynomial CCVS, the function first determines
the number of polynomial dimensions that represents the number of the controlling
variables of the source and fills it in the parameter cell property. Then the names
of voltage sources, through which controlling current flows, as well as the polynomial
coefficient are stored in the parameter cell.
[Hxxx n+ n- CCVS vn1 transresistance ] CCVS
In case of a voltage controlled voltage source, the function GetElement refers to the
GetVCVS function that works similarly to the GetCCVS as well as the treatment of
6
current controlled current source which is made by the GetCCCS function and Voltage
Controlled Current Source done by the GetVCCS function. The difference between
those functions consists in the way the MATLAB cell parameter is filled.
[Exxx n+ n- VCVS in+ in- gain ] VCVS
[Fxxx n+ n- CCCS vn1 gain ] CCCS
[Gxxx n+ n- VCCS in+ in- transconductance ] VCCS
2.1.2.1.6 GetSubcircuit function
The GetSubcircuit function puts the element name of the subcircuit in the name property as well as nodes and then stores the name of the subcircuit in the MATLAB cell
parameter property.
[X n1 n2 n3 ... SubcircuitName ]
2.1.2.2 GetSubcircuitComponent function
Once the parsing of elementary component is finished, the constructor of the class
object analyzes the input file to browse for the definition statements of subcircuits
already referenced in the netlist. For each subcircuit definition, the parser calls the
GetSubcircuitComponent function that creates for every subcircuit a component of
type circuit. The function puts the subcircuit name and node respectively in the
name and node property and then calls recursively the function GetElement which
parses the subcircuit definition, collects component, which can be element or subcircuit,
and stores them in the MATLAB cell component. There is no limit to the size or
complexity of subcircuits, and subcircuits may contain other subcircuits. After creating
the subcircuit component, the GetSubcircuitComponent function stores the object in
the cell component of the circuit object.
.SUBCKT SubName n1 n2 n3 ...
circuit element lines
ĖNDS
Finally, the parser analyzes the netlist file to recognize all parameters concerning the
predefined models and the types of the circuit analysis that we want to perform.
2.1.3
Flat Circuit Object Generation
The function ExpandSubcircuit is applied to the circuit object in order to produce a
flat one before proceeding with equation set up. This method instantiates subcircuit
elements and insert them wherever the subcircuit is referenced.
2.2
2.2.1
MNA Object Generation
DC Analysis Preparation
The function DCPreparation prepares the circuit for DC analysis, we disable all the
dynamic elements of the circuit object. So, we replace a capacitor by an open circuit
7
Fig. 4: Flattening process
dv
(large resistor) since at DC, dV
dt = 0, so that i = C dt = 0 and inductors are replaced by
di
di
a short circuit because, at DC, dt
= 0, so that v = L dt
= 0. In term of implementation,
to prepare the circuit object for DC analysis, is called.
2.2.2
AC Analysis Preparation
Each non linear component of the circuit object is replaced by it’s small-signal model
around the operating point determined by the DC Analysis. This is accomplished by
the function ACPreparation. First, this function parses the cell component and replaces
each DC independent voltage source by a short circuit and each current source by an
open circuit. Then, it replaces each component corresponding to a diode by a linear
voltage controlled current source component whose transresistance is the first term of
the linearization expression of the pn-diode element equation. Finally, it replaces each
Mosfet component by it’s small signal model.
2.2.3
Class MNA
The general form of the MNA equations for linear and non linear circuits is :
C
d
x + Y x + w (x) = Z (t)
dt
x (0) = x0
(1)
Consequently, the MNA class is composed of 3 properties Y , C, and Z. The matrix
w is taken into consideration during the generation of the equations. This class has
a singular constructor which takes the circuit object and constructs MNA matrices.
The following sections detail the implementation of the parser and the Modified Nodal
Analysis method.
8
2.2.4
Modified Nodal Analysis Implementation
The class MNA has 3 properties : The matrix Y ,C and the matrix Z. Each of them will
be created by combining several individual sub-matrices. The constructor of the MNA
class takes as input the circuit object and generates an MNA object corresponding to
this circuit. The first step is to calculate the number of nodes n and the number of
independent voltage source m to determine matrices size.
Fig. 5: Generation process of MNA object
In this section we detail each step performed to construct the MNA object from a flat
circuit object (Figure 5).
2.2.4.1 Construction of the Y matrix
For resistive circuit, the property Y is (m + n) × (m + n) and a combination of 4
matrices G, B, E and D (Figure 6).
Fig. 6: Matrix Y composition for resistive circuit
• The conductance matrix G : is nxn and determined by the interconnections between the passive circuit elements (resistors)
• The B matrix : is nxm and determined by the connection of the voltage sources
• The E matrix : is mxn and is the transpose of the B matrix
• The D matrix : is mxm and contains only zero
9
2.2.4.1.1 Construction of the G matrix
The G matrix is the conductance matrix which is the output of the function ConstructG. The function ConstructG initializes to zero the G matrix, then parses the cell
component and for each resistor element, it calculates its conductance value. According to its nodes connections, it replaces the conductance value into the G matrix. In
other words, the G matrix is formed according two rules :
• Each element in the diagonal matrix is equal to the sum of the conductance (one
over the resistance) of each element connected to the corresponding node. So the
first diagonal element is the sum of conductances connected to node 1, the second
diagonal element is the sum of conductance’s connected to node 2, and so on.
• The off diagonal elements are the negative conductance of the element connected
to the pair of corresponding node. For example if the property node of the element
contains 1 and 2, the resistor value goes into the G matrix at location (1,2) and
locations (2,1). If an element is grounded, it will contribute only to one entry in
the G matrix diagonal. If it is ungrounded (if both nodes are different from zero),
it will contribute to four entries in the matrix, two diagonal entries (corresponding
to the two nodes) and two off-diagonal entries.
2.2.4.1.2 Construction of the B matrix
The B matrix is the output of the function CostructB. It’s is an nxm matrix with only
0, 1 and -1 elements where n is the number of node and m the number of independent voltage source in the circuit object. Each location in the matrix corresponds to
a particular independent voltage source element (first dimension) or a node (second
dimension). If the first element of the node property, which is the positive terminal,
corresponding to the ith independent voltage source component is connected to node
k, then the element (i,k) in the B matrix is a 1. If the first element of the node property, which is the negative terminal, of the ith independent voltage source component
is connected to node k, then the element (i,k) in the B matrix is a -1. Otherwise,
elements of the B matrix are zero.
If a voltage source is ungrounded, it will have two elements in the B matrix (a 1 and a
-1 in the same column). If it is grounded it will only have one element in the matrix.
2.2.4.1.3 Construction of the E matrix
The E matrix is the output of the function CostructE. It’s is an mxn matrix with only
0, 1 and -1 elements where m is the number of independent source of voltage and n the
number of node in the object circuit. The E matrix is the transpose of the B matrix.
2.2.4.1.4 Construction of the D matrix
The D matrix is the output of the function CostructD. It’s an mxm matrix that is
composed entirely of zeros and where m is the number of independent voltage source.
10
Once the matrix Y is constructed, it will be updated according to the type of element
present in the object cell component. If the cell component of the circuit object contains inductor, the function CaseInductor adds the element stamps corresponding to
inductor into the Y matrix. Finally, if the cell component includes a dependent source
element, a function is called for each type of controlled source to add the element stamp
corresponding.
2.2.4.2 Construction of the Z Matrix
The next step is to construct the Z vector. This is accomplished by the function ConstructZ. The Z matrix holds with independent voltage and current sources component
and is developed as the combination of 2 smaller matrices I and V. The Z vector is
(m+n)×1 where n is the number of nodes, and m is the number of independent voltage sources component. The I matrix is nx1 and contains the sum of the currents
through the passive elements into the corresponding node (either zero, or the sum of
independent current sources).
2.2.4.2.1 Construction of the V Matrix
The V matrix is mx1 and holds the values of the independent voltage sources which
are stored in the parameter property. Each element of the V matrix is equal in value
to the corresponding independent voltage source.
2.2.4.2.2 Construction of the I Matrix
Each element of the I matrix corresponds to a particular node. The value of each
element of I is determined by the sum of current sources into the corresponding node.
If there are no current sources connected to the node, the value is zero.
Once the Z matrix is constructed it will be updated whenever an element stamps is
added to the Y matrix.
2.2.4.3 Construction of the C Matrix
The final step consist in constructing the C matrix that stores all capacitor and inductor
values.
The function ConstrutC initializes to zero the C matrix, then parses the cell component and for each capacitor element it replaces the capacitor value into the C matrix
according to the node property of the capacitor. The C matrix is formed according
two rules :
• Each element in the diagonal matrix is equal to the sum of the capacitor value
and the negative inductor value of each capacitor or inductor element connected
to the corresponding node. So the first diagonal element is the sum of capacitor
value and the negative inductor value connected to node 1, the second diagonal
element is the sum of capacitor value and the negative inductor value connected
to node 2, and so on.
11
• The off diagonal elements are the negative capacitor value of the capacitor element
connected to the pair of corresponding node. For example if the property node of
the element contains 1 and 2, the capacitor value goes into the C matrix at location
(1,2) and locations (2,1). If an element is grounded, it will only have contribute
to one entry in the C matrix, at the appropriate location on the diagonal. If it
is ungrounded (if both nodes are different from zero) it will contribute to four
entries in the matrix, two diagonal entries (corresponding to the two nodes) and
two off-diagonal entries.
2.2.4.4 Modified Nodal Analysis for AC Analysis
If the user want to perform AC Analysis, the object created from the circuit object is
called mna laplace and has two properties which are A and Z matrices. In this case, the
A matrix is constructed in a different form of what we describe before. This difference
is in the way we generate the G matrix. The G matrix will not only contain the resistor
values but also the complex impedance of capacitor and inductor element stored in the
cell component. The complex impedance are placed in the G matrix in the same way
it was done for resistor.
The complex impedance of a resistor, capacitor and inductor are respectively :
ZR = R
−j
1
=
ZC =
sC
wC
ZL = sL = jwL
2.3
2.3.1
Equations Generation
DC Equations
When intending to run any type of DC Analysis, and before being able to set up the
MNA equations seen above, the circuit object generated by the parser is prepared for
running DC analysis. This circuit object is the input of the MNA class constructor.
The general nonlinear MNA system for DC analysis as given in equation 2 :
Y x + w (x) = Z
(2)
Therefore, the MNA object generated from the circuit object prepared for DC analysis involves the matrices Y and Z as properties. This MNA object is the input of the
function GenerateDCequation which generates a MATLAB file containing DC equations as given in equation 3:
F = 0
F = Y x + w (x) − Z
(3)
The matrix w, containing the non linear model of the current crossing non linear
element, is taken into consideration while writing the equation in the MATLAB file.
12
2.3.2
Differential Algebraic Equation
If the user of the tool want to perform transient analysis, the circuit object created by
the parser is the input of the MNA constructor. The general dynamic nonlinear MNA
system as given in equation 4:
C
dx
+ Y x + w (x) = Z(t)
dt
(4)
The MNA object created contains as property the matrices Y, C and Z. The function
GenerateODE creates a MATLAB file containing the Ordinary Differential Equation
as given in equation 5:
ẋ = f (x, t)
f (x, t) = C −1 (Z (t) − Ax − w (x))
2.3.3
(5)
Transfer Function
After preparing the circuit object for AC analysis, the constructor of the MNA generates from the circuit object an MNA object. The general MNA system for AC analysis
as given in equation 6:
Ax = Z
(6)
A = (Y + sC)
(7)
Where :
The circuit is solved by a simple matrix manipulation as:
x = A−1 Z
13
(8)
3
Applications
In this section, we present experimental results for a Rambus Ring-Oscillator [6], and
a differential amplifier [5].
3.1
Rambus Ring Oscillator
In this section, we consider a Rambus ring oscillator made with an even number of
stages (n=4), as shown in Figure 7. Each stage has two forward (labeled fwd) inverters connected by a pair of cross-coupling (labeled cc) inverters. Each inverter is
single ended and is composed of a cascaded n-channel and p-channel transistors and
a capacitance C connected to their drains. The oscillating conditions depend on the
transistors sizes and the inial conditions[6].
Fig. 7: Rambus Ring-Oscillator
Figure 8 shows the SPICE netlist file of the rambus ring oscillator.
14
***Rambus Ring Oscillator***
VDD 9 0 DC=1.0
XI8 4 7 INV_CC_G1
XI9 2 6 INV_CC_G1
XI10 1 5 INV_CC_G1
XI11 8 3 INV_CC_G1
XI12 7 4 INV_CC_G1
XI13 6 2 INV_CC_G1
XI14 5 1 INV_CC_G1
XI15 3 8 INV_CC_G1
XI7 1 8 INV_FWD_G2
XI6 2 1 INV_FWD_G2
XI5 4 2 INV_FWD_G2
XI4 3 4 INV_FWD_G2
XI3 5 3 INV_FWD_G2
XI2 6 5 INV_FWD_G2
XI1 7 6 INV_FWD_G2
XI0 8 7 INV_FWD_G2
.SUBCKT INV_FWD_G2 IN OUT
C0 OUT 0 1e-12
M1 OUT IN 9 9 CMOSP L=100e-9
M0 OUT IN 0 0 CMOSN L=100e-9
.ENDS INV_FWD_G2
.SUBCKT INV_CC_G1 IN OUT
M1 OUT IN 0 0 CMOSN L=100e-9
M0 OUT IN 9 9 CMOSP L=100e-9
.ENDS INV_CC_G1
.END
W=+5.00000000E-06 MULTI=1.0 M=1.0
W=+2.00000000E-06 MULTI=1.0 M=1.0
W=+2.20000000E-06 MULTI=1.0 M=1.0 AD=46E-15
W=+5.50000000E-06 MULTI=1.0 M=1.0
Fig. 8: Circuit description of a rambus ring oscillator
Rambus ring oscillator Transient response
The differential model of the Rambus ring oscillator is given in Figure 9. However,
the time integration of these model requires the specification of the initial condition
x(0) = IC, and leads to the transient behavior shown in Figure 10.
Where x is the vector of voltages at the output of each inverter, gnd is the ground
voltage, V DD = 1.8 is the power supply voltage, f n are functions that model the n, pchannel transistor current based on their gate, drain and source voltages as well as their
sizes. The user may use different trannsistor models or may change the transistor sizes
and parameters by changing the MATLAB Mfile f n modeling the behavior of the n
and p channel transistors.
15
function xdot=ODE_rambus(t,x)
%%xdot is the derevative of the vector,x
%%x(1),is the voltage at the node,1
%%x(2),is the voltage at the node,2
%%x(3),is the voltage at the node,3
%%x(4),is the voltage at the node,4
%%x(5),is the voltage at the node,5
%%x(6),is the voltage at the node,6
%%x(7),is the voltage at the node,7
%%x(8),is the voltage at the node,8
%%x(10),is the current through the voltage source,VDD
xdot(1)=1/1e-012*(-fn(x(5),x(1),gnd,gnd,1,’P)-fn(x(5),x(1),VDD,VDD,-1,’P’)-fn(x(2),x(1),VDD,VDD,-1,’P’)fn(x(2),x(1),gnd,gnd,1,’P’));
xdot(2)=1/1e-012*(-fn(x(6),x(2),gnd,gnd,1,’P’)-fn(x(6),x(2),VDD,VDD,-1,’P’)-fn(x(4),x(2),VDD,VDD,-1,’P’)fn(x(4),x(2),gnd,gnd,1,’P’));
xdot(3)=1/1e-012*(-fn(x(8),x(3),gnd,gnd,1,’P’)-fn(x(8),x(3),VDD,VDD,-1,’P’)-fn(x(5),x(3),VDD,VDD,-1,’P’)fn(x(5),x(3),gnd,gnd,1,’P’));
xdot(4)=1/1e-012*(-fn(x(7),x(4),gnd,gnd,1,’P’)-fn(x(7),x(4),VDD,VDD,-1,’P’)-fn(x(3),x(4),VDD,VDD,-1,’P’)fn(x(3),x(4),gnd,gnd,1,’P’));
xdot(5)=1/1e-012*(-fn(x(1),x(5),gnd,gnd,1,’P’)-fn(x(1),x(5),VDD,VDD,-1,’P’)-fn(x(6),x(5),VDD,VDD,-1,’P’)fun_mos(x(6),x(5),gnd,gnd,1,’P’));
xdot(6)=1/1e-012*(-fn(x(2),x(6),gnd,gnd,1,’P’)-fn(x(2),x(6),VDD,VDD,-1,’P’)-fn(x(7),x(6),VDD,VDD,-1,’P’)fun_mos(x(7),x(6),gnd,gnd,1,’P’));
xdot(7)=1/1e-012*(-fn(x(4),x(7),gnd,gnd,1,’P’)-fn(x(4),x(7),VDD,VDD,-1,’P’)-fn(x(8),x(7),VDD,VDD,-1,’P’)fun_mos(x(8),x(7),gnd,gnd,1,’P’));
xdot(8)=1/1e-012*(-fn(x(3),x(8),gnd,gnd,1,’P’)-fn(x(3),x(8),VDD,VDD,-1,’P’)-fn(x(1),x(8),VDD,VDD,-1,’P’)fun_mos(x(1),x(8),gnd,gnd,1,’P’));
xdot(9)=0;
xdot=xdot(:);
Fig. 9: Rambus ring oscillator ODE’s
1.8
1.6
1.4
x(1)..x(8) [V]
1.2
1
0.8
0.6
0.4
0.2
0
0
0.5
1
1.5
2
2.5
Time [s]
3
3.5
4
4.5
5
−8
x 10
Fig. 10: Rambus ring oscillator transient response
3.2
Differential amplifier
In this section, we consider the differential amplifier circuit shown in Figure 11. It
consists of a differential pair and a current mirror. The differential pair uses n-channel
transistors and load resistors r1 and r2. The current mirror is composed of an ideal
DC current source of 60uA and two NMOS transistors used to define the amount of
current that flows into the two branches of the differential pair. The differential input
16
Fig. 11: CMOS Differential Amplifier
(vid = vip-vin) is applied between the gate terminals of the differential pair transistors
which have the same size and properties. Their drains are connected to the capacitors
c1 and c2.
The netlist file of this circuit is shown in Figure 12.
***CMOS Differential Amplifier***
R1 VDD! VON 12E3
R2 VDD! VOP 12E3
I1 VDD! NET21 DC=60E-6
C1 VON VSS 4.780e-14 M=1.0
C2 VOP VSS 4.780e-14 M=1.0
M1 NET21 NET21 VSS VSS CMOSN L=4.5E-6 W=100E-6 AD=+4.80000000E-11
+AS=+4.80000000E-11 PD=+2.00960000E-04 PS=+2.00960000E-04 NRD=+2.70000000E-03
+NRS=+2.70000000E-03 M=1.0
M2 VOP VIP VTAIL VSS CMOSN L=200E-9 W=4.4E-6 AD=+1.05600000E-12
+AS=+2.11200000E-12 PD=+9.76000000E-06 PS=+9.76000000E-06 NRD=+6.13636364E-02
+NRS=+6.13636364E-02 M=1.0
M3 VTAIL NET21 VSS VSS CMOSN L=4.5E-6 W=100E-6 AD=+4.80000000E-11
+AS=+4.80000000E-11 PD=+2.00960000E-04 PS=+2.00960000E-04 NRD=+2.70000000E-03
+NRS=+2.70000000E-03 M=1.0
M4 VON VIN VTAIL VSS CMOSN L=200E-9 W=4.4E-6 AD=+1.05600000E-12
+AS=+2.11200000E-12 PD=+9.76000000E-06 PS=+9.76000000E-06 NRD=+6.13636364E-02
+NRS=+6.13636364E-02 M=1.0
V1 VIN VSS AC 1.0 SIN 1.0 10E-6 10E9
V2 VIP VSS AC 1.0 SIN 1.0 10E-6 10E9
V0 VDD! VSS DC=1.8
.END
Fig. 12: SPICE Netlist file of a CMOS differential pair
DC, transient and frequency responses of the differential amplifier
The DC characteristics of the differential amplifier are shown in Figure 11. The input
differential voltage (vid) varies between -1.8 and +1.8 volts. The output differential
voltage (vod = vop - von) varies between -0.4 and 0.4 volts and the regions where one
17
of the MOSFET is in saturation region and both the transistors are in non-saturation
region are clearly seen. The netlist file of this circuit, algebraic equations for DC
response, DAEs for the transient response, and the transfer function for the frequency
response of the differential amplifier generated by our tool can be found in [?].
0.8
0.6
vop−von [V]
0.4
0.2
0
−0.2
−0.4
−0.6
−0.8
−20
−10
0
vip−vin [V]
10
20
Fig. 13: DC transfer characteristic of the differential amplifier
function xdot=ODE(t,x)
%%xdot is the derevative of the vector,x
%%x(1),is the voltage at the node,1
%%x(2),is the voltage at the node,2
%%x(3),is the voltage at the node,3
%%x(4),is the voltage at the node,4
%%x(5),is the voltage at the node,5
%%x(6),is the voltage at the node,6
%%x(7),is the voltage at the node,7
%%x(8),is the current through the voltage source,Vdd
%%x(9),is the current through the voltage source,Vin
%%x(10),is the current through the voltage source,Vinp
xdot(1)=0;
xdot(2)=1/4.78e-014*(-(8.3333e-005)*x(2)-(-8.3333e-005)*x(4)-fn(x(1),x(2),x(3),0,1,’P’));
xdot(3)=0;
xdot(4)=0;
xdot(5)=0;
xdot(6)=1/4.78e-014*(-(-8.3333e-005)*x(4)-(8.3333e-005)*x(6)-fn(x(7),x(6),x(3),0,1,’P’));
xdot(7)=0;
xdot(8)=0;
xdot(9)=0;
xdot(10)=0;
xdot=xdot(:);
Fig. 14: Ordinary Differential Equations of the differential amplifier
Where x is the vector of voltages at each node and f n is a function that models
current of the transistor.
Figure 15 shows the transient time response of the differential amplifier. The differential input vid is a one volt peak-to-peak sinusoidal signal. The signal traces show
18
both the initial transient region and the final steady state transient response of the
differential amplifier. Moreover, we observe that the differential output signal vod is
out of phase with the differential input and has a gain of 1.52 V/V.
2
vid=vip−vin
vod=vop−von
1.5
1
vid,vod [V]
0.5
0
−0.5
−1
−1.5
−2
0
0.2
0.4
0.6
0.8
Time [s]
1
−7
x 10
Fig. 15: Transient response of the the differential amplifier
Figure 16 shows the frequency response of the differential amplifier. The top graph
shows the magnitude response and the bottom graph shows the phase response.
Bode Diagram
60
Magnitude (dB)
40
20
0
−20
−40
360
Phase (deg)
315
270
225
180
8
10
10
10
12
Frequency10(rad/sec)
14
10
16
10
Fig. 16: Frequency response of the differential amplifier
19
4
Conclusions
In this report, we have described a Tool for Modeling and Analysis of Electronic Circuits and Systems that takes as input a SPICE Netlist file containing circuit features,
information and structures and generates a mathematical description of analog circuit
resulting from applying Kirchhoff’s law and Branch Equations on the circuit, and modeling the current across non linear element such as Mosfet and Diode. Those analog
circuit models are generated using a nonlinear set of equations formulation step based
on MNA. We demonstrated the capabilities of our tool on two different circuits: a
differential amplifier and a Rambus ring oscillator. Moreover, our tool can easily be
integrated within a more larger set of tools already existing in MOO inside the host
research laboratory or with existing public and commercial layout design and simulation tools such as Cadence Virtuoso, Synopsis HSPICE, Magic and Alliance. Besides,
mathematical model generated by the tool can be of greater interest for any verification
methodology such as noise analysis, model order reduction and process variation.
20
References
[1] M. R. Greenstreet. Verifying vlsi circuits. In ATVA’09, pages 1–20, 2009.
[2] F. N. Najm, Circuit Simulation, John Wiley & Sons, Inc., publication, 2010.
[3] Object-Oriented
Programming
http://www.mathworks.com/.
in
MATLAB,
October
2011.
[4] HSPICE Simulation and Analysis User Guide, SYNOPSYS, October 2011.
http://cseweb.ucsd.edu/classes/wi10/cse241a/assign/hspice sa.pdf.
[5] B. Razavi. Design of Analog CMOS Integrated Circuits. McGraw Hill, 1999.
[6] M. R. Greenstreet. Verifying vlsi circuits. In ATVA’09, pages 1–20, 2009.
21
Download