The IRSIM Tutorial version 1.1 This is a simple tutorial on irsim. It is not meant to replace the irsim manual which contains much more information. 1.0 Which computers can use IRSIM IRSIM runs on Unix. We recommend running on chips, a Sun UltraSparc server in the VLSI lab. You can also download the source from chips and run it on your own machine. 2.0 Creating a .sim file Irsim files are just text files that contain information about a circuit. They have the extension .sim. The first time you use irsim, you will probably have to create the .sim file yourself using your favorite text editor. Later you'll create it from a layout that you do in Electric. Below is a CMOS circuit to implement ~a~b + ~c where ~a means the inverse of a. Vdd ___________ ___| | || | a ---o|| | ||___ | | |___ | n1 || | ||o--- c ___| ___|| || | b ---o|| | ||___ |----------- out |___________| ___| |___ || || a ----|| ||---- b ||___ ___|| | | |___________| | ___| n2 || c ----|| ||___ | _|_ Gnd \ / V The first step in creating a .sim file for this circuit is to label all the nodes. Label power Vdd and ground Gnd. Irsim is not case sensitive so vdd and gnd will work also. You can label the other nodes anyway you want. Use any method you wish. For the circuit above, the inputs are labeled a, b, c and the output node is labeled out. Other internal nodes are labeled n1 and n2. When using irsim, it is helpful to have the labeled circuit schematic available so that you know the names of the nodes that you want to probe. The .sim file for the above circuit is shown below. | units: 50 tech: scmos p a vdd n1 2 4 p b n1 out 2 4 p c vdd out 2 4 n a out n2 2 4 n b out n2 2 4 n c n2 gnd 2 4 The first line is a comment. Any line that begins with the vertical bar '|' is a comment. Everybody knows the purpose of comments I hope. This first line says that the technology used is scalable cmos and that all dimensions are in units of 50 centimicrons or 0.5 micron. For example, the pmos transistor on the next line has a length of 1 microns and a width of 2 microns. Transistors are specified as follows. type g s d l w where type is p for pmos and n for nmos. The g refers to the name of the gate terminal. Similarly, s refers to the name of the source terminal and d refers to the drain. This is why you need a labeled circuit schematic to create a .sim file by hand. It is important that you get the connections correct. The l is the length of the transistor and the w is the width. The first transistor specified in the example above is the top-left pmos transistor in the corresponding schematic. Study the rest of the irsim file and the circuit. It is easy to see how the two match. You can also enter in resistors and capacitors. See the irsim manual for the proper format to create these elements. Considering just transistors, you are now ready to run irsim. 3.0 Starting IRSIM At the unix prompt type irsim /cad/tech/scmos100.prm *.sim scmos50.prm is the technology file and *.sim is any irsim file. For example, if your .sim file is named circuit.sim type irsim /cad/tech/scmos100.prm circuit.sim irsim will tell you how many transistors you have and then display the irsim prompt shown below. IRSIM> 3.1 Running IRSIM You can enter in commands interactively or you can run a script. Scripts are just the .cmd files and they contains commands that are exactly what you would type in at the irsim prompt. Here is an example irsim session. The IRSIM> prompt precedes commands that were entered interactively. Text preceded by the vertical bar | is output from irsim. Instructional comments will be preceded by //. IRSIM> stepsize 50 // The basic idea of irsim is that you tell it which nodes // to pull high, which nodes to pull low, which nodes to // tristate, and then you tell irsim to run the simulation // for a certain period of time. This period of time is the // stepsize. The above command tells irsim that the // stepsize is 50ns. IRSIM> w out c b a // The command 'w' tells irsim to watch the following nodes. // So the above command tells it to watch the nodes out, c, // b, and a. Irsim displays the nodes in the reverse order // in the above command. Therefore the output order will be // a b c out. This is just a matter of personal preference // though. Enter in the nodes in any order you like. IRSIM> d // d displays all the nodes that are being watched. // You can also enter in something like 'd a b' which tells // irsim to only display nodes a and b | a=X b=X c=X out=X | time = 0.0ns // at time zero, the values of the nodes are all undefined IRSIM> l a b c // The l command forces the nodes to a logic value of 0 // The above command sets nodes a b and c to logic 0 IRSIM> s // s tells irsim to simulate for a certain period of time // previously defined by the stepsize command. The default // value is 100 ns. | a=0 b=0 c=0 out=1 | time = 50.0ns // Irsim displays the values of the nodes after each step // because of the previous d command. The current time is // also displayed. Note that time = 50 ns. This is // the current simulation time now. IRSIM> h c // h sets the following nodes to a logic high value. // Therefore the above command sets node c to logic 1. IRSIM> s | a=0 b=0 c=1 out=1 | time = 100.0ns // step IRSIM> h b IRSIM> s | a=0 b=1 c=1 out=0 | time = 150.0ns IRSIM> path out | critical path for last transition of out: | b -> 1 @ 100.0ns , node was an input | out -> 0 @ 100.1ns (0.1ns) // The path command shows the critical path for the last // transition of a node. // The output shows that an input node 'b' changed to // logic 1 at time = 100 ns. The node 'out' then // transitioned low at time = 100.1 ns. Therefore it took // .1 ns to go from high to low for the given input changes. // You can look back at previous commands to verify that // this is indeed what happened. // Sometimes you may want to find out what the worst case // Tplh or Tphl is. The path command helps you find this // number. You do this by setting the circuit to some state // and then force inputs to change that will cause a // transition at the output. Some intelligence is required // to figure out what the worst state is and what // combination of input changes will cause the slowest // output transition. // If you have a long list of inputs, it can be tiresome to // keep using the l and h commands to set the logic // values. The 'vector' command lets you group inputs // together so that you can set them all quickly IRSIM> vector in a b c // The above command tells irsim to group the nodes a b and // c into a vector called 'in' IRSIM> set in 000 // This command tells irsim to set the vector in to 000 // Therefore, node a = 0, node b = 0, and node c = 0 // The following commands demonstrate how you can create a // truth table using the vector 'in'. Note that you can do // this much faster this way than by using the commands // l and h. IRSIM> s | a=0 b=0 c=0 out=1 | time = 500.0ns IRSIM> set in 001 IRSIM> s | a=0 b=0 c=1 out=1 | time = 550.0ns IRSIM> set in 010 IRSIM> s | a=0 b=1 c=0 out=1 | time = 600.0ns IRSIM> set in 011 IRSIM> s | a=0 b=1 c=1 out=0 | time = 650.0ns IRSIM> set in 100 IRSIM> s | a=1 b=0 c=0 out=1 | time = 700.0ns IRSIM> set in 101 IRSIM> s | a=1 b=0 c=1 out=0 | time = 750.0ns IRSIM> set in 110 IRSIM> s | a=1 b=1 c=0 out=1 | time = 800.0ns IRSIM> set in 111 IRSIM> s | a=1 b=1 c=1 out=0 | time = 850.0ns // the '?' command shows the source/drain connections to the // node. So it tells you what is driving this node. IRSIM> ? out | out=0 (vl=0.40 vh=0.60) (0.0120 pf) is computed from: | p-channel b=1 n1=0 out=0 [7.5K, 8.4K, 16.6K] | pulled up by c=1 [7.5K, 8.4K, 16.6K] | n-channel a=1 out=0 n2=0 [3.7K, 7.0K, 4.4K] | n-channel b=1 out=0 n2=0 [3.7K, 7.0K, 4.4K] // "p-channel b=1 n1=0 out=0" means 'out' is connected to a // PMOS whose gate is tied to 'b' and S/D tied to 'n1' and // 'out'. // "pulled up by c=1" means 'out' is connected to a PMOS whose // gate is tied to 'c' and S/D tied to 'out' and 'Vdd' (pull-up) // similarly about the NMOS // Suppose 'out' is a X. Then you can use '?' command to figure // out who is driving this node to be X. Let us further assume // 'C' is X, hence it drives 'out' to be X. Then we can use '?' // to find out which node causes 'C' to be X until the root of // X is found. So this is a really handy command for debugging // in IRSIM. // the '!' command shows the gate that this node is connected // to. It tells you what transistor this node is driving. IRSIM> ! b | b=1 [NOTE: node is an input] (vl=0.40 vh=0.60) (0.0072 pf) affects: | p-channel b=1 n1=0 out=0 [7.5K, 8.4K, 16.6K] | n-channel b=1 out=0 n2=0 [3.7K, 7.0K, 4.4K] // from the info above we know that 'b' is tied to the gate of // PMOS with S/D tied to 'n1' and 'out'. 'b' is also tied to the // gate of NMOS with S/D tied to 'out' and 'n2'. // irsim has a built in graphical logic analyzer. You can // use this to see waveforms. The 'analyzer' command sets // up the analyzer window IRSIM> analyzer a b c out // This tells irsim to display the nodes a b c and out in // the analyzer window 3.2 Using the analyzer window Go ahead and experiment with the analyzer window. It's pretty easy to use. Here are some of the things that you can do. 3.2.1. Print the waveforms to a postscript file Go to the 'print' menu and select 'file'. You will be asked for a filename. Hitting return selects the filename shown in (). Once you have the postscript file, you can print it out on one of the network printers using lpr. 3.2.2. Setting the width 3.2.2a. You can set the width of the view from either the menus or the slider on the bottom. From the menus, select 'window' and then 'set width'. You will be asked to enter the width in time steps. Use the 'move to' option under the 'window' menu to move to the desired time. You can also use the 'zoom' menu to zoom in and out. 3.2.2b. The best way to get a feel for the slider on the bottom is to play with it. Using the left mouse button expands the view or shortens the view to the left depending on where you click. Clicking using the right mouse button expands or shortens the view to the right depending on where you click. You can grab the slider with the middle button and move it around. 3.2.3. Changing the order of the nodes If you don't like the order that the nodes are displayed, you can click inside the name with the left mouse button, and drag it to a new place. Play around with this to see how it works. 3.2.4. Finding the time of an event You can click inside the analyzer window where the waveforms are to get a vertical line. The time where this vertical line is is displayed above. This is useful if you want to find out when a rising edge occurs. The resolution is best when you are zoomed in. // You have seen the commands 'l' and 'h' to set nodes to // logic 0 or logic 1. The 'x' command will effectively // put a node into tristate. It does this by taking the // node off the input list. // The following is an example of using the x command IRSIM> x bus // puts the node bus into tristate. An application of this is // simulating a register. Assume you have a one bit register // that is connected to a line called bus and is operated as // follows. To write a value in your register, you need to // drive the value onto the bus and then set a control line // write to high. To read the register, you first need to stop // driving the bus. Then set a control line read to high. The // irsim commands you need to issue are shown below. IRSIM> l read write // set read and write control lines low IRSIM> h bus // let's write a 1 into the register IRSIM> s // step IRSIM> h write // write into the register IRSIM> s IRSIM> l write // stop writing IRSIM> s IRSIM> l bus // set bus to 0 so we can see the bus // transition from 0 to 1 when we read // the register IRSIM> s IRSIM> x bus // stop driving the bus so we don't get // bus contention when we read the // register IRSIM> s IRSIM> h read // read the register; you should see a // 0 to 1 transition Irsim lets you keep a log of your commands and the outputs. To start recording, type IRSIM> logfile anyfilename // Anything that you see in irsim from now on will be // into the file 'anyfilename' // When you're done recording, type the following. IRSIM> logfile // Quitting IRSIM IRSIM> exit 3.3 Automation through .cmd files Any irsim interactive command is valid. Use your favorite text editor to create this file. An example is shown below for the previous circuit. stepsize 50 analyzer a b c out vector in a b c set in 000 s set in 001 s set in 010 s set in 011 s set in 100 s set in 101 s set in 110 s set in 111 s // end of example; do not type this comment in This example runs through all the possible combinations of inputs. The waveforms will be displayed in an analyzer window. You can run a .cmd file from the command line or within irsim. If the above file is called example.cmd, then % irsim scmos50.prm circuit.sim -example.cmd will run the command file on circuit.sim To use a .cmd file within irsim, type 'example' as shown below. IRSIM> example Note, you should not type 'example.cmd'. Another alternative is IRSIM> @ example.cmd but the previous way uses less keystrokes. Frequently Asked Questions: --------------------------- Q: IRSIM tells me that I have pending events. What does that mean and is that bad? A: This means that at the time that the simulation step ended, not all of the nodes in your simulation have settled. You can find out which nodes have pending events with the printp command. If your circuit is still working, then even if you have pending events it is ok. However, this might be an indication that if your increase your clock speed much more, your circuit will begin to operate incorrectly. Q: When I bring up IRSIM, it says that I have shorted transistors. What does this mean? A: This means that you have some transistors that have their source and drain shorted together. So unless you are trying to build a capacitor, this is not a good thing. Q: When I bring up IRSIM, it says that I have parallel transistors. What does this mean? A: This means that more than one transistor have the same gate,source, and drain terminals. If you've folded transistors (like maybe for a large driver), then you will have transistors in parallel. This is not a bad thing, provided that you meant to have parallel transistors. When running simulations including the pad frame, some groups have been frightened by the extremely high number of parallel transistors that irsim reports. Keep in mind that the pad frame alone has very many parallel transistors (large drivers with folded transistors). The pad frame alone reports: parallel txtors: n-channel=748 p-channel=714 Q: I want to save the state of my simulation, so that I don't have to keep running my dorky setup command file every time. How can I do this? A: There are 2 ways to save the state of a simulation in irsim. The first way saves the state of the sim as well as the history. The second way only saves the state. The command dumph will dump the history of the simulation to a specified file. The readh command will read that history back out. Please take a look at the irsim manual page for specifics. The > command will write only the state (not the history) of a simulation to a file. The < command will read this back out. This is especially useful for running very long tests, where the history buffer of irsim gets huge. You can break up your test and at the end of each piece, write the state to a file. When you start up the next piece, just read that state back in. Q: How do I flush out the history buffer? A: When you run very long simulations, you will find that the hsitory buffer gets unmanageably large. The command "flush" will empty the history buffer. So you can put this in your .cmd files periodically, if you don't want the history buffer to get too large.