 So, let us continue with our implementation of functions with NAND gates only and here let us take another example now and that is to implement this function a plus b plus c using only two input NAND gates. So, note that here in the previous example we had also allowed three input NAND gates, but now we are allowing only two input NAND gates and this of course is a realistic situation because some of these NAND gate arrays that you get will only have two inputs only then you need to worry about this. So, let us write down how we let us write down the basic equations that we are going to use. So, inverse we will get as a NANDed with a b the product we will get as a p bar and then bar a plus b we are going to get as a bar NANDed with b bar and then not of that all right. So, now let us look at a plus b plus c and since we are allowed only two input NAND gates let us write this as a sum of two terms and let us say a plus b plus c. So, there is one term here and one term here and now we can look at this particular identity and use that to implement this function. So, how do we do this we have a NAND gate the that is your y and at this the input to this would be a plus b bar and the input to this would be c bar this is like p plus q equal to p bar and q bar bar where p is a plus b and q is c. So, how do we now generate a plus b bar I think you at your end you saw some overwriting. So, let me just quickly write this again whatever we have done so far and here are the identities that we are going to use. So, as I was saying we will think of this as a plus b together and that odd with c and we are doing that because we have available only two input NAND gates. So, and this is looking like p plus q where p is a plus b and q is c and that we can implement with using this equation. So, let us say I generate a p bar p bar would be a plus b bar here and q bar which is c bar that will give me a plus b that will give me y. So, that is step number one all right how do I now a plus b bar there is no such thing as a plus b bar here, but there is a bar here. So, let me generate a bar or a plus b bar by using a NAND gate as a not gate. So, if I have a plus b here then I get a plus b bar how do I get a plus b I get a plus b using this identity. So, I can do a NAND gate the inputs to the NAND gate are a bar and b bar. So, I have one NAND gate here which will give me a bar another NAND gate here which will give me b bar all right. So, if I do all of this then I will get a plus b bar here what about c bar c bar is easy to generate that is c bar. So, we are we have now implemented the same function with 1 2 3 4 5 6 NAND gates. So, sometimes the number of gates will be large instead of using 1 3 input or gate we are now ending up using 6 2 input NAND gates, but if you have only NAND gates available then it the job can still be done. In fact, any logical function can be implemented with only NAND gates or with only OR gates. So, let us go ahead I will encourage you to go through the slides once again because it shows you the step by step procedure about how to do this. For example, the last operation first I mean you write it first and then sort of go backward from that and then in this way you can implement any function any given function all right. So, the same thing can actually be done with only NAND gates and let us take an example of that as well and this slide shows simply how to do these various operations the basic operations of NAND and OR. So, let us let us take this next example implement that with only NAND gates. So, this is using only OR gates all right. So, we first need to prepare a little table here of identities which will be useful to us and here how do you get a not of a function you can just say a plus a bar of that and so this is one OR gate that will be a bar what about a plus b that is simple a plus b nor is already available and then you need to take inverse of that again what about a dot b a and b that we can get from D Morgan's theorem. So, a bar plus b bar. So, let us apply use this to add to now implement this function. So, what do we see here? We see sum of three things. So, it is like p plus q plus r and so let us look at this particular because that is that is in this form. So, if you want to generate p plus q plus r we can generate p plus q plus r bar and then the bar of that again. So, this is the final nor gate and before this you will have a three input sorry this is a nor gate also nor gate then you have a three input nor gate where this is your p this is your q and this is your r. So, now let us see what p is p is actually equal to a b how do you generate a b here. So, you can generate a b by doing a bar plus b bar and then nor of that. So, there is a nor gate here that you need which takes a bar and b bar as inputs and then to generate a a itself from sorry a bar itself from a nor gate you can do this all right that is p what about q is again in this form a b in this case actually the a b c three terms. So, is b c d bar. So, we need a three input nor gate where this would be b bar now b bar we already have available. So, b bar can be connected there directly c we need c bar c bar as well that is c bar and then we need d bar bar that is just d that is that what about r r is a bar d again we look at this identity your. So, we need a bar bar which is just a we need a two input nor gate here one of them will be simply a and other one will be d bar and d bar of course, we can generate using other nor gate all right. So, this is the complete design and this is how you can you can implement a logical function with only nor gates you can try to implement this with only nor gate with nor gates with only two inputs that is that is possible it will be a little more complex. Let us go let us go by let us get back to the next slide. So, the same example that we just did with this slide will show the complete implementation now a very important topic multiplexers right now of course the students normally know when they come to this course they normally have heard of ones and zeros and gates or gates and so on, but most of them have not heard of multiplexers. So, it is very important to explain what multiplexers basic action is in great detail. So, the truth table of a multiplexer is shown here we have four inputs and of which one is selected that is the basic operation of a multiplexer and how is that selection then that is done by some select lines or control lines. So, it is if S 1 S 0 is 0 0 then the output is the first one I 0 if S 1 S 0 is 0 1 then the output is the second line I 1 and so on. So, a multiplexer is also called a data selector and in short it is called MUX it is basically selects one of two raise to n input lines and it makes the output z equal to one of these input lines. In other words a MUX is actually is like a router which routes one of these things to the output and there is a very nice representation you can show students to show this effect. So, in other words a MUX is like a box with some switches and only one of these switches will be closed depending on what S 1 S 0 is if for example, if S 1 and S 0 is both 0 and 0 then the first switch will be closed and this line will then get connected to the output. If S 1 S 0 is 1 1 then the last line will the last switch will get closed and this line will get connected to the output and so on. So, it is it is nice it is good to imagine that there are some kind of kind of switches only one of which will close depending on what S 1 and S 0 are. So, conceptually a MUX may be thought of as two raise to n switches for a given combination of the select inputs only one of the switches will close and the others will remain open. In reality of course, the implementation of a MUX is basically given by this and there is there are no there are no switches as such, but there are no switches and it is it is easy to show that the implementation of the MUX is actually given by this equation. Multiplexers are available as ICs and in fact, you might be already having some experiments which use multiplexers 7 4 1 5 1 is an 8 2 1 multiplexer and IC with arrays of multiplexer or other digital blocks are also available and these blocks can be configured or wired by the user in a programmable manner to realize the functionality of input and of course, I can be very large number of gates like thousands or tens of thousands of gates. Now, at this point or at some point we need to mention what is meant by an active high input or an active low input because students are not heard of these terms and it is good to inform them about it. So, normally when I write a table like this 1 is 0 and S 2 is 0 is 0 then the input is the output is I 0 that what it means is that S 1 and S 0 are considered active high inputs, but the same thing same some multiplexers are actually available with active low inputs and that means, what we what we are given is S 1 bar and S 0 bar. So, if S 1 S 1 S 0 equal to 0 0 corresponds to actually S 1 bar S 0 bar equal to 1 1 and so on. So, this input is active if it is low and of course, most all of you would be aware of this this nomenclation. Also, there is an enable pin in many ICs and the job of the enable pin is to enable that particular operation. So, if the pin is not active then the IC is not enabled and it does it gives you some default output if it is active then it does the normal job and some of these ICs will actually come with active low enable pin. So, it is important to point out alright. So, here is a very nice example I am not sure you can I do not think you can see this. So, what I will do is I will take another example with a smaller number of pins which we can actually try to do it do on paper. So, let us say we have a we have two multiplexers and this is something that you can actually show your students in class because that also brushes up their combinatorial circuits skills. So, the problem is like this we have two maxes let us say let us just take for simplicity 4 to 1 max we have two 4 to 1 multiplexers so, let us say one of them is here that got 4 input lines I will call these lines I 0, I 1, I 2, I 3 then there are the there are 2 select lines let us call this S 0 and S 1 and there is an enable pin. Let us say the enable is an active low pin. So, what the problem is that we are given is to use two of these multiplexers to make an 8 to 1 multiplexer. So, two of these to make an 8 to 1 multiplexer and the input lines of this 8 to 1 multiplexer are basically these lines. So, here there is another multiplexer it has shown I 0, I 1, I 2 and I 3 and it has got its own enable pin and it has got its own S 1, S 0. So, now then this has got an output Z 1, Z and this has got an output let us call this Z 1 and Z 2 and this is supposed to the overall box this is our 8 to 1 max the max that we are going to make with these two maxes the overall output is Z and these lines are supposed to serve as I 0, I 1, I 2, I 3. So, what we can do is of course, we can connect these just all these. So, either this Z 1 if this Z 1 is 1 or Z 2 is 1 your output is 1. Now the question is what do we do with these inputs E bar and S 1 and S 0 of both of these multiplexers so that we attain the desired functionality. So, what do we want we want the following. So, we have we want three lines to come out of this and let us call these S 0, S 1, S 2 of the overall 8 to 1 multiplexer. Now the question is how do we connect this to all these pins so that the desired functionality is obtained. So, the idea is this. So, this is the lower four lines and these are the higher four lines. So, this max should be selected. So, let me call this max 1, let me call this max 2. So, max 1 should be selected if this S 2 here is 0 and max 2 should be selected if S 2 is 1 because that the input lines of that we are connected to we are treating as a higher higher lines. So, how do you do that and that is simple and S 1 and S 0 actually can be the same. So, S 1 and S 0 can be simply connected like this. So, what we want to do is if S 2 is 0 then we would like to select this one. That means we want to enable the first multiplexer. So, this and since it is an active low we can actually directly connect this. Whereas, we want to select the second multiplexer if S 2 is 1. So, therefore and since this is active low we can actually connect this through an inverter. So, if you do this if you have 4 to 1 multiplexers and if you make all these connections then you can this overall box you can treat this as a single 8 to 1 multiplexer with I 0 I 7 as the input lines S 0 I 7 S 2 as the control lines and Z as the output. And what is shown in the slides it is basically the same thing, but it has got 8 to 1 multiplexers and it gives you 16 to 1 multiplexer. So, let us go ahead with the slides. So, this is this is ok to project in the class, but I guess you cannot see this right now. So, we will not consider this example it is very similar to what we have done. And using the same philosophy actually we can connect from 4 to 1 multiplexer if we are given 4 of them we can certainly make 16 to 1 multiplexer. Using multiplexers to implement logical function now this is very important that we often not covered I think in this levels, but let us actually pretty simple as well. So, let us do this example. So, the question is to implement this function of 4 variables A D bar C bar D plus A bar B C bar D bar C bar D bar using a 16 to 1 multiplexer. Now if it is a 16 to 1 multiplexer it is fairly simple. So, how do we go about this? Let us say this is our max 16 lines and this is the output. So, this is line number I 0 this is 1 2 and so on. So, I 0 to I 15 these are the now we are supposed and of course there are these select lines. So, how do you go about this? So, we need to find out when is this x 1? Now the solution will actually depend on what do you do with these select lines. So, let us say I decide to connect A B C D like this. It is also possible that you connect it like D C B A in that case what you connect here will of course change. So, let us say if I let us say I connect it like this. So, what should happen if A B C D is 0 0 0 0 if A B C D is let us just construct this table. So, actually this problem is extremely simple. So, we just need to figure out for what conditions x is going to be 1. So, we know that x is 1 if A is 1 0 A is 1 B is 0 B is 0 1. So, that is 1 0 0 1. So, that is this term here. So, x is 0 for this particular min term and x is 0 for 0 1 0 0 that is here. In all other cases it is 0. So, let us not even bother to fill it up. So, what all that we need to do now is figure out where to connect the 1. So, 0 1 0 0 that is line number 0 1 0 0 that is line number 4 I 4 and this is line number 9 I 9. So, all we need to do now is to is connect a 1 here and to I 9 we connect a 1 and all other pins we need to connect 0. So, let us not show that, but that is understood. So, this will do the job. So, if A B C D is any one of these combinations then a 1 will be connected to the output otherwise a 0 will be connected to the output. So, it is essentially it is implementing this truth table here on to the multiplier that is simple as that. It is very trivial, but it is good to start at this point and then go on to more complicated implementations. So, let us do that. So, this slide shows exactly this and of course, you would not be able to see the font size, but you can take a look at it later. So, now we take up little more challenging problem and that is to implement the same function. So, let us say I have not a 16 to 1 mark, 16 to 1 mark, but an 8 to 1 mark available to me. So, the same function can also be implemented with cheaper hardware like 8 to 1 multiplexer. So, we are given an 8 to 1 mark now with 3 control lines I 0, I 1, 2 and so on and the output here. Let us call this as 0, S 1. Again the solution to this problem will depend on what you connect to this select lines. Let us say I decide to connect A, B, C here as such and let me construct this table which we have done earlier. So, that is our table and X would be again X is 1 in this particular row 0 sorry 1 0 0 1 that is here and it is 1 here 0 1 0 0 that is here. So, this all other places it is 0 and now this it is convenient to write it like this if we are going to connect A, B, C to S 2, S 1, S 0. Now, suppose your A, B, A is 0, B is 0 and C is 0, then we are looking at this particular part of this table. In that case what is X? X is 0 irrespective of what D is. So, therefore the line number 1 which gets selected for A, B, C equal to 0 0 should be connected to 0. So, now next if A, B, C is 0 0 1 we are in this part of the table again X is 0 etcetera. So, we just need to go 2 rows at a time. Now in this case notice that X is 1 if D is 0 and X is 0 if T is 1. So, X is actually this should then be connected to D bar. The next one is always 0, next one is the same if D is 0, X is 0 if D is 1, X is 1. So, this should be connected to D and these others are all 0. So, this is 0 here, 0 here, 0 here. So, we will just connect 0 here. So, that is the solution and now the question suppose we have suppose you do it differently. Suppose instead of connecting A, connecting A, B, C here suppose I connected let us say B, C, D here then what happens? Then of course this will be function of this will consist of 0's and 1's and A in that case A or A bar. So, that is how these things are done. So, let us fairly straight forward example a simple extension of the last one and that is what is shown over here. So, there is a homework here for the students implement the same function with S 2 equal to B, S 1 equal to C and S 0 equal to B and that is what I was just mentioned. Here is another example. So, then we talk about D multiplexers and again these things are a little too small for you to see. So, but feel free to use this slide and if you project it in the class it should look ok. So, D multiplexer is just the opposite of a multiplexer. So, it takes a single input and it routes it to one of these output depending on what S 2, S 1, S 0 are ok. Here is it is a little too small for you to see, but here is an actual implementation of a D multiplexer 1 to 8 D multiplexer. These are all combinatorial circuits which are fairly simple to understand. Decoder we have I have noticed that people have students have problems with decoders and D multiplexers they sometimes get confused. So, it is important to point out the difference. So, a D multiplexer always has one input and 2 raise to n outputs where n is the number of select lines whereas, the decoder can have n inputs can have m outputs and so in that sense alone it is different. So, for each input combination only one input line is active which means 0 or 1 depending on whether the outputs are active low or active high. So, it is always good to give an example. So, here is a 3 to 8 decoder or 1 out of 8 decoder. There are also decoders available for more useful functionality like the CD to decoder decimals decoder and in this case notice that only the first 10 lines that is from 0 0 0 0 to 1 0 0 1 are really active and the others are sort of do not care conditions that means, we will not have these other combinations appearing at the input they are do not care. Here is this is this figure actually is very useful, but I think the resolution is going to be not enough for you to view it. So, I suggest that you can view it later. So, this is a BCD to 7 segment decoder and it is a circuit that students will use in the labs at some point. So, therefore, you can explain to them that what they have learnt is actually directly applicable to their lab work or project work. So, this is a BCD to 7 segment decoder given a given BCD line it will light up one of these one or more of this segment depending on what number you want to see. So, maybe we will just take what I am suggesting as homework here we can do that in class I mean right now. So, let me take that up. So, it says write the two table for C the segment C in terms of BCB and A. So, let me reproduce this figure here there is a ground and there is a VCC and so on and then there is BCB and A fine. And then the actually it is also interesting to see what this actually does what this chip actually does and what connections we need. So, let us just reproduce this fully here there are 7 segments that we want to light up. So, there are 1, 2, 3, 4, 5, 6, 7 outputs this is one of the segments an excellent example of a decoder. In fact, if you show this in class they will really appreciate the use of decoders. These segments I got names A, B, D and this segments actually are nothing but diodes. So, there is a diode here there is a diode here and so on do not worry about the directions right now all right. And all these things are connected this pin is active low let us say this is the output for A this is the output for B and so on. So, the way this works is suppose you want to light up this segment then this A goes low and all of these things are connected to the supply the positive of the diode and the negative of the diode is connected to this point here. So, if this pin goes low then the current there is a current which goes like this and then that makes the LED light and of course, the resistor value is calculated. So, as to limit the current to a suitable value. So, typical numbers we are like this is equal to 5 volts and the diode voltage itself the turn on voltage of the diode is like 2 volts these are not silicon diodes these are compound semiconductor. So, they have higher and they have higher turn on voltage and normally the current that you would like to flow through this LED when it is lit is something like 10 milliamps. So, that is right. So, if you put all the of this together then you get a resistance value which is 5 volts minus 2 volts 5 volts minus the drop across the diode divided by 10 milliamp that comes to 300 volts. So, you can choose this 3 resistors the same in all of these. So, now the question is now the problem is like this what should be the logic for segment like this what should be the logic for segment for output C which is actually C bar because it is active low and that is very simple. So, let us take A B C D here since D is our MSB and A is the LSB we can construct a small 2 table here B C D and A. So, let us do this on the next page because this page is getting a bit crowded or let us complete the table here and then go to the next page and there are 4 variables. So, we will have 16 entries here. So, now when do we want this segment to light up. So, let us write that so this decimal number that corresponds to this combination is 0 1 2 3 4 and so on and after that of course, we do not care for those inputs. So, now all we need to do is when do you want this C segment to light up. So, that means for that particular combination this input this output should be low. So, just think of this is 0 then C should light up. So, C should then it should be active if it is 1 it should light up if the decimal number is 1 it should light up. So, that means it should be active if it is 2 it does not light up if it is 3 it does light up if it is 4 it does light up 5 it does light up 6 it does and so on 8 of course, everything lights up 9 it does light up and these conditions actually are do not care because these input combinations are not going to happen. So, therefore, these combinations are do not care and now if we since we know this to table we can actually go ahead and construct a little corner map here or let me do that here. So, this is a good example to actually put many things together. So, you can see that the even the corner map has appeared which is a good use of this of what they have studied in the previous process. So, we just need to transfer these entries now into this table. So, let us just look at the ones there is a one here which is at 0 0 1 0. So, 0 0 1 0. So, there is a 1 here then there is that is it then there is no other one and then there are these x's and these x's can also be used. So, the x's are 1 0 1 0 1 0 1 1. So, there is an x here there is an x here there is 1 1 0 0 and 1 1 0 1 1 1 0 0 and 1 and in fact, this entire column. So, you just all we need to do now is to minimize this function and that can be done by combining it with this x and that is it. So, that will that will give you the expression for what this C bar should be this this output should be. So, this is a good problem to illustrate many different things including decoders. Let us let us go ahead encoders. So, encoders are just opposite of decoders alright and all of these things actually you are quite familiar with. So, there are m input lines and n output lines and the n output lines can represent 2 raise to n binary number each corresponding to 1 of the m input line. That is we can have m equal to 2 raise to n and some encoders will have m which is less than 2 raise to n. So, some of these lines will not be okay. So, here is an encoder example now again the font may be a little too small for you, but this state. So, there are 8 inputs a 0 a 1 up to a 7 a 0 a 1 up to a 7 here and there are 3 outputs o 0 o 1 and o 2 and that is given over here. So, for a given combination let us say a 0 equal to 1 and all others 0 output is 0 0 0 if a 1 is 1 all others are 0 then the output is 0 0 1 and so on. So, this is the just opposite of decoders and it is good to also show at this point an actual encoder such as 7 4 1 4 7 and that is a decimal to BCD priority encoder. So, maybe I will just reproduce this table here on the slide so that we can view it in more detail. And all of these things you notice that we spend more time writing than actually explaining the operation of the circuit etcetera. So, it is better if you have slides available to you it is sometimes better to just show these in class because the concepts involved are many of these cases are not really very difficult. So, this particular encoder looks like this and this also illustrates certain things like active low input and so on. So, this is called a decimal to BCD priority encoder and it also brings about this concept of priority. So, it is a good example to give. So, these are active low inputs the first one corresponds to it is called a 1 a 2 actually it is called a 1 bar because it is active low a 5 then 6 7 8 9. And then there are 4 active low outputs which we will call as o 0 bar o 1 bar o 2 bar. So, the way this works is these are the inputs that there is the output. So, and it is decimal to BCD. So, let us make 9 of these. So, this is like a 9 a 1 bar a 2 bar a 3 bar and these are the outputs. So, the output should always be arranged from MSB to LSB. So, that the numbers can be read easily. So, it is o 3 bar o 2 bar o 1 bar and o 0 bar. So, when all of these are inactive that is when all of these are high the output is all of these output lines are also inactive. So, that is that corresponds to the decimal number 0 0 0 0. If this is active the line number 9 is active then it does not matter what these are. So, that is why this do not care condition and the output that you get is 0 1 1 0. So, remember that this is actually active low. So, therefore, the decimal number the binary number that corresponds to this is 1 0 0 1 and that is the decimal line number. So, if this line is high this line is active that is 0 it does not matter what all of these are and that is represented by these excess and that is why this encoder has got a priority. It gives priority to this 9th line a higher priority than all other lines. Now, if this line is not active if it is 1 and if this is less line is active then it does not matter what these are and so on. So, then the output the decimal output that corresponds to this case will be the number 8. The number 8 is 0 1 0 0 but we since our outputs are active low this will the output of the chip will be 1 0 1 1. So, this example illustrates many things including the use of active low and active high pins etcetera. So, the next would be both of these are inactive and if this line is active then it does not matter what all of these are and then this decimal number would be 7 and so on. So, let us get back I think we are we probably do not have too many more slides on this topic.