ECE4902 Lab 6

Simulation

The purpose of this lab is to compare simulation results with your measurements from various lab circuits, starting with the basic parameters for individual devices, working up through the blocks of the op-amp (common source amplifier, differential pair), to the complete two-stage op-amp.   This lab uses the SPICE available in the Cadence suite of design tools (which also provide resources for IC layout). 

Be sure to have your lab data available for the following labs:

Following is an overview of the sections of this lab:

L6-1. Connect to dot, setting up files

Cadence runs on dot, the department's ultra-fast shared machine.  The first step in running cadence is remotely logging in to dot from the PC in AK227, and then setting up the correct directory structure in your home directory

L6-2. Starting icfb, creating new library

"icfb" ("Integrated Circuit Front to Back") is the command that starts cadence.  You will create a library to hold all the schematics you will generate in this lab and any other simulations you do for ECE4902

L6-3. Schematic Entry, NMOS

In this part you draw a schematic for simulating the DC VDS-ID characteristic from Lab 3.  In Lab 3, you had to use different resistor values to change VDS; the nice thing about simulation is you just define a voltage source and sweep its value over whatever range you need.

L6-4. Modifying NMOS part.

The default NMOS device from the cadence library has different W and L values and also uses different SPICE models than the MOSFETs you use in lab. In this part you will change the W and L values and refer to a SPICE model that describes the CD4007/MC14007 MOSFET

L6-5. DC Simulation, generic models

In this part you simulate the DC sweep of the VDS-ID characteristic circuit.  You should get the correct shape but the values will be wrong since the simulator uses generic models that have different parameters than the parameters for your devices.

L6-6. Model parameters, N-channel

In this part you create your own SPICE model parameter file, corresponding to the extracted parameters from your lab measurements.

L6-7. DC Simulation, your models, RB=5.1KOhm case

In this part you simulate the DC sweep of the VDS-ID characteristic circuit, using the model file you created corresponding to the extracted parameters from your lab measurements.  The VGS used is from one of the data points, for the value of 5.1KOhm in the current mirror circuit

L6-8. DC Simulation, N-channel, RB=51KOhm case

The other VGS data point from  Lab 3.

L6-9. Parameter Adjustment

Here you modify the parameter file to get good agreement between the simulated data and your measurements.

L6-9. P-channel

Repeat the DC sweep for the P-channel VDS-ID characteristic circuit.

L6-11. Common source amplifier with active load

Here you simulate the common source amplifier from Lab 5

L6-12. DC sweep, finding operating point

From the DC sweep of the common source amplifier, you find the DC operating point to use for the AC sweep in the next part

L6-13. Using calculator to find gain from DC
sweep plot

The low-frequency small-signal gain is the slope of the

L6-14. AC sweep at operating point

Here we use the simulator to sweep frequency (rather than DC voltage).  The result is a plot of behavior vs. frequency.  If we plot magnitude and phase of gain vs. frequency, we have a Bode plot

L6-15. Using Bode plot to find gain, f3dB, fT

The Bode plot can be used to find the bandwidth (3-dB frequency f3dB) and the unity gain frequency (fT)

L6-16. Exporting to MATLAB

Data can be exported for use in other software tools (e.g. MATLAB or excel) to compare measured data with simulation




L6-1. Connect to dot, setting up files

1) Open PuTTY connection

Log on Windows XP using your ECE account. Open putty by click its icon in the quick launch menu



2) Log on to dot

Double click on dot.ece.wpi.edu to log on dot

3) Set up directories

To keep things manageable, you should do all your work in a separate directory.  The first time you run cadence, create a separate directory cadence:
mkdir cadence
You should always be in this directory when you start cadence. Go into the directory
cd cadence
and make another directory to store the lab schematics
mkdir mylib

Be sure to remember this name, as you will need to use it when creating a new library from inside icfb in the next part of the lab.

You also need to make another directory to store your own spice models:

mkdir models
cd models
mkdir spectre

     
L6-2. Starting icfb, creating new library

1) Start cadence

Be sure you're in the cadence directory before starting.  You may need to cd ~/cadence to get back to the cadence directory.  Once you're sure you're in the cadence directory ... To start the software, type:
icfb &

Some "What's New" and/or "help" windows may come up; click on whatever's necessary to make them go away.  Eventually, the Library Manager window will come up. Headings are Library, Cell, View.



2) Create a new library for your design

Using the pull-down menu, select

File > New > Library

A Create Library window will appear (see below).  Choose a name for your library and type it in the boxes for Name: and Path:. In this example, the name is 'mylib'.  The library name needs to be the same as the directory you created in part L6-1.

In the 'Technology Library' section of the Create Library window, click 'Attach to existing tech library' and select 'AMI 1.6u ABN (2P, NPN)' (should be the default choice). The technology file contains information specific to the process your IC would be fabricated in. Click OK.

 

After you clock OK in the Create Library window, it should disappear.  Now your library manager window should look like this:


And your library should be all ready for you to draw a schematic!



L6-3. Schematic Entry, NMOS

In this part, you draw the circuit of the NMOS device with voltage sources to set VGS and VDS.

Now you've set up your library and it's time to make a cell. Cells represent each of the pieces of the design you are working on. Each represents a circuit or subcircuit, which can be shown in several different ways, such as schematic or symbol. Schematic and symbol are two types of views that can be created to represent the circuit. A schematic view is an electrical representation of the circuit and might contain components (such as MOSFETs, resistors, capacitors, etc) or symbols for other subcircuits. A symbol view abstracts the circuit into a simpler symbol (such as the triangle for an op-amp) that can then be used in other circuit designs. For our cell we will first create a schematic view in which we will show the circuit for finding the VDS-ID characteristic from Lab 3.

1) Creating a cell

In the Library Manager window, click on the library name (mylib) you just created. Using the pull-down menu, select

File > New > Cell View

This will allow you to define the cell name, the type of view, and the software tool to be associated with the cell view.



Click your cursor into the Cell Name box and type the name of the cell you want to create.  Give it a descriptive name, maybe something like

lab3nsweep
so you can remember what it does when you choose from your library of cells in the future.

For View Name, type "schematic". (Usually we will start the IC design process with schematic representations of the circuit. This is followed by a symbol view for use in simulation. After some iteration with simulation, we should have a schematic of a working circuit. Then you can create a layout view of the cell and proceed with physical design.)

For the Tool, choose "Composer-Schematic"

When you click on the OK box, a Composer window will open. Now it's time to draw the schematic.

Your circuit will eventually look like this:





2) Add MOSFET components

To add a component, you choose it from a "menu" of available components in the component browser.  You can get to the component browser in one of three ways:

Doing any one of these will open a Component Browser Window, and an Add Instance window (see below). To choose from analog parts, go to the Component Browser Window and choose the NCSU_Analog_Parts library. Select the N_Transistors entry from the available contents and the component of nmos4.








When you move the cursor into the schematic window, you will
see the outline of a MOSFET. Click the left mouse button to place the
MOSFET. Moving the cursor will continue to show the MOSFET outline; if
you keep clicking you will place more MOSFETs. Hit the Esc key to get
out of component placement mode.

3) Add voltage sources and ground

4) Wire it up

You can get to the wiring tool in one of three ways:

Click the left mouse button to place ends of the wire. Connection points (terminals) are indicated with red dots on the boundary of each symbol.  Connect wires until all terminals are connected appropritely (don't forget the substrate terminal!).  Hit the Esc key to get out of the wire placement mode and back into the selection mode.

5) Name signals

In complicated designs, it's a good idea to give the nodes names.  Although this circuit isn't complicted, we'll do it in this circuit to get in some practice...

First select the wire to be named.  Click on the wire to select it; you'll know the wire is selected when it's highlighted in white.

Let's name the gate node "vgs". You can get to the wire name tool in one of three ways:

The Add Wire Name form opens up; type in the name and hit return. The name appears in the schematic window; move the mouse to place it near the wire you're naming and click the left mouse button to place the name.







L6-4. Modifying NMOS part.

The default NMOS device from the NCSU library has different W and L
values and also uses different models. In this part you will change the
W and L and refer to a model that describes the CD4007/MC14007 MOSFET

Click on the MOSFET until you see a white box indicating that it is
selected and edit its object properties (the way you did for the
Voltage Source).

Now change the following in the Edit Object Properties window (see below)

Click OK when you're done.  You should see the new property values next to the MOSFET in the schematic window.

Save your design using

Design > Save

from the pulldown menu.  Now your schematic is ready for simulation!












L6-5. DC Simulation, N-channel, RB=5.1KOhm case, generic models

Here you simulate the acquisition of data points from parts L3-14, 15, 16 of lab 3. You will sweep VDS while holding VGS constant with the value of VGS set to the value you measured in the RB=5.1KOhm case. When you do the DC sweep and plot ID as a function of VDS, you should see a plot similar to what you measured in lab -- but the simulation results will not match your lab results yet, since the model parameters are different.  That's OK, the point now is just to get the DC simulation working. You will change the model parameters in the next part.


1) Open simulation tool

To open the analog artist simulation tool, go to Tools, then Analog Environment in the schematic window. This will open the Analog Artist simulation tool.







2) Specify DC analysis and source to sweep

Go to the pull-down menu

Analyses > Choose,

and select DC in the Choosing Analyses window.  We want to sweep VDS to duplicate in simulation the measurement you made in lab.  So click on Component Parameter and then click on Select Component in the DC Analysis part of the Choosing Analyses window.







Go back to the schematic window, click to select the VDS voltage source. In the pop-up window, double click 'dc' (see below).



Find the Choosing Analyses window again.

Lastly, input the range for the sweep. We will use a range from 0V
to 5V in steps of 0.1V each. The step size can be selected by changing
'sweep type' from 'automatic' to 'linear'. To do this:

Click on OK to finish your work in the Choosing Analyses window.

3) Select outputs to plot

We want to plot the drain current ID as VDS is swept.
From the pull-down menu in the Analog Design Environment window, choose

Outputs > To Be Plotted > Select On Schematic.

Then click the drain terminal of the NMOS which is indicated with the
small red square on the boundary of its symbol.  When you click a
circle should appear around the pin as shown below.  This means
the current into that terminal (the drain current ID) has
been selected to be plotted.







4) Start the simulation

Go back to the Analog Design Environment window, and choose

Simulation > Run

to start the simulation. A warning window may pop up:






Just click 'yes'. Then, after much thought on the part of the simulator, you will get an output waveform plot that looks something like the following:




The general shape is sort of OK, but the values are way off because
the model parameters are wrong.  You'll fix that in the next part.





L6-6. Model parameters, N-channel

For your simulation results to match the lab measurements, you need
to have the correct model parameters in the simulator. You need to
create your own model parameter file, which is done in this part.

In the general parameter file that was used in the previous part, you will need to modify parameters TOX, VTO, UO, and NSUB. TOX is the oxide thickness (in m), VTO is the threshold voltage, UO is the carrier mobility (in cm2/V.sec), and NSUB is the substrate doping (in /cm3) which is related to the channel length modulation parameter. Procedure for calculating NSUB
is on slides 62-66 of

http://ece.wpi.edu/~mcneill/4902/lectures/StudioRev_5.pdf


In order for Spice to be able to use these values, you need to create a
model file to override the defaults.


The model file needs to be in the directory 'cadence/models/spectre'
that you created earlier.  Using any unix text editor you're comfortable with (could be Notepad in Windows, or emacs from the putty terminal window), create a file called

CD4007N.m 
which has EXACTLY the following format, with your own values simply substituted in:
.MODEL CD4007N NMOS ( LEVEL=3 &
TOX=1E-6 &
VT0=2.5 &
U0=200 &
NSUB=1.2 &
)

Caution!!!  Notepad and other windows-based editors seem to insert weird invisible characters that confuse the simulator.  Cutting and pasting the above text may not work.  The best strategy may be to edit the following files:

CD4007N.m
CD4007P.m

In the text editor, save the model file and now you're ready to repeat the simulation using your parameters.






L6-7. DC Simulation, N-channel, RB=5.1KOhm case, your models

You will need to quit the existing session

Session > Quit

To start with the new model file.  Repeat the DC sweep setup procedure from L6-5, but now that you have created the new file the simulation will be done using your models.

Compare the measured data points from Lab 3 to your plot of the simulated current results. Two good VDS-IDS points to choose are

You can use the crosshair markers

Markers > Crosshair Marker A

to get numerical readings for points on the plot.  Some parameters will probably need to be adjusted to get the measured and simulated data to agree; before you do that check the results from the 51KOhm case.



L6-8. DC Simulation, N-channel, RB=51KOhm case, your models

Change the value of VGS to your measured value from the 51KOhm case.  Do the following so the simulator knows to use the new VGS value:

Repeat the DC sweep, and again compare some of the measured data points from Lab 3 to your plot of the simulated current results.



L6-9. Parameter Adjustment

Adjust your simulation parameters as necessary to get reasonable agreement between your measured data and the simulated VDS-ID characteristics.


L6-10. P-channel

Repeat parts L6-3 through L6-9 for the P-channel device. Create a new cell ...





Notes:

1) The PMOS can be found under the P_Transistors
entry from the Component Browser and select the component of pmos4.

2) For the model name of the pmos4, change it to
"CD4007P"
Remember that the Width of the PMOS device is 900u .

3) For your own CD4007P model file, go to the directory
'cadence/models/spectre' under your home directory, create a file
called CD4007P.m with EXACTLY the following format, with
your own values simply substituted in:

.MODEL CD4007P PMOS ( LEVEL=3 &
TOX=1E-6 &
VT0=-2.5 &
U0=100 &
NSUB=1.2 &
)
Do the DC simulations for your two VGS values.  Again, adjust the PMOS parameters as necessary to get agreement with your measured data.


L6-11. Common source amplifier with active load

Draw the schematic of the common source amplifier with active load.
Create a new cell ...





The resistor and capacitor can be found under the R_L_C entry of the
Component Browser


L6-12. DC sweep, finding operating point

Do a DC sweep of the input source V_IN. You will need to reduce the sweep increment to 10mV to see the gain in the high gain region.


1) Once you've saved the schematic and started the Analog Environment tool:  Click the vout net (wire) this time to select the output format of voltage.







2) After sweeping V_IN from 0 to 5V with 10mV resolution, your output should be similar (not identical!) to the following:







3) Use the crosshairs to identify the value of V_IN that corresponds to an output at
2.5V (mid scale). You will use this value as the DC component of V_IN for the AC sweep in the next part.

In this example, for vout to be at 2.5V, VIN should be at 1.213V.



L6-13. Using calculator to find gain from DC
sweep plot


The DC gain is the slope or derivative of the DC sweep plot.  You can plot the derivative using the 'deriv' function of the calculator.


1) Go to tools, then calculator to open this tool.






2) We need to select the output waves to do calculations on. Click on the button marked wave, and then click on output waveform. Next click on the button labeled Special Functions and then deriv , and then click plot to plot the resulting equation. The maximum value of the derivative is the DC gain of the circuit.







L6-14. AC sweep at operating point


1) Get the schematic ready

Go into your schematic and

2) Set up the simulator to do an AC sweep and plot the magnitude and phase.








3) Simulate

Run the simulation and you will get the AC magnitude. To plot the AC
phase, click the button 'Add Subwindow'.







4) Go back to the simulation interface, click on Results--Direct
Plot--AC Phase.







5) Go to the schematic window. Click on the 'vout' net. Then hit the
Esc key to finish the selection.










L6-15. Using Bode plot to find gain, f3dB, fT


The low frequency gain should match the DC gain from the previous
part. Use the cursors to find the 3-dB frequency and the unity gain
frequency and compare to your measured results.



Go back to the simulation interface, click on Results--Direct Plot--AC
Magnitude & Phase.







5) Go to the schematic window. Click on the 'vout' net. Then hit the
Esc key to finish the selection. On the Waveform window, click the
button of 'Switch Axis Mode' to get a better view!




L6-16. Exporting to MATLAB


1) Go back to the DC sweep waveform window





2) Open the Calculator. Click 'Wave' button and select the waveform
'vout'.



3 ) Click the button 'printvs'. Enter from -5 to 5 by 0.01. Click
'Apply'.







4) Click menu 'Expressions'--'Display Options'. Change format to
Engineering(exponent). Click OK.







5) Click menu 'Window'--'Print'--Print To--File. Give a filename.






Now the data file is generated!



6) Go to Matlab. Select menu 'File--Import Data'. Choose the file
'vout' just generated. Change the 'Text header lines" to 3. Click
'Next'.







To plot the data, use the following command:



plot(data(:,1), data(:,2))