ece 417-517 simulation instructions

13
QUICK GUI DE TO USING MATLAB , HSPICE, AND ATLAS This document is intended to be a quick and dirty guide to getting the project assignment set up and the three tools running on your Linux account. There are included some brief tutorials or examples for each of the three tools. All of these tools are accessible from any engineering Linux workstation. Please note that there are online tutorials that explain MATLAB and SPICE far better than this document. The goal here is to get you set up and on the way. Please search for and use some of these online tutorials if you are not familiar with these tools. Another point I want to stress is that I have experienced many problems with running HSPICE and ATLAS remotely. I strongly recommend working from a computer lab rather than remotely. Those of you who are more adventurous may try running these programs from home but if you do begin to encounter any problems the first step to debugging it should be to try it locally in a Linux lab. SAVING THE SIMULATION FILES TO THE WORKSTATION CREATE YOUR WORKING DIRECTORY The first step is to create a directory for this class. You can name it anything you like. If you have already done so please skip this step. If not, please do the following: 1. Open a terminal (see “To Open a Terminal Window” below) 2. Type “mkdir ece417” and press Enter. This will create a directory called ece417 in your home directory 3. “Type “cd ece417” and press Enter. This will make your current directory the directory you just created. DOWNLOAD THE SIMULATION FILE ARCHIVE Log in to the Linux workstation. Open up the web browser Firefox by clicking the appropriate icon on the task bar at the top of the screen (see Figure 1). Navigate to Blackboard and download the zip file to the Figure 1: The Firefox web browser icon

Upload: kydos-red

Post on 13-Nov-2015

233 views

Category:

Documents


1 download

DESCRIPTION

SImulation assignment documentation for oregon state ece 417 517. Conley.

TRANSCRIPT

  • QUICK GUIDE TO USING MATLAB, HSPICE, AND ATLAS This document is intended to be a quick and dirty guide to getting the project assignment set up and the three tools running on your Linux account. There are included some brief tutorials or examples for each of the three tools. All of these tools are accessible from any engineering Linux workstation. Please note that there are online tutorials that explain MATLAB and SPICE far better than this document. The goal here is to get you set up and on the way. Please search for and use some of these online tutorials if you are not familiar with these tools.

    Another point I want to stress is that I have experienced many problems with running HSPICE and ATLAS remotely. I strongly recommend working from a computer lab rather than remotely. Those of you who are more adventurous may try running these programs from home but if you do begin to encounter any problems the first step to debugging it should be to try it locally in a Linux lab.

    SAVING THE SIMULATION FILES TO THE WORKSTATION

    CREATE YOUR WORKING DIRECTORY

    The first step is to create a directory for this class. You can name it anything you like. If you have already done so please skip this step. If not, please do the following:

    1. Open a terminal (see To Open a Terminal Window below) 2. Type mkdir ece417 and press Enter. This will create a directory called ece417 in your

    home directory 3. Type cd ece417 and press Enter. This will make your current directory the directory

    you just created.

    DOWNLOAD THE SIMULATION FILE ARCHIVE

    Log in to the Linux workstation. Open up the web browser Firefox by clicking the appropriate icon on the task bar at the top of the screen (see Figure 1). Navigate to Blackboard and download the zip file to the

    Figure 1: The Firefox web browser icon

  • directory we just created using the Save as function of the web-browser. Unzip the file by:

    1. If you dont have an open terminal window from the previous step, open one now and navigate to the desired directory.

    2. Type the command unzip 417_proj1.zip and press Enter. This will unpack the project into the current directory. The project consists of the assignment and instructional PDFs plus three directories, one for each section of the assignment. These directories are:

    Part1 MATLAB Part2 HSPICE Part3 ATLAS

    3. To begin working on the first part of the assignment type the command cd Part1 MATLAB and press Enter. Then type matlab and press Enter. This will start the MATLAB environment.

    4. See the reference below for additional terminal commands.

    USING THE TERMINAL

    The terminal is an integral part of working with Linux workstations. Some common actions and commands are listed below

    TO OPEN A TERMINAL WINDOW From a Linux system on campus, go to applications -> system tools -> terminal. Working on campus is the easiest, and I will be around to support those working in the Kelley lab. If that is what you plan to do, you can skip the rest of this page.

    NAVIGATING FROM THE TERMINAL WINDOW The default directory is your home directory, and the directory you are working in will be displayed at the command prompt (the place where you type things). Your home directory can be viewed graphically on campus Linux systems from "'s Home" on the desktop or Places -> Home, or on your own computer using a FTP client as mentioned later.

    SOME TERMINAL COMMANDS: pwd lists the directory that you are currently in. "cd x" opens folder x, assuming x is inside the current folder. "cd .." goes up a level in the file system (opens the parent folder). "mkdir x" makes a new folder named x in the current directory. "dir" lists the contents of the current directory.

  • Adding -& while starting a program will leave the terminal accessible while that program runs.

    RUNNING THE PROGRAMS

    Programs will run in your current directory; they will look for files there and save files there. It is best to have a separate folder for each program to keep things organized.

    MATLAB can be opened simply by typing "matlab" in a terminal window. This will start an instance of MATLAB in the current directory.

    HSPICE is a command-line tool that runs from a terminal window. The simplest way to invoke HSPICE is by typing "hspice netlist.sp | tee netlist.lis", replacing the word "netlist" both times with the name of your own file. This command will run HSPICE saving the results of the textual output in the netlist.lis file. Netlist files are simply text files that describe a circuit and the analyses that you want to perform on it. To create a netlist file, open your favorite text editor (you can type "gedit" at the command prompt to open a text editor), make your netlist, and save it as .sp where is any name you like)

    ATLAS can be run from a terminal window by typing "deckbuild -as &". Deckbuild is the graphical interface through which the Silvaco suite runs, including other programs like the ATHENA process simulator that you might encounter elsewhere.

  • INTRODUCTION TO SIMULATION TOOLS

    The following descriptions are very brief introductions to each of these programs. The reader is encouraged to find and use one of the many great tutorials that exist on the web to learn more about the software

    MATLAB

    MATLAB is similar to many programming environments, however the focus of the MATLAB language is mathematical manipulation of matrices. MATLAB recognizes +, -, *, /, ^, and ( ), along with many other common programming operators, symbols, and commands. You can type commands directly into the command window and use it as a calculator, or you can create a script (extension .m) and program a series of commands, which is the most useful way to work in Matlab. That way, you can change a single value easily and run through a series of computations without having to enter them all again. Some basic useful commands are given below. Enter only one command per line, and end each line with a semicolon if you dont want the output from that line to be displayed. Anything after a % symbol will be ignored by the program, so make notes within your program using these.

    x = 1 will create a variable x with a value of 1.

    x, typed by itself, will display the value of x.

    y = x + 1 will create a variable y with a value of 2 (after the previous command).

    v = 0:2:10 will create a vector v with values from 0 to 10 in steps of 2, so x will equal [0, 2, 4, 6, 8, 10].

    v = [0, 2, 4, 6, 8, 10] also works to create the same vector.

    v[1] will give the number 0, because that is the first value in vector v.

    v = [[0,1],[2,3]] will create a multidimensional vector, in this case a matrix.

    v[2,1] will then display 2.

    v = v*2 will multiple each value in vector v by 2, giving [0, 4, 8, 12, 16, 20].

    for i = 1:3

  • z = z+1;

    end

    This will create a for loop, which will execute repeatedly, increasing the value of I by one each time, until i=3. i is called the index, and can be any variable you want. It will increase by one for each value of the loop, and the loop will exit after running the x=3 iteration. In this case, if z started at zero, z would end up being 3. Any nesting commands, like loops or conditionals, must be ended with an end statement; no parenthesis are necessary.

    x=(0:2:10);

    for i=1:size(x, 2)

    x(i)=x(i)2;

    end

    This is a little more complicated for loop. x is defined to equal (0, 2, 4, 6, 8, 10) to start, and then the loop looks at each element of x, using i as an index to keep track of which element to look at. The end result is that each element gets divided by two, so that x = (1,2,3,4,5) at the end.

    if z == 3

    z = 2;

    end

    This is a conditional; if z is equal to 3, then it will be set to 2 instead. The double equals sign is important; a single equals will MAKE z = 3, while a double equals will only CHECK if z = 3.

    plot(x1,y1,x2,y2)

    semilogx(x1,y1,x2,y2)

  • These commands both generate plots, with y1 values being plotted against x1 and y2 against x2. x1 and y1 must be vectors of equal length. semilogx will use a logarithmic x axis, semilogy will use a logarithmic y axis, and loglog will have both axes logarithmic.

    Try plotting x=y for x = 1 to 10 to confirm that these instructions make sense.

  • HSPICE

    HSPICE is part of the SPICE family of circuit simulation tools. It will process a netlist, a text representation of a circuit that includes simulation instructions, and it will generate a set of values for instance, current through a branch of the circuit as a function of voltage somewhere else in the circuit. We will not use a graphical interface for HSPICE, however, so these results must either be viewed in text form or displayed through a program like Matlab. An example netlist is given below:

    Diode I-V Sweep

    $This is a comment

    .options post node ingold=1 runlvl=0 relv=0.001 reli=0.001 DCAP=1

    .MODEL ml D (level=1 IS=1e-14 CJO=0 VJ=0.8 M=0.5)

    Vsrc 0 1 DC 1

    D1 0 1 ml

    .DC Vsrc 0 1 0.01

    .PRINT dc

    .end

    The first line is the title, which the netlist must include. Anything after a dollar sign is a comment, as in the line below the title, will be ignored by SPICE. Each compiler statement begins with a period; these tell the program what to do. The .options statement shouldnt be changed for these assignments, but make sure that you include it. The .MODEL statement is what you will be modifying with values generated in Matlab; here, it defines a diode model named m1. An example model definition for a BJT is given below without values:

    .MODEL bjt NPN(BF= BR= IS=

    +CJE= CJC= VJE= VJC= VAF= VAR=

    +NF= NR= RB= RE= RC= MJE=0.5 MJC=0.5 EG= )

  • The plus signs indicate that each line is a continuation of the previous one. BF is forward beta; BR is reverse beta; IS is saturation current; CJE and CJC are emitter and collector junction capacitance, respectively; VJE and VJC are emitter and collector junction built-in voltages; VAR is the Early voltage; NF and NR are forward and reverse ideality factors; RB, RE, and RC are the base, emitter, and collector bulk resistances; MJE and MJC are grading coefficients that should remain at 0.5 for our assumption of perfect step junctions; and finally, EG is the band gap energy, for calculation of temperature effects. More detail is given in the link below, from the University of Colorado: http://ecee.colorado.edu/~bart/book/book/chapter5/pdf/ch5_6_3.pdf

    Beneath the .MODEL statement is the actual circuit layout. Vsrc indicates a voltage source named src; 0 and 1 indicate the nodes and direction which Vsrc is connected, where 0 is always ground; DC indicates zero frequency; and the final 1 indicates a constant 1 Volt.

    Beneath that, D1 indicates a diode, named 1; 0 and 1 indicate that it is connected between nodes 0 and 1, where 0 is always ground; and m1 indicates the model to use to simulate that diode.

    To put a BJT in your circuit, use the following example: Q1 1 2 0 bjt Q indicates a BJT, and 1 indicates that its name is just 1; 1 2 0 indicates that the collector is connected to node 1, the base is connected to node 2, and the emitter is connected to ground (node 0); and bjt is the name I used for the model. The three terminals are always specified in this order.

    The .DC statement in the given example tells the program to simulate sweeping Vsrc from 0 to 1 Volts in steps of 0.01 V, and the .print statement ensures that it will output something we can use. All netlists must end with a .end statement. Another example sweep is below:

    .DC Vce 0 2 0.01 Vbe point 6 0 0.60 0.62 0.64 0.66 0.68 .DC says to run a DC sweep, Vce 0 2 0.01 sweeps the V source named ce from 0 V to 2 V in steps of 0.01 V, and the rest of the line indicates that the sweep should be performed for Vbe, at six different values, and those values should be 0, 0.6, 0.62, 0.64, 0.66, and 0.68 V.

    To run this netlist, access a terminal window, navigate to the folder containing the netlist (well call it netlist.sp, where .sp is the required extension), and type hspice netlist.sp. There should now be a .sw0 or .trw file in the same folder containing the results of the simulation. The output type depends on what kind of simulation you had it run (.DC, .trans, or something else).

  • To display the result, place the hspicetoolbox folder (will be posted on Blackboard) inside the same folder as your netlist. Open Matlab from this folder, and in the file navigator on the left side of the window, right click the hspicetoolbox and select add to path and then all files and subfolders. This tells Matlab to go ahead and use the instructions within. Then open HSPICEplot.m (also on Blackboard) and modify it with the appropriate filename and plotting options (logarithmic, etc).

    The HSPICEToolbox allows you to use the following commands:

    loadsig(name, file)

    This will load the simulation results stored in file to a Matlab entity named x.

    lssig(x)

    This will display the different signals stored in object x, created by the previous command. Make sure not to use a semicolon at the end, or else there wont be any output to read.

    current = evalsig(x, I_Vce);

    This will extract the signal named I_Vce from x and save it as a vector (list) named current. From here, you can treat it like any other vector in Matlab, plotting it against other things or referring to individual elements in it with current(i), etc.

    To test that you understand HSPICE, try making a netlist for a circuit containing a simple DC voltage source and a 10 ohm resistor (R1 1 2 10 will be a resistor, labeled 1, connected between nodes 1 and 2, with a resistance of 10 ohms). Instruct it to sweep the voltage source between 1 and 10 V in steps of 1 V (.DC vsrc 0 10 1), and display the results in Matlab (this will likely be the tricky part). Dont hesitate to ask for help; even though its a simple circuit, working with the software can be tricky.

  • ATLAS

    To run ATLAS, type deckbuild as & in a terminal window, preferably from a folder that is otherwise empty; the program will create a number of its own files in that folder, which will make it hard to find other things you might want. A graphical interface should pop up. There are a few non-intuitive things to keep in mind with this interface, the most ubiquitous of which include: left-clicking a menu will automatically select the first option in it; right-clicking a menu will open it in the standard way; and both delete and backspace delete characters to the left of the cursor. Also, scrolling is frustrating be careful to notice when it instantly jumps to one end or the other, and when it stops tracking the newest lines in the output.

    ATLAS operates on a deck, or a .in file, in the same way that HSPICE operates on a netlist. Deckbuild is the interface where you create these decks and instruct ATLAS to operate on them. There are a number of example decks available to see how ATLAS works. Load one of these by right-clicking main control, selecting examples and choosing the first BJT example file. Look over the deck and figure out what it does, then run it from the menu at the top and make sure that the results show up in a program called TonyPlot. If the first example you try doesnt run, try a few others the school does not have all the software packages that the examples depend on.

    For part of this assignment, you will be asked to create cutlines in TonyPlot. I tried to have these display automatically, but they havent been displaying reliably. To create them yourself, start from any statement in the .in file that says "tonyplot whatever.str; make sure you start with a .str file instead of a .log. This will show a very colorful cross section of your device in Tonyplot, under whatever conditions it was last biased before the "tonyplot whatever.str" command. To create cutlines in order to plot various quantities along those lines, go to the Tonyplot window with this colorful picture and click Tools, and then Cutlines. Click the button that looks like a calculator. This will let you manually define where your cutlines are. Create cutlines at the x values specified in the assignment (x=0.3 and 1.8 for the BJT), and make them from y = 0 to y = 0.5. Both x values should be the same for the same cutline in order to keep them vertical. Make sure to click "OK" instead of just hitting enter, as hitting enter will close the window without making anything. Creating a cutline will create a plot of net doping along that cutline. Right click this new plot and select "display" to choose the quantity you want to display on this plot (potential, E field, or whatever else you may want).

    The ultimate guide for ATLAS is its user manual which can be found here:

  • https://dynamic.silvaco.com/dynamicweb/jsp/downloads/DownloadManualsAction.do?req=silen-manuals&nm=atlas

    All ATLAS commands are detailed in that PDF. Here are a small sample of some ATLAS statements:

    #

    This comments out the rest of the line so that ATLAS will ignore it.

    mesh

    x.mesh

    y.mesh

    These will create a grid of simulation points. ATLAS works by determining what happens at each of these points and determining how each point affects the others near it. A mesh that is too coarse will miss a lot of important physics, and a mesh that is too tight will take hours to run (and may introduce bugs of its own).

    region

    These statements define regions for easy reference later on, and can be used to build an initial structure.

    doping

    Self-explanitory; use these statements to indicate the doping levels of different regions.

    model

  • ATLAS can run simulations according to a number of physical models, each of which had its advantages and disadvantages in terms of factors incorporated and time to run. These should not be changed for this class, though you are free to experiment with them.

    solve

    This statement is like .DC or similar statements in SPICE. solve init will solve the currents, voltages, etc in the state the system has been defined, and is good to include at the beginning of your solve statements in general ATLAS uses the results of previous simulations as reference points for further simulations, so solving the system at equilibrium is a good place to start. Voltage sweeps can also be performed with this statement; see the example files for more info. You will be modifying solve statements to perform most of your analysis.

    log outfile = stuff.log

    This saves the results of the previous solve statement(s) for viewing in TonyPlot.

    save outfile = stuff.str

    This saves the device structure for viewing in TonyPlot.

    tonyplot stuff.log set display.set

    This will display the results stored in stuff.log according to the display options saved in display.set. You can create your own .set files in TonyPlot by setting up the view you want from within TonyPlot, selecting save set file, and then adding the appropriate set statement at the end of your TonyPlot statement. You can also display .str files in this way, which you will need to do to make cutlines.

    To test that you understand ATLAS well enough for now, load and run an example file and view the results.

  • Finally, if these instructions aren't clear, please let your TA know. There are many good resources available online that may answer your questions, as well.

    Created by David Matthews, 2013

    Modified by Fan Zhou, 2014

    Modified by Michael Hayes, 2015