 Similarly what we want to do today is to look at digital simulation okay simulation of digital circuits. Now central to that is a very nice idea that is involved in simulating these integrated circuits. Before I get into the actual theory of that and so on which we will do the question that you should ask yourself is what is the biggest challenge for digital simulation okay. Now the simulation is 0, 1 there are logic equations so if you know what is the input calculating the output not a big deal for logic simulation okay. The bigger challenge is actually the complexity. What it means is that calculating everything to the n th degree of so many circuits which are typically expected to be there in an integrated circuit that is the real complexity okay. The other part is that suppose we had the computing power to simulate everything in detail that output will be useless to us because it will have so much detail that we will not be able to make sense out of. So the point is that in that case if we are not going to do a fully accurate simulation at an analog level then what kind of detail is expendable and what kind of detail is essential okay because those are the considerations which then go into logic simulation. So one thing is obvious that is 0 should remain a 0 or 1 should remain a 1 and if it is at an indeterminate level then that should be pointed out. That means you do not have 2 valued logic you actually have 3 valued or 4 valued logic like you have in very low for example. So just a binary bit is not very good for simulation because its output is constrained to be either 0 or 1 whereas in real life you may have some design flaw and if you cannot catch that flaw then why are you doing the simulation at all. If the simulation always tells you that you are right then you might as well not run it okay. So therefore one of the things is that the correctness of logic simulation is important then the appropriate choices of the output. Now what is expendable? The exact waveform is expendable for example suppose the output reaches 4.2 volts and then goes on to 4.6 and then dips down to 4.3 and goes up it does not matter a 1 is a 1 right. In fact that is what the previous lecture concentrated on how to make circuits so that a 0 is a 0 and a 1 is a 1 and the exact analog voltage within that range becomes immaterial okay. So you know that circuits are designed to be like that if you use logic gates. So therefore what is expendable is this analog detail. In fact if this detail is there it is distracting. When you look at a waveform and it has all sorts of wiggles and so on there is a lot of detail in this waveform of which as digital designers we have no use okay. So that is one thing which is not required. Is all analog expendable? Is it okay to have square waves for everything? The answer is no not quite square waves. The rise time is important for digital considerations the fall time is important the delays are important okay. So therefore we must not think that logic simulation is only a simulation is Boolean simulation where only whether in the inputs of 0s and 1s what outputs will be there in terms of 0s and 1s that is not the only thing. You do need some sort of analog simulation which estimates a time taken to go from a 0 to 1 etc etc accurately. So the actual transition time is important. On the other hand the exact shape of the transition is not important okay. So when I did the analysis of the CMOS logic gates yesterday we saw for example that initially it is linear and then it becomes logarithmic etc etc all those details are not important okay it is important to understand where most of the rise time fall time is going etc how you should bias if you are designing single logic gates but as a user of those gates designing designers of digital systems the exact trajectory taken in going from 0 to 1 is not important as long as the rise time fall time delay times etc are accurate okay. So that sets up our parameters of what kind of detail is expendable and what kind of detail is desirable okay and the more we reduce the detail the more efficient our simulation will be because we will not do the things whose output we do not desire okay. The other thing is that if you have a digital gate and if its inputs are not changing then there is no need to recompute the output right if the inputs have been known earlier and the inputs are not changed then there is no point in recomputing the output you can assume that the output continue to be at a level where they are okay. So we must make use of this and this is done in a style which is called event driven style okay in event driven if no event occurs then no new simulations are performed that means if there is no switching from 0 to 1 and so on no further simulations need to be performed however if there is an event you pull out the sub circuit which is affected by this event rest of the circuit need not be resimulated because their inputs are not changed okay so you pull out a sub circuit from this more complicated circuit which will be affected by the events which have occurred and then ripple through their outputs to see what events will be caused at the output as a result of these events at the input and then these will affect other circuits and those will affect other circuits and so on. So the style of our simulation is very different from circuit simulation which will be doing but I am sure you are familiar with you most of you do peace pies and so on peace pies you simulate for all time whether something is happening or not and you produce a plot of the output of the function of time continuously whereas here recomputation is done only when an event occurs okay so you have conquered complexity by 2 devices here one you never handle the full circuit you pull out the sub circuit which is affected by these events so as a result at a given time you are not handling the entire complexity of the large circuit that you are simulating so that is in the complexity phase the number complexity and in time complexity you are not looking at your circuit all the time you are looking at the circuit only when you need to right the combination of these 2 leads to efficient digital simulation and most digital or logic simulators or timing simulators make use of this the simulator that we are going to use today is called IR sim it was developed earlier at Stanford University it is been called by different names it was initially simply called sim okay however what they did was that they made it interactive and made it resimulatable okay I will tell you about resimulation what they did was something that we all wish we had the capability of and namely they can roll the clock backwards okay after all it is a simulation so you can roll the clock backwards so suppose some bug occurs it is not necessary that this bug has occurred because of something which happened now the that bug might be the result of something which happened much earlier so you need to have the capability of a trace back and therefore you need to have the capability once something has happened to go back now earlier the only thing was that is a bug occurs then you resimulate and stop it short of this and see if everything is okay up to this point and then stop it further and so on whereas here they made a program which is resimulatable in backward direction that is you can go backwards in time okay so that became from sim r sim okay and that was also a command line interface they made it interactive and that is called IRC that is the program that we are going to look at it is a public domain program it is a very good program okay also one advantage of using public domain programs for this sort of a thing is that source code is available and many additions have been written for this program by our own students okay to the extent that some of the junior students who had used these things went to some place and ran IRC when they came back to us and saying sir I do not know what kind of implementation they had it did not have this facility they had to be told that facility was homegrown and is available only in IIT Bombay so this gives a great deal of insight to the students to go fitting with the inside of the software and really understand how this logic simulation is taken this would never happen professional software which comes as an executable file largely protected you cannot look at it and it is so expensive that you would be shocked if you find somebody going and patching that code and so on whereas here the source code is available okay so this source code will be provided to you we will even if we have time tomorrow tell you how to recompile this day yesterday at least on paper I have told you all that business of of configure make make install etc etc we will actually do if we have some time by hand so that you know that going from a source distribution to the actual in implementation of the software how we go about okay that done now let us see what is the basic technical idea behind IRC and the technical idea is the following let us consider that you have a gate now this is loaded with some capacitive loading and so on now what was it we have already put down our parameters we have seen what is expandable what is not okay so now let us look at the circuit in that context let us say that this is some logic gate I don't care what function it performs okay and its output stage is capacitively loaded now I am not in reality this in during charge time we have seen that it initially goes in constant current mode and therefore linearly and then some exponential kind of charging because it the transistors have entered the linear mode okay I am not interested in this what I want to do is to define some particular points on this trajectory and say that as long as you give me this time accurately this is time this is voltage as long as you give me this time accurately then I don't care what exact trajectory it took to go from here to here you can pretend as if it went like this you can pretend as if it went like this and I don't care right this is what we have agreed that I don't as long as this time is accurate the exact trajectory in going from a 0 to 1 or a 1 to 0 is irrelevant okay now the in doing my analysis in the first lecture I had assumed a model for a transistor which was necessarily simple and I was worried that look actual modern devices may use a very complicated technology their models may be very accurate there are many things that we have ignored and therefore there are likely to be inaccuracies in my predictions okay so now let's look at a different way of this okay so let us eventually it is going to be charged by some transistor or some transistors this capacitor okay let's just just for the sake of argument let's look at a charge or a discharge alone all right so what is going to happen because of the intricacies of this logic there might be some series parallel some such combination it doesn't matter eventually an MOS device or a series of MOS devices are going to charge it up or charge it down okay now let's find out what the charge time is if you do not make any approximations or assumptions about the model of the transistor okay so let us look at the charge case because we already started discussing the charge case the discharge case is quite similar okay so eventually you have some device like this and this device is connected in some complicated series parallel whatever I don't care and this guy turns on and is charging my capacitor that's all that I need to know right now okay and I want to know what is the time that it takes to charge from a given and known voltage V1 to a given and known voltage V2 this could be say 10% of VDD to 90% of VDD whatever that is my convention but these voltages are known they are standard okay so now let's try to see how to write it down without making any approximation at all okay so therefore let us say that the current of this transistor is a function of the output voltage it is also a function of VDD and VGG but if I know the logic state the VGG inside is predictable right the gate voltage is predictable that's how it is off or on right so that voltage is also some digital voltage some fixed voltage which is not changing with time okay you have applied some digital voltage there and as a result of that the output is now changing okay so let us say that the current through this transistor I is given by some function of various technological or various other parameters which remain constant but as a function the instant is correct okay at any given time T the current will change with time so at a given time T there is a particular value V and this V uniquely determines the current okay so let's take a let's take a step back and see the validity of this assertion okay this is my V output which is a function of time what I am saying is that at any given time T the current which is provided by this is dependent only on V0 okay why is that so look the gate voltage is already established that is why this is charging so gate voltage whatever it is is some constant and the current is determined by what by the gate voltage by the geometry and the grain voltage the gate voltage is not changing the drain voltage is not changing the power supply is not changing the only thing which is changing is the output voltage therefore the instantaneous current through this transistor is some function of V0 it is not directly a function of time it is a function of time because it is a function of V0 right the for the current through a transistor doesn't change with time if the voltages are held fixed if the voltages are changed only then the current changes right so that is my assertion that it is some function of the output voltage once I have assumed that the rest follows what is the rate of charging of this this current is then equal to C dv0 by dt right this is the charge equation of this that this current will call the rate of change which will be related by this equation right all right in that case I can say that dt divided by C is equal to dv0 divided by some function of V0 ok notice that this function could be some hyper geometric series relation exponential log not the simple equation and I don't care as long as it is a fixed function I don't care it is some function ok it may be divided into three ranges four ranges linear saturated I don't care as long as the V0 is given the I is known that's all that I have to assume right now if I integrate it from 0 to charge time tau right I have separated the variables on the left there is no voltage dependence on the right there is no time dependence right so I can integrate these two independently over their respective ranges then 0 to t dt divided by C that means integral from V0 to V high these are known voltages ok dv0 upon this function of V0 right now I am not going to perform this integral what I am going to say is that look at this integral it is a definite integral therefore when evaluated it may come out some complicated function but doesn't matter eventually for V I am going to put V0 right so it will come out a new function of V0 right of V inside new function of VH and VL I will integrate it I will get some new function of V0 and I will put the limits in it it is a definite integral so wherever V0 occurs I will put some VH and minus that function with VL therefore this whole thing will be a function of now VH VL and constants but VH and VL dimensions are constants so this whole thing is a known constant if the function is not known but this whole thing will come out to be a constant which can be determined let's call that R it's looks like R it is not actually R it's very nonlinear very complicated doesn't matter it is some value I just happen to put R for that value then I get a very simple relationship what do I get this will give tau by C equal to this R where R is that integral evaluated with values put and that simply gives me tau is RC I know C R I do not know R is in theory determinable okay so now this is what I can do it is simple inverter just one single inverter and bring your circuit simulator with the most complicated model in the world the most complete model in the world okay and use that inverter to charge a capacitor okay you are now doing detailed circuit simulation so you will get all those complicated videos and straight lines and linear whatever it doesn't matter now measure the time that it takes to go from 0 to 1 that is your tau now you know tau you know C then you know R now just store it as a variable okay no more circuit simulation from now onwards you can just put this constant value of R in a different simulator and every time for the delay you just put this RC okay remember the value of this R might be different for charge for discharge after all the charges through the P channel discharges through N channel these are different transistors they may have different geometries doesn't matter okay so you take some standard geometry use the same standard geometry okay now it turns out that the scaling laws as this time are also well known for example you know that the current is directly scaled by W by L therefore where is that current here right so therefore this is this tau by C is this value and then you can just scale that R by W by L right that is in the denominator so the wider the transistor lower is the value of R and it will scale linearly right so that this tau will scale linearly with geometry and this came linearly with C because the only dependence of C is here right as soon as you done one experiment with a circuit simulator you found all the parameters which are of interest for the charge time similarly you do for discharge time okay once you have these parameters then you can set up a simple parameter file which will contain these equivalent resistor values right and now just describe your circuit as if it was a circuit simulator and do logic simulation what it will do is if the input changes from 0 to 1 it will schedule an event at the output calculate the CR time and will schedule an event at the output that much time later right then you finish all the events at the current time advance the time variable to that later time and make the output equal to that value at that time and then see who is affected by that value right and then re-simulate those calculate their CR values and schedule events at their output and so on till you have propagated the thing to all over the circuit okay so you follow the major insight is that if you are not interested in the shape only in the value of the time then essentially what you are saying is that I am able to cheat and assume that this f is a very simple function which is easy to integrate okay and since the whole thing is a definite integral it comes out the constant as long as I can calculate the integral it doesn't matter the detailed shape what the detail shape is the integral in some sense is integration of current is charged it tells you how much how how long it takes you to put that much charge on this capacitor okay you may put a lot of charge first and very little charge later or very little charge first a lot of charge later who cares this is only the integral value that you are interested in that is a constant okay so you may have two inverters with different kinds of transistors as long as they are values the same they delay is the same and for digital simulation they are equivalent for analog guys will make a lot of difference between them saying you know this is in constant current charging this is resistive charging or whatever we don't care okay on the other hand it does take those things which are of importance for example tomorrow you decide that the low value is something else the high value something else this time will change okay and then you have to recalculate data but once calculated you can set up a new parameter file as soon as you have a new technology new voltage differences and so on that means this thing depends on technology it depends on the supply voltage and it depends on your definition of what is the low voltage and what is the high voltage once that is given then for those values you do a detailed circuit simulation evaluate the value of R and then now for as long as these things don't change this R will remain the same okay this is what is done by IRC first is a parameter file okay this must be created and for most technologies these parameters are downloadable okay so for some technology the somebody has done that painful not very painful actually very simple calculation just just just do an inverter right just integrate just just do an inverter but it also provides you by the way a methodology so that you can do it on your own if you have a new technology okay so these parameter files are available or you can create your own doesn't matter okay the format and so on of this so but parameter file is one important cut before that you cannot proceed then you need a file which describes your circuit right so you the P-MOS is connected like this N-MOS is connected like this etc etc okay remember you are not thinking of it as logicates you are thinking of it as a detail circuit so every transistor is being described okay so P-MOS is given by this etc etc you give it what is the geometry of this transistor you must give because it's corresponding R value and the capacity load value puts on others that will be scaled according to its geometry okay so you must give the geometry so that the appropriate loads and appropriate on resistance etc can be calculated all of that comes from the circuit description combined with these parameters okay and finally there is a command file in some sense this is a remnant of the history of IRC in the sense that earlier it only had a command file it would not work interactively okay the original same program so you specify what inputs are provided at what time does the input change from 0 to 1 etc etc so you must have a language for describing the input okay and that is put in the file but in addition to that now it has become interactive there are other things that you put now you have a circuit you have a huge number of nodes you don't care for all of those nodes right in fact if it told you the waveform ID each one of those nodes that would be confusing and you will not be able to draw the proper conclusions so you there are only a few signals which are of interest to you and whose way forms you want to see so you should be able to specify of course every node will be simulated but you want you want to be able to specify whose way form will actually be reported on the screen okay so that is input output control you specify what signals are there at what time does the signal go high at what time does the signal go low etc etc okay all such stuff goes into the command file the command file is optional the command file could have been null 0 in that case all these things will be described interactively okay however the command file is a great help what happens is that let's say that there is this complicated circuit and you are working it up to a large part and then something interesting happens now every time you run the simulation you don't want to say alright clear this flip flop put this signal high then put the signal low and long story before you come to the interesting part right so what you would like is that all that history can be put in this command file and you run the command file and then the program should wait for you to give interactive input and then you can interactively make the time go forward or backward as you wish okay in addition to that they are debugging tools for example you specify a node and it will tell you which node is driven by it and which node drives it okay so if you are tracing the circuit backwards or forwards something is going bad at some node you want to know who's trying to pull it up who's trying to pull it down such questions can be asked and the program will provide you those answers okay now I believe that this is not the right place for doing it because you should have the program in front of you and then it is so much easier if I just start describing it here it will be that much interesting so we will hold that back for the lab session itself but in this session what is important is that even to make a beginning you have to understand how the program is going to be used okay so the program is installed as we have discussed yesterday it is installed in use of local bin use of local bin is in your path so when you invoke it okay you must invoke it with these three files okay and just to make sure see what happens is that these parameter files are going to be used left right and center and these are probably not generated by you so you are not familiar with this parameter file what happens if by mistake you produce an output which use the wrong parameter file okay so you might have simulated this effectively in point one micron technology whereas you have a one micron technology so you are very happy with the results but actually the results are not valid right so to take care of that this program puts down a tag which must be link with the parameter file so for example the parameter file may put down the lambda for a 1.6 micron technology for example it will say lambda equal to 0.8 so in your sim file you must put down lambda 0.8 okay that does a sanity check that this sim file was written for this technology and indeed the parameter file which is being used is that same technology okay so that one part is important the other thing is that just like any specification language it allows for comments it allows for various pause points and so on and those who will learn as we go along okay so this is the description of the program that we are doing now for our lab strategy for most of these programs I have a three tier strategy for doing it this is what I follow with students and I recommend that you follow with your students and the reason for that is the following suppose you have this big and complicated program which does things now most of the modern generation students are probably not afraid but if there is a new program I know I shouldn't be afraid but if it is a new and unfamiliar program I am a little inhibited at first okay because there are too many unknowns therefore as step one I provide tutorials what do these tutorials do everything is precooked for you you don't have to be anything you know that the program runs with this input file right because later very often the specific specification languages you put a semicolon instead of comma etc etc and they come back and swipe you across the face right so the point is that first let's take a familiar situation and do your tutorial we have done our work on it we know that this works if it doesn't work then you are doing something wrong in running the program once you are comfortable running the program with something wrong where you expect the output to be something it actually does those things then you become a little adventurous then you say let us see if I do this what will happen etc etc okay so the first step in this whole process is this playing around with something that somebody else has given you okay so I have one example for you this example is an adder okay but using CPL okay we have done this in the class yesterday so it is a good excuse now to become familiar with it you could have done it with the standard signals work with that as well but it is interesting to see how CPL works it's an unusual kind of logic so the given tutorial file is a CPL file okay notice that CPL while it has lots of very good properties it has one very bad property and that is that is the signal and signal bar are not matched they don't arrive at the same time then either both switches will turn on or the two switches that we saw yesterday or neither will turn on this can lead to glitches okay so it produces lots of glitches that's why it is not as widely used as this standard CMOS unless both in bit bar are time matched okay as Professor Chandorkar had described okay so one interesting side experiment of this is that right now on purpose I am generating the bit and bit bar in the worst possible way that means I am taking the signal and for signal bar I put an inverter right in other words it is 0 1 fork using Professor Chandorkar's technology yesterday's right and that you know will be very bad because in theory can never be matched right you need an infinitely fast inverter for the two delays to be matched but that is what I have used to show the functionality you play around with it okay so I have I told you I have a three step strategy for most of these experiments so the first of this tutorial in which case what you are learning is how this program operates okay the input is known to you input is given to you the output is known to you okay you are just confirming that it does what you expect it should do right the next step is an incremental step in which a small assignment is given to you the small assignment in this case is that you take out the inverter and for all inputs add a two three fork and adjust the geometries till the inverting and non-inverting inputs arrive exactly at the same point okay so you are not changing this a whole lot you are just taking out all inverters and changing the inverters by a two inverter chain and a three inverter chain whose delays are adjusted to be identical right two slow inverters and three fast inverters right so that they're totally the same correct now your bit and bit bar will arrive roughly as well as you can manage at the same time correct now run the same circuit again and see whether many glitches vanish or not that way you know which glitches were the results of this time mismatch okay now the actual result of this is not very important the adder is not an earth shaking circuit but the point is that you will become confident enough that you can now make changes to this file and run a circuit which is at least partially of your own construction the third step in the lab then is that you create something totally on your own okay so a simple assumption is given to you and you are asked that you design the circuit and see that it works properly okay and that assignment is something which is unrelated so that you will not be tempted to just redo what has been done the idea is that you just design very simple circuit just design a derived by two circuit using a B flip flop putting Q bar back to D right so it will become a problem if you flop you just give it a clock the output should be divided by two currently that's all that we can do in one lab right but the potentially obvious then later you can make a synchronous synchronous counter asynchronous counter decoder even and a unit or what you what have you right now the way this adder is made is that it first makes and or XOR all kinds of logic so it is first a tutorial in complementary pass gate logic and then it just makes use of or and XOR etc to make some and carry okay so it's a it's essentially a full adder of a four bit quantity right so that is what you are going to do first as a material then modify the bit by generation using forks and read it and finally create a file of your own and generate it using your own editor and creating it right by two circuit that is what is the goal of the lab today.