you know it is actually a full course we are trying to do in one session. So obviously we will not be able to do full justice to it as if every detail of this is going to be covered but I think a couple of qualitative factors about hardware description languages are very important to understand before we go and also then I will take out a little bit of the practical part which will be useful to you in doing the experiments. So essentially much of this session will be understanding below the bonnet kind of details of a hardware description language what is really involved and a little bit about the actual description of hardware. So let us first begin with why are hardware description languages required and the real reason for hardware description languages is that electronic circuits have become extremely complicated. Now the way we learn electronics is through drawing circuit diagram but if you have circuits which use a Pentium for example uses about 10 to the power 8 transistors 100 million transistors. So there is no way that you can draw a circuit diagram using 100 million transistors. Need to understand such complicated circuits the only way to go about is to have a hierarchical understanding that means let us take a simpler example let us not talk about Pentium every time. Suppose we take an 8085 with which everyone is familiar even to describe an 8085 is a big deal as a circuit diagram. So we never draw it to a transistor level in general what we do is we draw it to a block level. So if you say here is the register file here is the bus interface output you know bus input output unit here is the interface unit here is the ALU here is the instruction decoder and so on and then show the interconnection of those. Once we have understood this interconnection then we open out the ALU and say okay here is the adder, subtractor here is the shifter here is the and unit etc etc. So inherently this is understood hierarchically you understand a bigger circuit as an interconnection of block diagram and then you open out each block diagram and depending on the complexity you may describe that block also as an interconnection of other blocks till you have got it down to devices which are readily available. Now so therefore this involves essentially two journeys up and down the complexity path it involves for example this design as well as synthesis. So therefore description and synthesis are two opposite ends of this journey. In case of simulation for example you describe the circuit and then ask what is its behavior? In synthesis you describe the behavior in a standard way and ask which circuit will have this kind of behavior okay and both of these must be made easy and this is what the hardware description languages do alright. Before I get into very deep details of hardware description and so on you are all electronic teachers. So I would like to ask you what is electronic design what do we understand from electronic design all of you have taught electronic design, design based things and so on. So what is electronic design component values of what so is that the only thing that just the values of register is the design activity power supply but that is not all there is to design you are looking at you know different parts of an elephant here. So particular operation I so by the way none of these things is wrong these are different ways of looking at electronic design in different ways but one way of putting it is that you where do we begin electronic design with specifications right. Somebody gives us specifications so we are given a set of specifications okay by the way I am doing it on purpose on the board again there is a proper lecture series on this content which will be made available but I again do not like this flashing an entire page of information at you at one go I would like to evolve it step by step okay. So we begin with specification right and then what is our final goal from specifications where are we supposed to go we have to come up with the final design right. So therefore what is the actually specification the specification is a statement of the behavior of a circuit what in the behavioral description it says that when you do this this should happen okay so if this signal goes to one or there is an edge on this signal then this should happen etc etc a description which involves describing the behavior of a system that is specification right and when we have finished our job what have we got let us say some specification was given to you and you have designed it properly so no no so what do you return to the guy who asked you to design specifications are met but what is your output to that guy what are you giving that guy gave you specifications what are you giving to him give me a list of things that you will give give back to that no no hardware is too wide you will give him a circuit diagram a list of components the value of these components right so what we return is essentially and so then design our circuit which will finally result from this is an interconnect connection of known component right this is our final output what was given to us was the description of the behavior of a circuit we have based on our experience I know how a deep flip flop behaves I know how a counter behave I know how an adder behave and if I connect them in a particular way then I believe that the behavior of this will be the same as the behavior right the act of conversion from here to here is electronic design you agree with me right the idea is that we have given some specification which is essentially a essentially a description of the behavior of some system the guy who is giving me the specification will does not even know component he does not know what is the bipolar what is CMOS whatever he knows behavior this is what I want right it is our job then to select components and to interconnect them in a particular way using our experience that is our art right and using our art we interconnect these in a particular way and finally give give back to him saying connect this component to this kind of component this way and the component should have this value right so what you said about the value is important but that is our output back to that person okay so the value of the component is only one of the list of things that I will return this is in other words is structural description right we are given behavior that give me a circuit which will have this behavior and what I return to that guy is a structure saying here is this component here is this component pin 3 should go to pin 9 of that etc. etc. So this description if you look at it is the description of a structure what is connected to what whereas this is a description of behavior what happens when right and the act of electronic design is conversion of this to this right now nobody is saying that given some complicated behavior you will up and produce a circuit which will have this behavior that is not practical right so actually what what happens is that in this journey as we go from behavior to structure there are various steps in between which are partially behavior partially structure okay so for example suppose you told me design an 8085 now designing an 8085 may be a simple circuit by today's standard so it is a big deal I cannot sit in an afternoon and design an 8085 and give it to you right so what do I do when an 8085 is to be designed I just break it up into blocks right so what I say is that suppose I had a register file which was connected to an ALU in this fashion of course I am not showing the detailed way of connecting but I will have some idea that if it is connected to an ALU and the ALU receives instructions from an instruction decoder and the decoder got the instruction from the bus interface and so on right then my 8085 will work this is my first stage of decomposition right at this stage of decomposition what have I done I do not know right now how this ALU is going to work right I do not know what is the detailed design of this ALU at this stage but I know that if given a description of the ALU I can design it I trust in myself right so I I say that okay ALU can be designed register files can be designed decoders can be at etc etc right at this stage I am partially structural because I have described this interconnect okay that there will be an internal bus and there will be an enable signal and three clocks later and there will be a state whatever right so that I have designed however I have not designed the innards of this however I have derived this specifications of this I know exactly what this ALU is supposed to do for example in case of an 8085 I know that I should be able to add and subtract but I do not require a multiply and divide okay so now what have I done I have described this structure but I have also derived the behavioral description for each one of right in the next step I will take just this behavioral description and build it up okay so for example the I will take the ALU behavioral description and then say here is an adder here is a subtractor here is a shifter here is a series of AND gate here is a series of OR gate and when put together connected like this then they constitute this ALU right in the next step I will say this adder is this connections of ANDs and ORs etc etc XOR correct so this whole design process with the journey from here to here is a gradual conversion of behavioral description fully behavioral description to a fully structural description where do we stop we stop at a point where the components which we are using are already available and it is beneath contempt to design okay now that depends on the level of your technology for example you might say that below deep flip-flop there is no point going deep flip-flops are easily available do not ask me to design a deep flip-flop okay or you may have to go down to a transistor and say that even the deep flip-flop has to be broken down to a transistor so that depends on what kind of library is already available you have a library of component and those components are considered atomic the richer is this library the less work you have to do in order to design for example once you reach an adder you may stop saying adder is there in my library right so essentially when the components become components of a library then you need not design any further right because then adder is beneath contempt do not even talk to me how an adder is to be made adder is there in the library I will pick up that element from the library and place it it is equivalent to saying that I will go to the market and buy a 74 74 my deep flip-flop is there right so or whatever and beyond that I am I need not design so that because 74 74 is a equivalent of a library for you so essentially what it means is that when I stop I stop at a fully detailed interconnection of a set of components and these components are considered atomic and are known behaviorally to me and there is no need to go beyond behavioral for that right so essentially I start where the whole circuit is behavioral and end with a circuit which is fully structural of components which are known behaviorally is this part clear this is this is the journey and therefore any hardware description language should be able to cope with the behavior of a circuit which is designed in any gradation of mixing of behavioral and structural description ok for example suppose I was to tell a hardware description language that I have a circuit like this and these are the inputs and these are the outputs and now if I say that I excite this circuit with such and such waveform it should be able to tell you that this this will be the output alright on the other hand the same program if I tell it that here is a black box whose behavior is described in this fashion that assigned to Q the value of D when there is a positive positive edge on clock this is also an acceptable description and this is also an acceptable description now I may have different blocks some of this kind and some of this kind and I may put them all together in an interconnection and now this whole circuit may be excited with a certain input and it should be able to tell me that this will be your up alright this is the hallmark of a hardware description language that means it should have the capability of any gradation of behavioral and structural description and should be able to simulate it without any problem if whether it is behavioral or ok so this is point number one what what the HBL is supposed to do the second part is that the HBL actually has to it actually looks very much like a programming language and most of our students by the way how many of you have used hardware description languages ok so quite a few all of you will agree that if you look at an HBL it looks like a programming language ok therefore all the more reason that that it is very important to tell your students that it is anything but it is not a programming language ok so why is it not a programming language even though it looks and smells like a programming language ok the reason for that is the HBL when you have a programming language it is a series of steps which are executed sequences ok so the software is sequential on the other hand hardware is concurrent every part of the circuit reacts at the same time suppose you apply something then all parts of it will react at the same time right therefore to treat hardware as a program is inherently bad but on the other hand this hardware description language is going to run on a computer and therefore it has to do everything sequentially through a program so how do I describe something which is inherently concurrent using a device which is inherently sequential ok this is the purpose of the hardware description language in that sense it converts a sequential program and uses that program to describe something which is parallel ok so now let us see how that is done so what we say is listen if one thing is sequential and the system you are describing is parallel then you cannot have a proper clock because then you are simply saying that it will take me some time to describe one step and the next guy I will actually be describing it later but it should behave as if it occurred at the same time right so I cannot have a sequential clock in this system I must have some way of controlling the time ok so the way to do it is that now we say that the time to compute the time to run the program is of no consequence whatsoever that is something else right I do not care what I am going to do is to describe everything and I will have a time variable so the time is a variable now I may do operation X operation Y operation Z one after the other but as long as the value of the time variable remains the same these will be considered parallel you know concurrent and when the time has to be advanced I will do it as a conscious action not as a way of continuous flow of time so I will say alright now everything which was to have happened at this event has now been done and now please advance the clock to the next step ok so the so the so the advance of time is no more continuous it has been granularized and I do everything which happened at the same instant of time I may do it sequentially that does not matter how much time do I take to do it does not matter the time variable remains the same value therefore everything which I did would be interpreted as having occurred at one instant and which is the value of time which is at that time set this is the way I can handle concurrent ok you got that alright therefore I must understand time very well unfortunately time is a is a complicated it is not as simple as it appears ok I will illustrate this by an example let us say that I have a trivial circuit it does nothing at all it simply delays a signal ok so let us say that I have this black box this is its input this is its output and the function of this block is to delay it by 30 microseconds ok could be 30 nanoseconds anything invent some time for this now what is the behavioral description of this the behavioral description of this is assigned to output the value of input after 30 microseconds this is the behavioral description that whatever happens to the input make it happen at the output but after 30 microseconds right now let us try to implement there are various ways of implementing it the idea is was my specification unique was it unambiguous if it was not that it might lead to different implementations which are not equivalent ok if I am ambiguous so let us see is there room for ambiguity here or is it clear enough so let us take the most obvious implementation of this I will have let us say an RC delay and followed by a buffer so that I get a nice clean digital signal and the value of this RC has been so adjusted that the total delay including the delay of the buffer is 30 microseconds ok let us consider this scenario right this is this is a reasonable implementation of this I have converted this behavioral description to this structural description of known component ok let us say that the inverter the buffer is a known component register capacitor these are all known components let us produce a test case for this now in this test case what I do is suppose I applied to this delay circuit a pulse strain which has one pulse which is much narrower than the delay and another pulse which is much wider than the delay ok and let us apply this input to this implementation alright now this is not what the HDL will actually calculate but we know in reality what will happen so as this input goes high at this particular point this capacitor starts charging but it has hardly charged up to any value when it comes down and it starts discharging right so as a result the input to this inverter looks like it starts charging but immediately starts discharging right and at a later time starts charging but charges all the way up and then discharges for the wider this is what happens at this hidden node X and what does the buffer do it acts as a discriminator it says all voltages below some voltage is 0 all voltages above that voltage is 1 right so essentially what it does is that it converts this to this waveform so I get a delayed version of the input except that this narrow pulses back the wider pulse is delayed as specified but the narrow pulses back this kind of delay is called inertial delay but somebody else might look at this description and say this is not how I will delay the input signal what I am going to do is I am going to put an LED at the input with some current limiter or whatever and then couple this light to an optical fiber which is long enough to produce 30 microseconds of delay and then put a detector here which will convert it to a digital waveform and put that at the also this is also one way of delaying the input by 30 microseconds I have carefully calculated the length of the wire required to produce the amount of delay that I want okay now let us apply the same test pulse to this one what will happen at the output both the pulses will arrive right the narrow pulse will not vanish so now the behavior in the two cases is qualitatively different even though both are implementation of the same intended behavior the actual behavior of the synthesized circuit is qualitatively different why did this happen because it turned out that we hadn't realized that there are two kinds of delay and I must not specify only the delay I must specify what kind of delay I mean okay obviously this kind of delay is not illegal the RC kind of delay in fact that's the most common kind of delay nor is this kind of delay okay however the output behavior can be vastly different and therefore if I have to specify the circuit properly otherwise my specification itself is non-unique okay is not clear enough so therefore I must specify the circuit also specifying what kind of delay I mean okay this kind of delay is called a transport delay alright so therefore now we have a better understanding of time in general however this kind of delay is not very common in circuit the circuit delays are typically RC kind of delay therefore the default kind of delay is inertial so in most hard way description languages if you don't specify what kind of delay it is it will be taken to be inertial if you want a transport delay then you must be you must specify the keyword transport okay then the delay will be taken to be of the transport type there is one exception to it the input specification to any circuit is always supposed to be a transport kind of delay right for example if I was to describe this waveform itself right so I will say that make the input 0 at t equal to 0 make it 1 at t equal to 10 make it 0 at t equal to 15 remain 0 till t equal to 50 make it 1 at t equal to 50 and make it 0 at 150 now this is an input specification description of this waveform if this input itself became inertial then obviously I will never be able to apply this input the input itself this particular thing will vanish right so therefore the delays specified at the input specification are by default transport all other delays if unless specified are taken to be inertial okay if you specify transport of course it will be taken as a transport delay otherwise they are taken to be inertial delay okay only the input specification waveform specification are any waveform specification is considered to be transport that means essentially it is truly reproduced to be applied to the circuit where you want to apply the input all right this part is clear okay so when time when it is a question of time there are two things which need to be specified the amount of delay and the type of delay the type of delay is inertial by default and the amount of delay is 0 by default if you do not specify a delay then it is supposed to be 0 units of time and of inertial time all right this is the default value but that immediately brings a problem to our head because nothing happens in zero time in hardware anything which occurs must occur in non-zero time but here is this guy telling us that this thing should happen in zero time okay so the this may lead to problems because there may be two signals which arrive very close in time and the output may depend on which one arrived first and which one arrived later indeed it could be the here so whether the set arrived first or the reset arrived first will depend decide whether this q is 1 and this is 0 or that is 0 this is 1 right so therefore the order the time order that means the sequence of input is of great importance therefore we should not describe destroy that sequence and the way this is done is that internally a hardware description language invents something called a delta delay and delta is some undefined number which is a very small amount of delay but this simulator keeps track that this happened at t this happened at t plus delta this happened at t plus 2 delta this happened at t plus m delta right and this happened at t plus 2 microsecond now when the final results are presented and only when the final results are presented to the user you take the limit of delta going to zero so for example something might have occurred at 30 microsecond something else might have occurred at 30 microsecond plus delta something else would have occurred at 30 microsecond plus 2 delta and so on now for internal use you will always keep track that this occurred earlier than this that is important for the behavior of the circuit but when you present the final result you will take the limit delta equal to zero and to the outside world you will say this as well as this as well as this occurred at 30 microsecond so this is the mystery of the delta delay in hardware description language essentially to keep the scheduling proper things are calculated to the accuracy of some arbitrary parameter called delta so you actually keep it is a two component thing a real time plus the number of delta so the time is kept track off in as a two component system the real time plus this many delta and the time ordering is important because the deltas are important in time ordering whenever you order something in time then the deltas are taken into account but when the results are reported all deltas are put to zero and it is reported as if it occurred at delta is this part clear the delta time right so because it is important the sequence is important for the behavior of circuit you keep this artificial delta time internally and eventually take the limit as delta goes to zero if you have specified zero time right if you have specified a real time then of course the delay will be that much sir you are saying that when outputs are reported delta is assumed to be zero it means accuracy is kept hidden when outputs are reported no no no no no accuracy is not you specified at zero time otherwise delta would never have come some input sequence is coming one pulse comes at t another comes at t plus delta no no there is you do not know anything about delta you have said that this process takes zero time then the the program has a little laugh while you are not watching and he says what you really mean is that this occurred at t and this occurred at t plus delta so the problem started with you because you did not specify the amount of delta and most of the time our first simulation we we do not give any time but internally it says that a result and the cause must be separated in time and the result must always be a delta delayed compared to the input but that because you have you claim that this this guy took zero time therefore internally it will maintain accounts of deltas but when it reports back to you because you said it takes zero time it will put the value of delta equal to zero so there is no loss of resolution if you want that this inverter takes 30 picosecond of delay and the output equal to input bar after 30 picosecond then it will properly produce it will use 30 picosecond in that case but if you do not specify the time it will internally use the delta no delta delay is an artificially it is it it does not exist except for ordering things in time because later we will see time ordering is very important so the value of delta is actually zero in the limit but you do not lose that resolution internally because it is often very important as to say which happened first and which happened later in software it would not have mattered but this is very important in hardware because essentially you are artificially creating a parallel process from a sequential simulation right so you have to keep track of what happened when so you say this happened at this time and this happened at this time plus delta and this happened at this time plus delta in reality that delta may be put to zero eventually and if there is a finite amount of time that you have specified then you will say that this happened at 30 this happened at 31 this happened at 35 and so on all right if you say zero then it does not believe you it does not take zero it says that the effect should always be delayed by a delta from the cause okay and if that causes another phenomenon then that will be one delta after this and so on so the whole chain will be triggered and kept track of then you have a list of things which occurred at t t plus delta t plus two delta t plus three delta and they will all be time ordered in that way and your simulation will complete and when the results are given to you back then the value of delta will be put to zero okay so this is how we handle parallelism using this delta delay and advancing the time in a specific fashion now this is with this we have done absolutely the basic underlying assumptions about hardware description now comes the time for seeing what really happens during simulation and this is extremely important to understand because things are specified as if it is a computer program but what happens internally is extremely different okay and this leads to all sorts of problems with inexperienced designers so we next come to the idea of a transaction and an event yeah. Can you say that the simulation delay the internal delay has not been specified by the user internal delay has not been specified means zero delay is there and if the realization of the circuit which is a feedback type of circuit so under that condition how the simulation is exactly so you will require for that that is it at the following let us say that you say out equals A or B okay in VHDL for example you will use this intact like this now you have not specified any time so what VHDL will do is whenever the value of A or B changes it will recalculate the value of out but the new value will be assigned not at the same time when A or B changes but at delta time after that okay so that later suppose you were to suppose now there is a different circuit which uses A and out and let us say B has not changed at all okay so let us say B has been at zero throughout now at this point A change the output B zero so the output will change at a time which is delta later okay this delta will be zapped to zero when the output is reported so then it will look like that you will get the proper waveform there however now there is this circuit and this circuit will be woken up twice once to say A has changed what is your output at this point the out has not yet changed okay so its output will be scheduled to become something because of this change in A then a delta time later it will be woken up again saying out has changed what is your output and correspondingly the output will be rescheduled for some time plus two delta okay so the fact that A and out are not simultaneous and A arrives before out is retained in the simulator if you had put this delay equal to zero then this order would have been lost so for all you know the circuit inside here is that old match now whether A came first or out came first is significant accordingly the output would be set or reset and even though they came delta first or delta later the final output will be determined by that and therefore this order is important finally the output will be presented with delta equal to put equal to zero but how to determine whether this output is one or zero requires whether A came first or out again A dot A with some function out is there that output is connected to third level of the circuit so we have to add the two datas and after that only that is right so you it is a two dimensional time one is the real time and the other is how many delta okay and you keep track of both of them throughout all right only when you go to the next real time the delta will be set to zero so for example suppose the next clock arrived at 30 microseconds this happened at 20 microseconds so you kept track of 20 20 plus delta 20 plus 2 delta 20 plus 3 delta 20 plus 4 delta and then 30 and then 30 plus delta 30 plus 2 delta 30 plus 3 delta and 4 okay and then finally when the results are produced then you will see only 20 and 30 but the results will be correct in the time order and they would not have been correct unless you put this find distinction of what happened at 20 and what happened at 20 plus delta in everything you take delta if you say zero the simulator humours you saying okay you really do not mean zero you are simply saying that I do not care it is some infinitesimally small time zero is impossible okay so it humours you and internally uses delta instead and later because you said so it puts the value of delta equal to zero so it is not just for counters for everything whenever you say time is zero it replaces that zero by delta on the other hand if you do not for example you might define the OR gate as something whose output is a or b after 10 microseconds then it is happy it will schedule the output after 10 microseconds okay all right so the next thing to understand about hardware description languages is I am running terribly short of time myself of inertial time so the next thing to be understood is this idea of transaction so essentially you have an assignment which is of this kind where the right hand side is some expression it could be logic it could be anything it could be if then else whatever some expression then the way it is handled in hardware description languages is following when you struck this statement then the all the variables on the right hand side at that instant had some value okay the entire right hand side is evaluated at that time but the output is not put in this variable immediately it is put in a waiting storage and it is scheduled to be assigned to this at some future time if you have specified a delay then that future time is the current time plus delay if you have not specified that time then that time is the current time plus delta but in any in any case the assignment is never made immediately if it is not a variable for variables it is like a computer programming but for a signal the assignment is not made immediately ever it is scheduled to be assigned and that scheduling takes actual effect at a time determined by the amount of delay and if zero delay is specified then the actual value is acquired at t plus delta this thing is often not understood by students and you very often have bugs like like this so you say assign some to command and if command equal to some c equals a plus b else c equals a minus okay you will very often find code like this now this will do all sorts of terrible things and if you go through this code a hundred times you will never if you think that it is a computer program you will never never find out what is wrong with this so what is wrong with this all right when you say assign some to command it has scheduled the value some to command but the actual value is not some the actual value is the old value therefore when the if is executed some has the old value okay so it is not necessary that it is the command has the old value because the assignment has not been done the time is still t it will become equal to some at t plus delta but the current time is only t we have not yet advanced the time all of this is happening at the same time so therefore the value of command is not some right therefore this equality will be sometimes true if the old value was also some and sometimes false if the old value was subtract okay so therefore what this if will do is according to the old value of command not according to the new value of command okay so if Murphy is alive and well then it will so happen that the old value of command will also be some and then you will go you know Hurrah my circuit works and then you will go and call the instructor by that time the program has been running and the old value is minus and every time you do instead of adding a plus giving you the value a plus b start giving you the value a minus okay and this is because you have treated it like a computer program any computer programmer will will draw that value from it but this is not a program this is a hardware description okay so therefore never read it as assigned to command the value some always read it as schedule for command the value of some because this assignment is going to take place in the future not right okay and in the at the current time it retains its old value right and this also illustrates the value of delta what will happen is that if you had weighted a delta here then this if would have been correct because you have given time for this output to settle to its value but if you have not given time to settle to its value this is not correct okay now this is extremely extremely important because consider a trivial case of a shift register consider this shift register what is the behavior behavior is that add posage of clock do the following assign to q 0 the value of d assign to q 1 the value of q 0 and assign to q 2 the value of q 1 right this is the description of that all to take place only when the clock has a positive posage okay now suppose you did not have this suppose you assign the values right then without a delta time later what will happen the value of d will be assigned to q 0 immediately and that same value because q 0 is equal to d will be assigned to q 1 and that same value will be assigned to q 2 so this is not a shift register at all it is a dead shot everybody q 0 q 1 and q 2 have got the value d this is the circuit you are describing and this is not what you intended though the description appears to describe what you wanted that add posage of clock do this in fact you have ended up with something totally nonsense right on the other hand if the assignment is done a delta time later then all is all is fine because now what happens you are saying make q 0 the value of d in the next delta now q 0 has its old value then you are saying that make q 1 equal to q 0 in the next delta therefore q 1 also retained its old value and so on down the line and when the next delta comes only then these things acquire their values and therefore the shift register works properly okay so this tells you how important that delta time is otherwise you will get completely nonsensical result all right so therefore it is very this this sequencing is very very important without it you will not be able to describe hardware properly okay