 Good afternoon everybody Can we settle down the last rows are you able to hear me clearly? It's okay The volume is okay Yes, no super So my name is Anjan I'm this guy over here I will be Your lecturer for this week and the next week teaching you very long Frank will be back tomorrow. He will teach sequential circuits, but today will be How to implement? combinational circuits in very long do you Ask a lot of questions Do you want to use this for fun? No Let's see I've never tried it. It's fun people. I see people throwing it around but good. Okay, so since the Classroom is way bigger than we expected last year It's better if people kind of reduce their tone when they discuss with their partners if you want because even if one person talks Then it's kind of comes down very slowly So let's go What did you learn in the first two weeks of this lecture? Can someone close the door, please? Thank you We saw how the history. Yeah, sure Let's see it's good so Till now you saw the history of computer architecture How microprocessors have evolved over the couple of decades? Last week you saw how Transistors are made and How to design logic circuits like a simple logic gate like and or are using these transistors? You also saw how you can put together a number of these logic gates to make something meaningful And what you will eventually do over the course of this semester will be putting all these useful blocks into a whole microprocessor This is pretty much what you are going to do in your lab It's going to be very interesting and this is one of those labs of labs Where you will actually learn how to start off from a schematic till all the way up designing your own microprocessor Writing your own code and actually seeing it run I believe you had a brief demonstration last week So and it was just the beginning you will be actually playing snake with the boats that you will be getting you will be programming Snake so we go from transistor level Building some logic gates some useful blocks putting it together to make a microprocessor Writing assembly programming for your own microprocessor and then taking it all the way to actually Interfacing a display such that you can actually play snake for example And this you will be doing in groups of two so it's going to be a great experience So we saw we saw something about so you saw how Transistors are put together into a logic gate and then these become a schematic I don't know whether you have already done one lab. Have you You know some some groups have done one lab. I guess okay, so you will be designing kind of a schematic in your first lab and You're not going to do something like this don't get scared. Okay, so this is how typical boats look like like This is like one of those very old Development boats if you see the date is 86 87 here. So this is how schematics were done in the past But today's microprocessor are extremely complicated. You cannot It's not imaginable to sit and do such a circuitry in a in a in a software and trying to make it all work and Put it into a chip. So what we have is our hardware description languages and I believe Some portion of it was covered last week, but just for a recap. I will continue from here So what are hardware description languages? If I'm going very fast, let me know if I'm going very slow. Let me know. It's all going to be fine So what are the hardware description languages? They are very similar to see and other programming languages that you are more familiar So what do they do? They help us and they enable us to have a very easy way of putting in these schematics such that the computers can understand and Actually build these circuitries Imagine that you don't have a programming language today. You will be writing zeros and ones This is exactly what you can think of as these hardware description languages. They basically Enable you to model the circuits in a very C-like or programming language In a in a in a in a very syntactic and semantic way They support all kinds of logic gates the all the functions that you saw like and are all these things you can simply Put in it and it will realize this and get for you. You don't have to do anything. You simply write statements or code So basically it's a convenient way of drawing schematics some other Advantages of using a hardware description language is that they are standardized It's like see you learn the syntax and everybody can understand. It's not the same for it's not the same for schematics if you see One person's schematic. This is not exactly the same as another person is going to draw the same schematic You will actually observe this in your own labs where you will be drawing a schematic of a particular circuit and the same circuit schematic if you look at another group completely different and Potentially are not going to understand each other so well and this is pretty much why everybody bought to came together and developed this hardware description languages. It's not proprietary and Example your schematics that you draw in a particular software can only be processed by that particular software and Here you can write using a text you can using a notepad text pad Whatever you use it and then simply feed it and any compiler that is capable of handling these STLs can actually process it Again, it's easier for computers to understand what you are trying to tell because if you draw a schematic It's much more difficult for it to come off Somehow look at the image and process it instead if you give them code It's much easier and also there are several additional benefits that were discovered In your lab you will actually write so you design the circuitry and then you have to test whether it works What happened is that? by actually enabling The schematic to be represented in such a way We were able to actually run our own test benches and actually test the circuitry even before we go into the hardware chip manufacturing This is very important It's not there's a big difference between software development and hardware and chip design because it takes Approximately six to eight months from your chip design to for you to get back the actual chip But in software you write code you deploy it you test it doesn't work And then it comes back and then you fix the bug But here the turnaround time is much longer and imagine if every bug needs to be fixed in this way You are not going to get any product out at all so You can actually simulate synthesize and test your circuitry because of these hardware description languages There are two hardware description languages very long and we HDL Don't ask me why very long is more popular in the US it is popular in the US and we HDL is by somehow by the history says some of the in the history you have Europe adopted we HDL more predominantly And in this course we will use very long and this is what I will going to be Going to be talking about this this week in the next couple of in the next couple of hours. I Would like to stress here one thing if you follow the second edition of the digital book its System very long. We are not going to do that Follow the first edition of the salmon Harris book. It's actually the Real very long. There's it's we are not going to talk system very long in this course We are only going to focus on very long. So Don't follow the second edition. There might be additional constructs additional syntaxes which might confuse you follow the first edition so Let's get started So first thing is a module. What is a module? It's the building block of very long and It's what I you can relate to this module as something Meaningful something like what putting together a bunch of and then our gates you can say this model is Representing some behavior of a circuit that you want and if you want to represent the very long module What do you need? What do you need for a circuit? So if I show you some block like this a b c and y what do you get from this? Yeah Yeah, so so what you need is basically and it's a set of inputs a set of outputs in this case only one and then You have a whole bunch of functionality that that goes into the module itself But just from this figure You don't know which is input and which is output It's the same exact same case even for the computer. It doesn't know what is the input and what is the output? We just know because we typically think the left side is input and the right side is output So basically what you need to declare a module is input Output and the functionality and this is exactly the syntax here So what do you do when you define a module and this is the main building block when you start writing very long you write module and all the keywords that you cannot change are in bold here and Everything else is up to you. You can even say ha ha hoo boo boo doesn't matter Okay, but the ones in bold are keywords. You cannot change. So you say module and Then you give a name for your module which is the name for this very long module It's can can be example and then you can Given all the signals that are going into the module and our outputs of the module You don't have to worry at this stage. What happens inside the module? All you need to know are what are all the signals that are required to build the module inputs and outputs So you simply give a comma b comma c comma y and then you actually tell The system what is input and what is output and you have input So you can say that a b c are inputs exactly like this input input input and then y is an output And then you have an n-module note that a lot of people make this mistake in the labs. They give a space here There's no space between n-module. So it's a very silly mistake Just keep in mind that you don't have a you don't end up with a space there And Then you give the circuit description itself inside this we will now slowly over the course of this Lecture we will build how to how do we come there? Also one of the best one of the interesting things of very log is that you can write in Million different ways really million different ways. There is no good way of doing it for example You can write exactly the same thing like the one that we say so module Test so the name of the modulus test which we give and then you go inputs a b and the output y Or you can actually move input a right into the braces when you declare as Input a input b output y and you are still going to be fine So there is no there's literally no difference between writing it this way or this way so Now these a b and y are basically single bit Single bit lines. So very log also helps you to define a boss You already know what a boss is right? No A boss is a set of digital lines. Okay, so it's it's basically Typically you don't have so it you can consider bus to carry information from one point to the other in a circuitry and You can also so and and you have multiple so you have a it's a 32 bit data So you have 32 lines for the variable a it's basically in programming languages. You can think of it as an array and So what why do you need it is because? for example when you do any kind of Arithmetic so any any kind of computation for example a simple ad and when you do a plus b a is going to be a 32 bit Number b is going to be another 32 bit number Because as you know if you have two bits you can only represent zero one two and three and If you have 32 bits you represent to power 32 right so typically for any reasonable Computation you have typically six eight bits or 16 bits or 32 bits. So you add two 32 bit numbers and to you can actually define these as the following so you have a start and An end which is 31 so it's this is 32 bit a is now 32 bit value So you say input 31 colon zero always? always It's a good practice to put the higher order the higher number in the front It's because we follow a little Indian and this little Indian is basically telling you that the left side Wire is the most significant bit If something is Greek and Latin for you, please tell me okay, because I'm just trying to Get a feel of how much you know So you all know what's the most significant bit right? Yeah, okay, so you have two different ways of representing Representing data like digital data. So you have if you have a 32 bit number You have you can represent it in two ways. I have to write it down somewhere and I hope everybody can see This is a better place or you want me to use this one the middle one the middle so You have let's say you have four bit data and I can write it as one zero one one now If I don't tell you whether it's a little Indian or a big Indian You will not know which is the least significant bit and which is the most significant bit. Why does it matter? because In a typical system in a little Indian system. This is the least Significant bit what this means is that and this is the most significant bit So what this basically means is that you read this as let's say this is what? Quick anybody One zero one one. What's it in decimal? Yeah 11 It's decimal 11 in little little Indian But if you say big Indian then you have to read it as the other way around so this becomes your MSB Which basically means you will say one one zero one and this will so you basically start from here One one zero one and this is big Indian format, which basically means that this is going to be 13 so you see the difference and It it doesn't So it's a good practice to always follow one particular way of telling the system It doesn't matter when you are the only one designing the whole system But when you are going to ask somebody to interface with your system, then it's going to be a big confusion here All the bits are going to be reversed because the other person is going to say 0 to 31 Maybe or you are writing as 0 to 31 and the other person follows 31 to 0 And when you connect your two devices together all your bits are going to be going Exactly in the other way and interpreting it in the other way So always it's always good to follow one particular way of writing So I I strongly recommend Following this little Indian way of doing it. So it's like you always start with the higher order bit Any questions here? So some simple basic syntax Very long is case sensitive. You all know what it means some name doesn't mean some the smaller order some name You cannot start your variable names with the number and typically white space is all ignored and These are some recommended good practices which you can follow in your lab exercises Consistent naming style always use the functionality So aha who is allowed, but it's not going to tell anything. So always use a Name that is relevant to the functionality Ops As I said always try using a 31 to 0 and not a 0 to 31 It's for Maintaining little Indian which is more popular Also define one module per file. So the module syntax that I gave you The opener file name the file name exactly the same as the module name So if you say a module and whose name is example name the file example that we and this is Easy for you to find where each module is and do not put too many modules in one single file because it's it's going to be a management it's more of a file management issue than Correctness it's going to be correct still and As I said use the file name that equals the module name So there are two main types or main styles of writing hardware description languages One is the structural type and the other is behavioral In a structural what you what you're going to say is you know how the circuit looks like You know the gate level circuitry You know how to connect which gate from to which gate or you know how each module is going to be connected with other Module so you kind of straight away represent this the circuit in a structural format the other one is behavioral where you know that if a is one then B has to do something and you can actually say this without knowing how to realize the circuitry in the digital sense and We will see how we do both structural and behavioral because you need both these Because when you implement and test a practical circuit you are going to use a combination of structural and behavioral styles of writing a hardware description language So what is structural? Let's take this simple example In this example you have three blocks Do I see three blocks or two blocks? three blocks One is called the top Let's say three modules in yeah, okay. Let's say three blocks for now. So it's a top small and small Small and top are the two modules So as you can see This is kind of you have you have a bunch of input signals a select C And you have an output signal y and you know exactly how you are going to connect this small module With this small module and how the output of the first small module is going to be connected It's going to be connected directly to the input as an input to the other small so you know the structure of the circuitry and you can actually directly Directly state this in your hardware description language And how would you do that? Let's see now Okay, actually, let's let's do it together. It's easier that way so as you can see you have two small modules right and What we will have actually have is you just need to write one small module and then you instantiate the same small module Two times so you have I first and I to and then you put these two instantiations into a bigger module called top and This is exactly what is here. So you first write a top module which You forget about the inside ones. Okay, you just simply forget these small modules All you need to see is only the top module and for the top module what you have you have the inputs a Select C and output y and this is pretty much what you have here a select C y input a select C output y And you have a wire and this this wire is needed to connect the block inside I'll come to it later Now when you consider the other module the small module So you have another module here, which is like module small and for this small module What are the inputs and outputs? It's a b and y and this is exactly what you write here So you have module small a b and y and remember you can actually have the same Name same variable name in both. It doesn't matter. They are typically independent modules so they will not going to complain at all and You say which is the input which is the output and then you have the description of the small what does that small do? And it out still now All clear So exactly top this is the top small module the two small modules and then you have the wire Which basically connects the two small modules there is wire and register which people typically get confused a lot What you need to understand for the combinational part of the course is wire So wire creates combinational logic and when we talk about sequential circuits next week or in fact Tomorrow when Frank talks sequential circuits, you really understand the difference between wire and register But for now, let's say wire is simply a connection between two points Now what you do is now we have to instantiate this small module into the top module So what you do is you instantiate small once Small so you call the module name by this original name and then you say I first which is the name of the module itself sorry and This is a name of the module you can do anything you want So it doesn't matter but what you have what is important is that you have to instantiate the module with the exact name that you gave for the module here So the first letter is going to be small The instantiation name and then you start connecting wires So what you're going to tell by this statement is that you are connecting the a port of the small module with the a port of the top module and This is exactly what it says here Okay, and it's and it's now what you're going to do here is you're going to connect the b port of the small module With the select of the top module. So whatever goes inside the braces is part of the top module here Okay And it outs sounds complicated very easy, right? So and same goes for the end and one and why as well and then we instantiate the second small module and You gave the give the name I to small I to and then for this We cut the what's going to happen is a is going to be connected with the wire and one B is going to be connected with the C input and The Y output is going to be connected with the Y output of the top module Extremely simple. That's about it. You can also make it extremely even more easier. You simply say small I first a Cell and one however When you write something like this, which is when you write this kind of instantiation without the dots and the braces We have to remember to keep the order so the order in which you are telling these wire so a Select and n1 has to be exactly the same order in which the module is written So so that a will get connected to a select will get connected to be an n1 directly to y so Both of them are correct. This is a safer choice because you don't have to remember the order That's about it both will work perfectly fine. So from here How does the system know what is the circuitry to actually detect and what this is this this process of converting a hardware description language into a digital circuitry is called synthesis and Tools that you are going to use for the labs will actually do it for you as soon as you write such a very luck Very long code and when you synthesize the code You will end up with a digital circuitry that the compiler or what we call a synthesizer Actually parses your code and determines what logic get to To realize and how it has to be connected and this is the most common way of doing digital design They do also some optimizations I will show you one such optimization in a couple of slides and this is also At the same time you can also now feed in some test inputs and simulate the behavior of your circuitry of Course you cannot assume that the generated digital circuit that the synthesizer generates is going to be the most optimal solution But in most in in general, I mean majority of times you're going to get a very optimized circuitry But if you are going to look for some very advanced Manipulations like you want to optimize for some power you want to reduce get count and things like that You have to be very careful how you write the very law, but these are advanced so you don't have to worry about it right now so Let's kind of walk through one simple example So you have an example block example module. I keep forgetting that you cannot do this so Interesting not the best way to clean a board clearly you see I'm very terrible in cleaning clearly So Let's walk through This so you have example a b c and y so these are the signals and let's say Let's try to draw it So walk me through you have inputs a B and C Let's mark it very clearly and then you have output y right and Then comes You assign y to be do you are you familiar with this representation? No, okay, so This means not It's you just invert the bit The and symbol out there Is basically an AND gate so you realize and this is a and B you know how an AND gate works right Yeah, so you have let me just zero zero you get a zero output if you have Any of them zero you get zero and if only if both of them are one you get a one So this is pretty much what we are going to do there and let's see how we are going to What is that circuitry? So you have? not a not be and then you also have a Not see and then oh This is getting complicated. Let me simplify it so Sorry exactly But I wanted to simplify it you simplified it for me. Anyway so Not the best way to do it. You also know about the Reductions, right? So let me just write it down like a prime B prime C prime and You have an R and Then you have a Can you help me B prime C prime and what's the last one I cannot see it a B prime? C right hopefully Yeah, so now How do you reduce this? You can say you can take out a plus a and then you can say B prime C prime So I basically take this and then I simply write Take out B prime C prime Fully outside and then I'm a prime plus a and you know that a prime plus a is what? One exactly so I don't need to worry about it and then I can simply have a B prime C and When you further take it I can actually reuse This parameter so what will now happen here is B prime C prime plus a B prime C prime plus a B prime C so now I can again take out a B prime and Then I left with C plus C prime and this goes away So basically what's left is B prime C prime plus a B prime any doubts here. It's okay good, so Basically, this is what we want, right? But if we had done this manually If we had done this manually you would have ended up with several and gates. Yeah, you will see it in the next So in the next slide, so it's not a so you basically end up with B prime C Prime plus a B prime Can I and you give it to the synthesizer? It automatically gives you this So you don't have to do the optimization For getting this circuitry the synthesizer does it for you automatically if you had done it manually You would have ended up with just like how I started last Right. I was totally lost, but then now the synthesizer automatically will give you this and once you get such a Circuitry you can actually pass test benches You will also do this in your lab exercises where you will be able to send test signals and actually mark and See how the inputs change when whenever the how the how the outputs change whenever the input changes You will actually be doing this So a bitwise operators So you you can do a lot of so you can represent and are XOR NAND and NAR in very long straight away just like how you would do in any other programming language You have So as I said the single ampersand represents and Are the carrot symbol represents an XR and then you can actually say an and and then you invert it for an And and same thing with the NAR It's pretty standard So I'm not going to run you through this and when you synthesize this code you're going to end up with this automatically And if you notice there are also buses here So here now the input and the outputs are all four bits So you see both a and b are for our four bit Input signals and the output signals y1 y2 y3 y4 y5 are also four bit signals and There is reduction operator for example when you have an 8-bit a and you want to do an and of every bit for example You have a of 7 and it with a of 6 and it with a of 5 so on instead of doing every bit and you're just going to Do y equal to ampersand of a and you will end up with exactly this functionality It's called reduction operators and What does it real? What does it realize? It's pretty much this you have a of 7 of 0 as a bus and then you pretty much and Everything together to get an output and you simply can say it in one sentence y equal to ampersand of a conditional assignments So it's like an if and an else statement if then else statement and you have here a multiplexer Where you have an input which is four bits d0 and Then do d0 and d1 and then you have an input also, which is the s which is typically the select and Then you have an output. So you know how a multiplexer works, right? The last four slides of last week Whoever said no It's exactly the last four slides. Okay, cool. So again, I have to lift it up cool so multiplexer This is two three inputs a b and then you have the output y right and Then you have a select So when select is zero The output y is going to be a and When select is going to be one your output y is going to be b So it's basically in simple terms a switch Where you have either a or b and depending on the value of s Whether it's zero or one the switch is going to be connected to a or b This is the digital equivalent of the if then and else statement So as you see you can assign so you write assign Inside the module. So you have a multiplexer module, which is Two in two two inputs. So you have d0 and d1 the a0 is now d0 and b is d1 here and You have s and y so you have Assign y equal to s question mark and question mark is the ternary operator because it operates on three inputs It's very similar to us to see So what how do you read this you read it as if s equal to one then d1 else d0 Got it if s equal to one then you have d1 exactly what I said s equal to one You connect d1 and if s equal to zero you connect d0 and That's about it. So you write it in one single assigned statement and this Is exactly what happens? So you have a four-bit d0 four bit d1 one bit s and a four bit y and as I drew It's pretty much the digital representation of your circuitry Of course, you can add more conditional More conditional assignments. So you can say Something like this, which is basically nested if and else. So how do you read it is if s of one? equal to One then you say if s of zero equal to one then d3 else d2 So you you can actually see how so how this is represented in normal If and else statements and you can add more So you can do exactly the same thing by actually saying not just s of s equal to one or zero But you can actually specify I will come to what does these things mean, but these are right now just Think that it's a two-bit binary number one one so if s equal to one one then y equal to d3 so and similar on and so on I Would if you're interested it's a nice assignment to kind of figure out what how this would look in a digital circuitry What do I mean by that now? I saw one bit multiplexer. You have d0 d1 one select signal and it was all fine How this would be represented in a digital circuit and how this would be represented in a digital circuit I would leave that as some kind of a homework for you guys when we meet next time I would ask and then we can discuss about it Now you can take a break and when you come back. We'll start with express expression of numbers So let's continue So before the break we saw The represent how numbers are represented in kind of this format Now what you're going to see is what does that actually mean? So you can typically express numbers in this way you have n Apostrophe B and an xx and is the number of bits. So if you have consider this example You have eight which represents eight bits and then you have the B Which here is not simply a smaller version of this B, but it also means binary So if you see here, you have binary hex if you want to represent it in hexadecimal You have hatch d4 decimal offer octal. These are the four different bases in which you can represent in very long And then you follow it up with the number itself The underscore does not mean anything it just improves readability. That's it nothing more So you can actually remove the underscore when writing So some examples quickly, I'm not going to walk through walk you through all of them I'm just going to pick two of it. So you have what this means is a four-bit binary number 101 and This means when stored it's 1001 Consider this example. What this basically means is that it's a 12-bit number H stands for hexadecimal F a Three which means that f is one one one one. That's 15 a Is one zero one zero and three is represented as zero zero one one and and how the number is stored Or what's the value of the number is exactly this so you have one on one one zero one zero zero one one And so is it octal and hexadecimal. So what we have seen so far is how Structurally how we will how how we can instantiate modules how we can represent a structural circuit we also learned how to write simple logic operations such as and Not XR and then of course the multiplexer functionality, which is basically the conditional statement and We can also describe some of some constants with the number representation, but there's more So you can actually so there's It's also depends on why so when whenever you write a Particular statement with a multiple expressions multiple operations. This is the order of precedence. So this is Slightly different from typical programming languages. So you start with the not and then the least The lowest precedence is the ternary operator. You know what is precedence? Yes, so it's basically everybody knows, right? Okay, cool So let's let's kind of so as I said very long has a lot of different ways of writing You can you can write code in different ways in very long Let's start with this example of comparing two numbers and now we will walk through this example and see How many different ways you can write code for this from the most complicated way for readability to the most Short form of writing the same functionality which literally is Not so readable or not so understandable when somebody actually looks into that code So you have an XNAR gate and XNAR gate is not of XNAR XR. So you have the So you have the same module instantiate module module definitions My XNAR to inputs AB output Z and then you write Inversion AXR B and you have an AND gate here to input AND gate AB output Z Simple a assign Z equals a Amazon B So now if you want to compare two numbers, what would you do? What is comparing two numbers say if you I want to know whether it's equal both two numbers are equal or not? Yeah Exactly why we have XNAR and then you actually manned it. So what is an XNAR gate? What is the functionality of an XNAR gate? Yeah, it outputs one when the inputs are equal exactly so if you remember XR is represented as this figure and You have an XNAR So this is an XNAR gate so an XR has the truth table as follows let's say a B output When you have zero zero zero one one zero one one you're able to see the last rows you find Okay No answer means yes to me So you have zero so whenever there are At least one one then your output is one for an X X XR gate as this these two will be zero and It's exactly the other way around for an XNAR gate. So you have one zero zero one for an XNAR What does what this basically tells you is that whenever both A and B are equal? You have a one Whenever A and B are different you have a zero so you can in some sense say XNAR determines Equality and XR Determines inequality Simple and if you want to know exactly what XR does it's y equals a prime B Plus a B prime This is the actual XR computation Okay Nothing to do with this particular example, but do you see something Interesting about the XR truth table. Do you see? So you have zero zero zero zero one one is there some other functionality that this represents Is there some arithmetic functionality that this represents? Exactly, it actually does bitwise addition So you say zero zero zero plus one one one plus zero one one plus one is one zero Which is the lowest part so you have zero and you will and so you can actually Typical when when you're doing a plus B you will pretty much be implementing an XR Got it Great so So when we compare two numbers we need to determine equality What this basically means is that we are going to XNAR A and B and Then Say if it is going if it's going to be equal then you have a one and if it's not an equal you're going to have a zero So the bigger picture here is Input a zero a one a two a three and so on what why exactly are we doing this? Because this is something to do with the AND gate Why are we doing this? What up? What does this actually mean? So? What I drew here a B and y these are single bit Numbers What if I want to give a four-bit a a four-bit B and a four-bit y and This is exactly what I'm trying to represent here with such a code So you have a split into a zero a one a two and a three so you have literally each bit of a Exiled and with and and each bit of B And then you Explicitly represent y as the equal so if it's equal you have a one if it's not equal you have a zero and then What you do here is you have to XR a one with B one You understand so you have to do bitwise X nor and similarly you will X nor a two with B two and so on and then you have B four So you have four different outputs each comparing a one B one a two B two a three B three and a four B four And each of them can be given a name C zero C one C two C three so you can somehow say these are C zero C one C two C three And now when you want to say that a is equal to B How would you say that you have to add everything so you have to say that a one B one are equal and A two B two so a two and B two are equal and a three and B three are equal and a four and B four are equal So you will have to add all of them Together to give you the equal output Right and this is pretty much what happens here. So you have X nor Modules and my and modules and My X nor modules are instantiated four times just like how we drew you connect each value a zero with B zero connected to C zero and Exactly like how we drew it here So you connect a one B one to C one and so you have four X nor gates And instead of having one and gate with the four inputs you have you can do it three times and that's it Something that's interesting here is ha ha ha boo boo What this basically means that you don't need to stick to I zero I one I two I three you can give any name here So I'm just trying to remind you here that this is important This should match the module name that you wrote and this can be any name that you want And then you have The final and so this three and representation what we So this representation of Four input all C zero C one C two C three turning into equal you can also write it as You have C zero you have C one and you have C two and C three and then you have another and here which is equal So this is exactly the same circuitry this is in in using just two input and gates and this is what is represented there Any doubts yeah, this is a bus. Oh, yeah, sure. It's not a bus yet, but wait on wait Yes, you have exhaust and and straight away, but This is more for you to kind of understand so you can use a X or B straight away, but there are no Adders for example. Yeah, so this is one way of achieving what you want another way is you don't have to write an and Module you can directly when you can simply instantiate the X now and directly use C zero one equal to C zero and C and C one what that basically means is that I have Given this as C zero one and this is C two three and that's it So I I didn't write any separate module for this one I just simply assigned C zero one to C zero ampersand C one and You don't need to instantiate and There's another way of doing it What changed here? Let's try again. Yeah, so you can also do exactly what I Told here So you can simply add everything together. Let me put it down just for comfort So you can simply add all the outputs together to make the equal or You can also use What is this? What does that represent? It's reduction operator. Exactly. We just saw it like 15 minutes ago So instead of Instead of doing C zero and C one ampersand C two ampersand C three and Individual wires like how we do it what you can do is you can actually do a bus definition here So you can make C as a four-bit bus and then what we are trying to do is exactly a reduction operator You're trying to add every bit of the bus with itself So you have equal to ampersand of C and it's a short format of course It suffix readability But it's just one way of showing It's a way of showing how many different ways you can write very long code and this is not the end of it. I Can replace the a zero a one a two a three with bus as he mentioned With three zero and three to zero so it's both of them are four-bit buses and directly you can include them in your instantiations or You can simply do this You don't have to individually XNAR bit by bit you can simply say C equals A XRB whole inverted and What very long synthesizer will automatically do is it knows that C is a bus A is a bus B is a bus or for input data It when you when it does a when it does this assigned operation It's going to automatically convert all the four bits into C. So this is it You don't have to do anything more pretty much or You can also do this Really short, but it affects readability So you can simply say if a equal to be a ternary operator if a equals B Then one else zero and the synthesizer will automatically figure out All the circuitry that we just drew it is going to figure it out for you Okay, I didn't start with here because then nobody will listen to me any questions Yeah, you can have four input and as well, but it's typically so so you can either are There are pre-defined libraries, which you can say you can also use for input and this will actually realize a for input and but ops So the the the one that I showed you This is actually going to be a for input and But it depends on what are the libraries that you're going to tell the synthesizer to use Because sometimes you can restrict it to say okay I don't have four input and and typically you will not get this circuitry because To input and it's it's how how the hardware is realized. So you simply it's much more easier to reuse two input and So you are typically restricted with this With this with this thing, but otherwise if you are not restricted and you're doing circuitry with schematics You just simply don't care, but when you implement it you say try it because there will be questions Okay, I'm trying to It's it's it's a hint There will be questions doing the exam where you will be asked to draw circuitries with a restriction of using only two input circuitries So you will have to realize logic gates But your restriction would be used only to input and or NAND gate and this will be a question because you have a constraint there Okay, what is the best way of writing very long? does not exist so It's up to you, but there are some good practices as I mentioned before easy to understand and Hierarchy is useful. What is hierarchy? Remember the first example of two small modules and the top module in that I mean two It's the small module and the top module and where we instantiated the small module twice So this is kind of a nice hierarchy which helps us understand what is happening much better Try to so one advice is try to stay close closer to the hardware exactly kind of reflects one of the questions here Where why can't we do it with simply for input ants and if there is a restriction that you cannot use for input ants? Then you really need to make sure that the system does not generate it So you always try to be closer to hardware and try to think in terms of hardware. It's very difficult Something that I did not say in right at the beginning the main difference between C and very lock are Parallel execution so when whatever the code you see Especially in the combinational circuit path. They don't execute one after the other It's hardware and hardware is typically parallel. So all of them execute at the same time. So what do I even mean by that? It doesn't mean that you know here you have C is assigned to this and then you invert C but Both these are going to be executed in parallel and The system will automatically figure out where to put because it's going to continuously be computed and It's not like in C where you pass through one sequence and then it's the next sequence next sequence especially in a combinational block It's going to be parallel execution But you will see in the next in tomorrow how you will actually how you can actually instantiate sequential circuits You can also use parameters for example, you can simply have Parameter with equals 8 which basically means that why do you need parameters? You don't have to if you decide Suddenly that your inputs are no longer going to be 8 bits, but 16 bits all you need to change is the width Equal 16 and it's going to reflect in the entire code and you can pass this parameter To a module as well Let's see how it's done So if a parameter is not given so if you're not passing any parameter and you do the standard instantiation of module module name and Input output signals then it's automatically takes the value of 8 the width and if you pass it like hash 12 then width takes the value of 12 and you are realizing a 12-bit input d0 12 bit 12 bit input d1 and so on Of course, there is a more verbose version of it. You would not be using this very often, but it's just good to know Yeah parameter is input is actually going to be realized in hardware Parameter is just for your readability convenience. It's you can treat it as some kind of a constant and What this is what this what is going to what is going to be important here is that if you're going to come back to this module and You want to say I'm going to change the 8 bit to 16 bits Then you don't have to go all the way and find every input and output signal and change a to 16 It's just for you to make it more convenient and it's not going to be it's going to be converted right at the synthesizing part And then it's going to be done. That's it But input and output are actually going to be hard wires You can also do bit manipulation. For example You can assign part of a bus so if I want So if this is a 16-bit bus the long bus and then there's an 8-butch 8 bit shot bus and then you have you can actually assign Some portions of some bits of the long bus to shot bus So you can actually pick up some bit values and then Compute and assign this to the valley shot, but you can also concatenate operators. For example, you can say why is simply Concatenation of a 2 a 1 a 0 and a 0 so you will have a 4-bit y With exactly with the value is connected as the second bit of a first bit of a The least significant bit and the least significant bit So this will be the value and you can also define multiple copies just like this instead of doing x equals 4 times the same You can also say 4 times this so it's it's like it's multiple ways of representing bits Okay, I Have a couple of slides. These are not important. I'm going to skip this because you might you might need some other Pre-requisite, okay, so what about timing? We all know that Circuaries are all going to be executed with respect to delays and timing So one way of doing it is you can give timescale one nanosecond one picosecond What this basically means is that when you use a parameter like hash five? It means the inversion operation is going to take place after five nanoseconds So it's going to take after eight is changing. It's going to take Five nanosecond for Z1 to be the actual inverted output And this is not going to be used in the synthesizer It's only for simulation to test how fast your circuit can run. It's it's and it cannot be synthesized There's no it's not going to get converted into hardware This is just to kind of so if you have some hardware restrictions which says that I need My inverter to perform within three nanoseconds then you can actually say okay assign this three nanoseconds and then you test your Circuitry and see if the output is seen after a certain time or before a certain time so that the system is stable And it's exactly the same here. So your output is going to get assigned after nine nanoseconds This brings me to almost the end of this class So we have seen a kind of a basic overview of very long described Discussed behavior and structural so behavioral how the circuit behaves with respect to if and else conditions We also see how to implement structure when you know the structure of the circuit how to implement it in how to implement it in very long What's going to happen tomorrow and the following week is you're going to learn about sequential circuits here We only saw combinational circuits and basic logic gates. There was no Memory involved. You're not so and there was no feedback or there's no Flip-flops these are things that are very essential for a circuit to operate and there were no clocks And how do you what is the clock doing in a circuitry? So all these kind of things you will you will hear from Frank tomorrow and then the following week I would come in and say how you will implement those sequential circuits in very long And then you will learn about test benches how you can test your very long code and all this is going to be useful for you in the next seven Eight seven to eight lab exercises if not the whole semester So what we thought in this week and the next week are going to last for the whole semester for the lab Exorcises so if you have any doubts Perfect time to ask questions and if you're not able to ask questions here email the assistants Email ID whatever you have and they will be glad to answer it. Thank you very much