D latch

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so in the last video we took a look at the SR latch which is this latch that has two inputs a set input and a reset input and if we input a one on the set input it sets the latch and the Q output goes high and then if we input a one on the reset it resets the latch and the Q output goes low so this video I want to look at trying to build a latch that has a single input so instead of having one input to reset it and another input to set it having a single input that when it's zero it resets it and when that input is a 1 it sets it so you might think well that's easy we can just put an inverter here and so if our input is a 1 then it sets it and of course our inputs inverted to the reset to zero and if our inputs are zero then it's not setting it but if we invert that zero we get a 1 up here and it resets it so let's try and build this and see what happens so here is this circuit and basically it's the same as before so we've got the two nor gates here connected just like this and then the set input is connected here to this button to our single input and then the button is also connected through an inverter to the reset and so this is the reset up here and it goes through an inverter and to invert I'm using this nor gate to this this chip has four nor gates on it and so rather than having another chip that has an inverter on it you can actually use a nor gate as an inverter because if you look at the truth table for the nor gate you can see if both inputs are 0 then it outputs a 1 if both inputs are 1 it outputs a zero so if you tie both of the inputs together you can turn a nor gate into an inverter so this is just kind of a little shortcut since I've already got the nor gates on this chip and I'm not using all four of them so this switch is going into both inputs the little jumper here connects both inputs and then the output of this nor gate that's now an inverter is going into the reset so let's see what happens okay well the input is off and the the latch is reset so the Q is zero the naught Q is is 1 and if we turn the input on the Accu goes high so it sets it and the not queue is low the problem is it's not actually latching anything anymore it's not it's not serving as a memory or storing anything it's just whatever the input is then q is the same thing and not q is the opposite of the input this is not super useful so what we need to do is find a way to tell the latch part of this when it should latch the input and when it should just ignore the input and so a way to do that is to have an enable option essentially or an enable input and this is an example here of adding an enable to the SR latch so this is our SR latch that we're that we're familiar with and instead of just having the reset and the set inputs directly going to the latch we have them going through these and gates and so in order for this and gate to output something both inputs have to be on so this has to be this and this have to be on in order to get an output here and so by using these and gates this gives us an enable input and so as long as the enable input is off or 0 both of these outputs these and gates are going to be 0 regardless of what the reset or set is so this basically gives us a way to kind of turn on the latch and turn it off so let's build this and just to kind of get a better intuition of what's going on so this is that SR latch with enable and so what's going on here it's a bit more complex but down here is our nor gates just like we've been seeing before and the the outputs are connected to the inputs that's what these yellow wires are is these cross wires here and then the inputs the reset and the set are these blue wires and instead of going directly to switches they're now going to and gates and this is a 7408 quad and gate chip and we're using two of the an gates on this chip and so one of the and gates outputs is going to reset the other is going to set the inputs are going are coming from either the reset button which is this across this green wire or set button which is which is this button across the set of green wire and then the enable is this button up here is connected to both or an input of both and gates so this is this is basically a SR latch with enable so it's just like the SR latch but we now have this enable thing so let's take a look at how this works so we power it up looks like it started up in the in the set state because Q is is high but just like the regular SR latch it's just going to kind of randomly pick one state and if we try to reset it or set it you can see that pushing these has no effect and that's because it's not enabled what we have to do is enable it by pushing the enable option here and now that it's enabled the set and the reset will work just like before we can set it and reset it and so if we reset it and then let go of the enable now the set and reset don't do anything we turn on the enable we can set it and then if we turn off the enable it stays set and now the set reset don't do anything so we have this SR latch that we can set and reset only when the enable is on and so now that we have this enable option let's see let's try and put that inverter back in and see what we can do so here's here's the same thing we've got this set and reset here going through zan gates we have our enable and now we're hooking this inverter up and so we have a single input coming in here and we can either set it by setting as high which will set the latch or we can reset it by setting it low which will then set the reset high in the and the set low but it will only change when we've enabled it so if we look at that circuit we've got our nor gates just as before we've got them hooked up with the two inputs and so this is the reset and the set inputs over here are these blue or the blue wires and then they go into the or they come from I should say that and gates and we're using two and gates here as well and then the inputs for the N gate one of them is the enable and that's the stop button here and so you can see these two yellow wires are going to an input on each of the two end gates and then the input which I've labeled as d4 for data I guess the input is this the second switch here which you can see there's a green wire that's going into the input of the sort of the bottom and gate which is the set and there's another green wire that goes back over here and again we're using one of the newer gates as an inverter and so it's going into two inputs of that nor gate and then the output of that nor gate so the inverted the inverted signal from that nor gate is then coming back into the top and gate so if we power it up and take a look it powers up and it looks like it's set at the moment I've also added an LED here so the input you can you can see whether I'm pushing the button here and so you can see the input is changing this this input is changing and now the outputs not changing and that's because the latch is not enabled if we enable it by pushing the top button you can see now that when the input changes the output changes to follow it but if I if I turn off the enable it latches in the in this case reset state and then if I turn on enable then I set it and then I turn off enable it now latches enabled and so this is usually called a D latch because it will latch a single bit of data because we're you know we can use this as part of a to build a memory or register something in a computer to store one bit of data and if you see there's that there's a block symbol for it as well which has this block and it has the the D input the enable input and then the Q output as well as the the not Q output which is just always going to be the opposite of Q and in fact normally if we were using this to store a bit of data we we would probably just ignore this q and so in fact we can do that and we just pull the LED out and that will we can basically ignore it and so you can see what's stored in this D latch right now is a one and so then if I enable it and then I change that to something else maybe I change it to a zero now what's stored in the D latch is a zero and again I can enable it and it follows whatever the input is and then if the input is a 1 and then we turn off the enable the latch stores a 1 and so you can see this is a great way to store one bit of data as we as we might in a computer register or even memory or something
Info
Channel: Ben Eater
Views: 421,787
Rating: 4.9729824 out of 5
Keywords:
Id: peCh_859q7Q
Channel Id: undefined
Length: 9min 16sec (556 seconds)
Published: Wed Feb 24 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.