BUILDING AN 8-BIT COMPUTER FROM SCRATCH #4 (Full Stream)
Skills:
Systems Design Basics80%
Key Takeaways
Builds an 8-bit computer from scratch
Full Transcript
[Music] hello hello hello everyone good evening wherever you are uh yeah there's so much construction noise outside I'm sure you can hear it and I'm really sorry about that I hope it stops soon it's already 700 p.m. uh so they should hopefully stop soon so today um um no wait uh few things in order first of all uh yesterday I had here a tripod that was holding the overhead camera however today my uh rigging setup um arrived so now I have this arm that is coming from here from a shelf going out over here uh so I have a new overhead camera setup so let me quickly uh switch to the overhead camera for you to see uh the new setup so in that way it looks kind of like yesterday we have again the work space where we can work and we have up here the oscilloscope that we can look at uh so I think it's uh pretty neat this way uh I think it looks uh better uh what else I guess that's that's about it that changed um so in today's uh stream we will continue with Ben eater uh series and the thing is the next few videos are him explaining uh certain types of flip flops he if I look here in the playlist there's he will talk about the SR ledge the D ledge and the D flipflop so I assume these are mostly just educational videos uh not necessarily where we where we will continue the build so that means that um we will probably just lay back for a little bit and I will be a reaction streamer we will just watch these videos together and um I try to learn from them for completeness sake I definitely want to watch them and I will also probably learn stuff from it uh so my background knowledge about this is actually from school I went to a technical stool school before I went to University and uh at that school we did learn the basics of electronics so we learned like how to simplify uh you know Gates uh truth tables and stuff like this and we also learned about the different kinds of flipflops and Lees and stuff like that so that is now probably also uh 89 years ago for me actually at this point feels so old but uh so this will be also a great refresher for me and I'm and I definitely couldn't explain them myself anymore right now so um I'm really looking forward for Ben eer explaining them especially because Ben eer is so much more detailed and has really great uh Insight um that he always provides in this video so I'm really looking looking forward to watching this but this also means we will be watching these videos and I will be quiet for most of the time and in the meantime I will then eat because I haven't eaten yet but I thought uh if I have to watch these videos anyway I can I can uh watch while we no wait I can eat while we watch so how's everybody doing um uh I see um some people saying hi in chat hey nice for you to be here um um if there are any questions about the stream yesterday or anything um then let's deal with that before we then head into the videos uh hey I'm a Noob who has been learning from Udi my friend who has been doing this for years suggests me to Learn Python first but when I try to exploit exercises I see it's C language based what should I learn first python or C uh so first of all what did you watch on You Demi that you still not haven't learned that stuff uh that's just my small criticism of UD Demi I don't I don't think I'm sure they are Great Courses but I think the most of them are garbage so please don't spend money on them I think my videos provide more value than uh most udmi courses and my videos are free so I it it always kind of annoys me and makes me mad that people would spend $10 on udmi courses because they cost money there must be more value but then they are [ __ ] uh while you can get my videos for free or even just you know uh uh support a little bit on patreon with like a dollar per video or something like that uh just my small rent I'm sorry but um well depends on what you want to do with uh exploiting you know exploiting is a broad term typically or usually how I refer to it especially in in context of my channel uh I talk about you know like the the series I have on binary exploitation is mostly about small C programs but in reality you know exploiting could mean anything it could be web application exploitation um or it could be compiled programs but then it also depends on with what language this program was compiled uh exploit exploiting uh programs written in C++ uh else somewhat different than just raw in C but I think C is the simplest way to learn about uh this kind of low-level exploitation C++ just kind of adds on top of that with uh different kind of language features that you can abuse uh during your path of exploitation and a few different kind of Primitives that exist uh in in in these other kinds of languages so I think um that's the way you think now also I don't think what should you learn first python or C you know why do you even make this distinction just learn whatever what what comes up when you see a problem that you need to solve then you learn the tool that helps you to solve this so if you want to write a script that does something then then is the moment You Learn Python and if you want to uh do learn a bit about like exploitation this kind of you know these basics of exploitation with C then you learn C and now you maybe need to write an exploit script to exploit what you want to you know what what you have written in C then is the point when you learn python uh so don't think that you need to these blocks now I need to Learn Python and now I need to learn C and which one do I do first it's all intertwined it's all interconnected uh you jump between those topics all the time uh so um I I think that's the better way to approach this and uh my recommendation would be uh of course I'm a bit biased or you know I also don't have a lot of I can't compare much but I think you can just start with my binary exploitation series and uh the it is on for it used to be exploit exercises.com.au uh that's the website that my videos are about so you can follow along you can install this you can try them yourself uh when you get stuck you can watch my videos and try to do it yourself also don't get stuck on the videos even if you feel kind of stuck keep watching a few videos because this is the problem a lot of these uh knowledge information things have kind of circle references so sometimes certain early videos become clearer once you watch later video so just feel free to explore don't be scared uh play around with it um along the way you will maybe write some a little bit of python or a little bit of C that's so that's my little rant there uh uh I watched all his playlist I wonder do you want to improve his computer after finishing adding more RAM yeah and assembl operations that also my plan I haven't watched the series yet but I did hear that it has only 16 bytes and limited instructions so that's exactly something that I once I feel you know I'm I'm also learning here so once I feel more comfortable and understand it better then that's definitely like a challenge or a thing to work on to in increase the memory and um also add more instructions for sure uh actually Basics and see you can learn fast at least you understand the basics yeah for sure C is in some way a very simple language there are not many uh many things yes I've been doing the education sites nibula it's very interesting yeah perfect you on a good path don't worry about it keep doing that's great that's exactly what you should be doing um all right um and please don't waste any more money on you Demi courses please please please do this what you are doing uh play kind of sites like exploit education like nebula challenges or whatever uh go that path check out picco CTF check out all the other CTF websites don't worry too much about which CTF you just need to get started and play them and get stuck and get frustrated that goes way more than any course all right okay cool so uh yeah let me switch here the screen to the laptop so that is working awesome let me put myself somewhere up here I guess oh my gosh they do Street construction work outside so the whole apartment building is shaking I'm like on a upper floor and I still feel the floor shaking okay everybody ready watch some YouTube videos while I eat all right uh also if if the audio and stuff oh and by the way I should have also fixed the alerts yesterday that didn't make any sounds I hope not today that makes sense all right let's uh watch the next uh video the SR ledge video so in previous videos we've looked at the orgate which if you remember in this case we have two inputs if one input or the other or or both are on then the output is on otherwise the output is off in this video I want to start thinking about scenarios where where we have a gate where the output is connected back to the input or or some series of gates where the output is connected back to the input and so you might think well maybe we can just come up with a truth table like this where the input can be either a zero or a one if it's a zero then the output ought to be something and if the one and the output might be something different but what we'll see is is that it's not not quite as simple as that uh so to build a little bit of intuition for what's going on here uh I think it's easiest to kind of build a circuit and and kind of see what happens so this is that circuit it's got a uh this chip is a is a 74 ls32 chip which has four or Gates on it uh and this is the pin out for it and you can see with the four orates you've got a B and Y are the input a input B and Y is the output so the first three pins and this chip is is upside down so it's these first three pins here and what we've got just like the diagram here is input uh a is connected to the switch input B is connected via this little blue wire to the output and then we also have an LED connected to the output and you might be wondering if we need a a resistor for this led but if if we look at again at the data sheet for the 74 ls32 there's already on the output there's already a resistor here connected through this transistor and so when this is switched on the gates on uh we already have this 120 ohm resistor built into the into the chip here in this in this case it's going to limit current so we should be okay with that led the input is connected to this switch which uh it's actually connected across this resistor to ground and then when we push the button the button will will connect us to this 5vt Source here so if we're not pushing the button it's inputting a zero if we push the button it's inputting a one and this is a momentary switch so let's uh hook the power up and see what happens so we hook the power up and you can see the output is off and so that kind of makes sense maybe the the inputs start as zeros and so zero and zero uh should give us give us a zero output and of course if that's a zero then that's going to feed another zero back into this B uh so it just stays everything's a zero so that makes sense so now let's see what happens if we change the input to a one by pushing the button so if we push the button the input's a one so a one and a zero we get a one as the output and we see the output comes on uh but actually this output is now coming back into this input so B is is is a one as well now so actually we've got we're pushing the button so we got a one coming in a we've got a one in B and so the output is still one but now if I let go of the button so a is now zero B is still one and so the output is still one and so this this stays on even though I've now let go of the button and in fact if I keep pushing the button uh there's really nothing I can do to to get this to turn off once this input turns on even if it turns off later the output stays on it it latches on essentially and so really the only way to reset this is to disconnect power from the entire circuit and then uh you know we can reconnect it and then of course it starts out at zero again but if it any point after this thing is powered up that input ever goes to a one even if it's just momentary if I just hit it really quickly that output latches on and remembers that that input was at 1.01 so this is pretty interesting and you can imagine why we can't just come up with a simple truth table like this uh like we might like to but what would be even more interesting is if we had some way to turn it off again uh some other way to reset this other than having to disconnect power from the entire circuit because that might not be uh you know too practical so what I want to do is look at another circuit that actually does work that way and this is this is that other circuit and this might look a little confusing at first U you know but we'll we'll walk through it uh one thing you'll notice is different we're using nor Gates instead of or Gates so it's the same as Norgate but the output is inverted we'll talk a little bit more in a minute about that uh and again I think you know a good way to build some intuition for for this is to actually build the circuit and so I've done that here uh this this chip now is a quad Norgate it's a 74 4 ls02 chip which has four nor Gates and of course we're just using two of them and to kind of walk through what's going on in here uh the bottom pin here is this bottom input and then the next pin up is this input here and you can see the yellow wire is connecting it to the output of the top Norgate the third pin is the output of the bottom Norgate here uh and you can see that's connected to an LED so we can see what the output is and you also see this little yellow wire is connecting it to the input of the top Norgate the other input at the top Norgate is connected through this blue wire to the to the switch here so we can set the input there uh and then finally the output of the top Norgate as we saw we've got it hooked to an LED here and it's also going back down to an input on the bottom Norgate and again these switches are hooked up so that they're normally a zero and when we're pushing them they're a one so let's uh you know before we think too too much about this let's let's just sort of power this up and see what happens I always like to kind of build the thing and see what happens so we it in and the top LED comes on so this Norgate on the top is is switched on so this is basically what is happening here so I've kind of drawn uh exactly what states different things are in to kind of make this a little bit easier to understand um and also as a reminder I've got the truth table for a Norgate so again if either input one input or the other or both are on then it's off otherwise it's on so it's sort of the opposite output of an orgate so in this case the top or gate is on and so we see the LED there and that implies that this input down here must also be on and so if we just kind of Reason through this hopefully it'll make sense so the bottom Norgate we've got a one and a zero and of course this one for some reason this top LED came on we'll talk about why a little bit later but uh for now we'll just sort of take it on faith that it's on because we can see that it's on uh and the bottom uh is is zero because we're not we're not pushing this button so that's a zero so a one and a zero means that the output put is a zero and that makes sense that we see the bottom LED is off and so then that's being fed back into the top Norgate and of course we know we're not pushing the top switch either so it's a zero and a zero going in here which means that the top Norgate should be on and that's what we see so this hopefully makes some sense so now what happens if we start changing these inputs so the bottom input uh is fairly straightforward if we turn the bottom input on then this gate will be uh the inputs will be one and one and we can see the output then is still zero so this doesn't change which means this top nothing else changes so if we change this bottom we if we input a one if we push this button um nothing should happen and in fact nothing happens we can push this button as much as we want nothing's changing because we're just going from one zero to one one you can see one Z one one the output stays the same here doesn't change this nothing changes now the top one is a little bit more interesting so if we push the top button we're basically changing this here to a one so this I've just redrawn the circuit here here um and I'm changing just this top input to a one well if we do that the top gate now has inputs of one and zero and so one and zero it ought to change it ought to turn off and output a zero here well if it does that that puts us here so one and zero and zero so that makes sense but now that changes the input of the bottom gate and so now the bottom gate is getting a zero and a zero coming in well if a zero and a zero are coming in the bottom gate ought to be outputting a one so then it's going to switch on and when it switches on that changes the input on the top gate again so now the top gate is getting a one and a one well in that case a one and a one is still a zero so the top gate doesn't switch it's already off and so now the circuit is is stabilized in this configuration but what you see happens is before we had the top LED on or the top gate on and at the end of this whole sequence of events the bottom gate is on the top gate is off so let's give it a try I push the uh button here on top indeed we see the top goes off the bottom comes on so we're now in this state and really it it did actually flip through all three of these states it just happened very quickly I mean on the order of of nanc really uh to get to this state here well now if we release the top button and this goes to a zero that puts us in this state here and a zero and a one input on the top gate is still going to Output a zero so zero and a one is still a zero and so nothing changes and so now with both inputs off we've swapped which of the gates is on so this is essentially a mirror image of where we started so we started with the top gate on the bottom gate off now we have the bottom gate or excuse me the top gate off and the bottom gate on and since this is the mirror image of this you know now pushing the top button doesn't have any effect whereas before remember when we're pushing the bottom button it didn't have any effect but pushing the bottom button is basically going to run through this same sequence of events but sort of in in Mirror Image and flip from the bottom to the top and now the bottom doesn't have an effect and so you can see by pushing these buttons we can kind of flip it between one state and the other and then once it's in that state it stays in that state until we until we push the button again or until we push the other button I should say and so this is a fairly common circuit and and it has a name it's called uh it's called an Sr latch and Sr stands for set reset uh because the the can essentially be set or reset and so these inputs are are labeled you know typically labeled r s and then the outputs are labeled q and inverse Q or not q and the the way to sort of think about this is that if you want to set the Q output then you input a one on the on the S input or the set input so this sets it in the sense that the output Q is on and then this resets it in the sense that the output Q is off and then inverse Q is just always the opposite of whatever Q is and so sometimes you might see this uh this Sr latch in circuit diagrams uh just as a as a box they'll draw it like this and it'll have these inputs and they'll be labeled R and S and that's how you'll know it's an Sr latch and it'll have the outputs q and not q and then usually they'll have a little bubble here to show that that's an inverted output and so if you see this in a in a circuit diagram you can basically think of it as this as this circuit or or something that that works equivalently in the sense that if you press the if you or if you input a one on that on that set input then the Q will will latch high and if you input a one on the reset input then the Q will latch low and then the not Q will sort of do the opposite and you might be wondering you know what happens if you input a one on both the set and reset at the same time and you know in that case uh the outputs are both you know both q and not Q go go low and you know sometimes you might see this referred to as an invalid State because you you you know if you're sort of using this as a set reset latch you should only be setting it or resetting it at any point in time you shouldn't be doing both so sometimes you might see that as an invalid State the other question you might have is you know when we first when we first powered this up you know it started with this top gate on uh and the bottom gate off and you might be wondering why you know why why does it refer the top gate this thing is the circuit is fairly symmetrical and really it's it's just kind of almost random or or arbitrary uh which one which one turns on first uh because when it first starts up all of these inputs are zeros and so if both inputs are zeros both gates want to turn on uh and in fact both gates might turn on but what'll happen is one of them will turn on maybe a little bit faster and this signal will get to the other gate and this other gate will now have this one input and a one and a zero will turn one of the gates off and so it's really just a question of which one turns on First and it's you know usually you it's probably on the order of of a few nanc or one is just a little bit faster than the other uh and so it just sort of arbitrarily one of them is going to turn on First and so you if you're using this circuit in or if you're using this you know this Sr latch in a circuit you're going to want to make sure you you have some way of resetting it or setting it or getting it at some known State before you uh rely on its output I suppose and so because the Sr has this property that you can set and reset it and it remembers the state that it's in you can imagine it might be useful in in all sorts of computer memory and other applications and so in future videos we'll we'll build on this and look at some other types of latches and and other components that are used in in computers so in the last video we took a look at the SR latch excellent so that was the uh first video uh yeah my my big cups I love them they are from the US uh I was introduced to them in Texas and so uh they have like this double wall and they keep the drinks fairly cool so uh they were drinking it during barbecue and I thought they are so amazing and then I had to buy a couple and bring them with now this one specifically has a stormtrooper as a design yeah and they have saved my alive a couple of times because of the lid you know it's not like completely sealed or anything it it leaks out uh it has an opening here for the straw and stuff but if it just Falls over a little bit it just spills a couple of sprinkles and I have you know thrown this over my uh accidentally knocked it over while working on the desk and so uh it keeps it cold and it keeps it safe sorry allergies my I have this nasty cough and my nose is itching uh so you are making this Arash but what for no I'm not we are watching Ben eer videos uh on the 8bit computer and uh this is just now this was just the next video in the series uh so before we move on to the next module he is explaining what the underlying stuff that we will be using next I I assume that's the reason uh the uh the SR ledge and at the flipflops and stuff like that that is uh crucial information or knowledge to understand how the computer then later works uh these are the kinds of components that we will make use of um so he's explaining them now and so we watch these videos before we can move on uh so I'm not I I I don't plan to uh uh implement this uh here now myself just watch it um yeah so these are Ben eater videos just FYI for the people have been asking uh what this channel is Ben eer is uh is the person who built this 8bit computer and he has this uh playlist the series on it which I'm following and I want to uh Implement myself uh okay so if no um feel free to write some questions after the next video uh I will again pause and we can have a quick chat uh before we then move on I think there are overall uh three videos of that just explanatory kind and then the fourth one will be continuing here uh so yeah let's head let's head back in 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 in 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 a zero it resets it and when that input is a one 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 one then it sets it and of course our inputs inverted so the resets a zero and if our inputs a zero then it's not setting it but if we invert that zero we get a one up here and it resets it so let's try and build this and see what happens so here is the circuit and basically it's the same as before so we've got the two nor Gates here uh 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 Norgate so 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 Norgate as an inverter because if you look at the truth table for the Norgate you can see if both inputs are zero then it outputs a one if both inputs are one it outputs a zero so if you tie both of the inputs together you can turn a Norgate 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 uh so this switch is going into uh both inputs the little jumper here connects both inputs and then the output of this Norgate 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 not Q is is one and if we turn the input on the Q goes high so it sets it um and the the not Q is low the problem is it's not actually latching anything anymore it's not uh it's not serving as a memory or 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 so 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 uh 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 um and instead of just having the the reset and the set inputs directly go into 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 zero both of these outputs these and gates are going to be zero 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 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 here is our nor Gates just like we've we've been seeing before uh 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 but instead of going directly to switches they're now going to and Gates and this is a 7408 uh quad and gate chip and uh we're using two of the and Gates on this chip and so one of the and Gates outputs is going to Res set the other is going to set the inputs are going are coming from either the reset button which is this uh across this green wire or the set button which is which is this button across the uh this other green wire and then the enable is this button up here is connected to both uh or an input of both and Gates uh 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 powered up looks like it's 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 um 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 if we turn on the enable we can set it and then if we turn off the enable it stays set and now the set and 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 uh going through the end 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 this High which will set the latch or we can reset it by setting it low which will then set the reset High and the and the set low but it'll 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 them hooked up with the two inputs and so this is the reset and the set inputs over here are these blue are the the blue wires and then they go into the or they come from I should say the and Gates and we're using two and Gates here as well and then the inputs for the endgate one of them is the enable and then that's this top 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 put which I've labeled as D for for data I guess the input is this this second switch here which you can see there's a green wire that's going into the input of 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 nor Gates as a as an inverter and so it's going into uh two inputs of that Norgate and then the output of that Norgate so the inverted uh the inverted signal from that Norgate is then coming back into the top end gate so if we power it up and take a look it Powers up and uh looks like it's set at the moment I've also added an LED here so the input uh 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 output's not changing uh 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 the in this case reset State and then if I turn on enable and then I set it and then I turn off enable it now latches enabled and so this is usually called a d latch uh because it will latch a single bit of data uh because we're you know we can use this as a as part of a to build a memory or register or something in a computer to store one bit of data and if you see there's there's a block symbol for it as well which is 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 in in fact normally if 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'll we can we can basic Al 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 DCH is a zero and again I can enable it and it follows whatever the input is and then if the input is a one and then we turn off the enable the latch stores a one 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 so in the last video We Built This D latch which has crap sorry for the microphone uh okay so I was just saying uh thanks for the cheer nanocat and then about the what the plan is uh so the architecture here is called sap but it has nothing to do with the software Manufacturing p uh it's called Simple as possible so it's a the it's from a as far as I know it's out of a a book explaining how a computer is what the different parts of a computer are and in this book uh the um the author introduces sap 1 2 and three I think and so uh these are as simple as possible architectures to build uh your own kind of computer and that's what Ben eater's videos are based on so he has it based on this book which I don't have but uh so yeah that that that's called sap simple as possible so yeah um oh that's clever yeah I also think I think it's so fascinating right it these these Gates and an gate or Norgate so easy to understand and suddenly once you connect an output back to an input you open up this whole magical world of suddenly what is possible with these with these setups here and then suddenly you have such a thing as this uh this this as this D lger or something I think it's also really clever because it because you understood these parts or you thought you understood them but at least I would have never thought about you know what would happen if you connect them back and what could you build out of that I I think this is real ingenuity uh thanks for the cheer uh M slice uh dinner plus streaming time yeah I also just ate dinner I'm not sure if you were here but while we watched the first video I ate my bowl um still too big for an i7 uh what do you mean turn on audio yeah sorry sorry sorry um this is just a mini lecture in electronics uh well not by me but by Ben E of course it's to make a register probably yeah I wait let Let's us maybe peek forward what is the next video in the series it will be the bus architecture and how register transfers work yeah so I guess we uh we will head into uh the registers next and the bus H but first we need to watch the third video the flip-flop video your one bit of data is three times bigger than I said oh oh yeah that's true it's it's isn't it insane how many what you can put on these small chips really makes you appreciate it once you build see like the gates in more human size I don't know all right I hope everybody's doing fine today how is everyone now a few more people have joined since we started human sized yeah yeah I I think if you grind open or Edge these open you might be able to see them with you might be able to make out the Gates of the simple and the nor Gates maybe with a with even a lens maybe possibly I'm thinking about building this during my M break as well sounds fun oh yeah I I think it's a lot of fun I also think it takes a lot of time uh but it has also something medit meditative about it but yeah I think it's a cool project I always wanted to do it no KP mate today I might get a k mate after I drank uh my Cola all right yeah okay then let's quickly watch uh the next oh 16 minutes well let's get it over with has the enable input as well as the D input and whenever the enable input is high then the output here the Q output is just equal to whatever the d input is and then there's also a an inverted Q output or a complimentary or negative uh Q output that's always just the opposite of what what Q is and then if the enable is not high then it doesn't matter what happens with the D input so this is the D latch I've made a slight modification from the vid the from the circuit we had in the last video which is that on the inputs I've added these LEDs uh and so if we're not pushing the button then this this is going to be uh very close to Z volts uh you know it'll SN a little bit of a current through the LED but not enough to to light the LED up and then when we push the the button then we're connecting 5 volts to the input and so the input goes from 0 volts to 5 volts and then uh we also have 5 volts that can uh flow through the LED and and this resistor just limits the current through the LED so we don't burn up the LED and so I just added these LEDs so that uh we can see what the inputs are so to get a better sense of how this works we can look at a timing diagram which is this here which shows the values of uh the the inputs the enable input and the D input over over time and so it shows them going high and low and and we can see we can kind of think through what's going to happen to the Q output and I've left off the the inverted Q output because I think it's just kind of distracting but in fact I'll remove this led uh but you know just keep in mind that the you know the the D latch also has an inverted output that's just always going to be the opposite of whatever Q is so remember the way this works is whenever the enable input is high the Q output is just going to follow whatever the d input is so just for these per perod of time where the enable is high the Q is just going to be what the D is so the Q here is going to be just what the D input is and then the rest of the time when the C when the uh the enable is low the Q output is just going to stay whatever it is so if it starts out off for example it's just going to stay off here it's off and so it's just going to stay off and then and then here it's just going to stay off and in this case it's going to going to stay on and in this case it'll stay off so it doesn't matter you know during these periods what the uh enable or what the d uh input is doing as long as the enable is off it's just going to stay uh latched where wherever it is so if we want we can just verify that this works the way that we that we think it should he had to practice that that's like almost playing like piano yeah and it looks like it works the way we would expect so that's great and hopefully it makes sense to you how that works but often times in more complex digital logic circuits we've got lots and lots of of different latches that are latching different values all over the place and it's important to keep all of that in sync and so typically there is a clock of some sort uh that is that is controlling the the operation of all of the different components and keeping everything synchronized and it's important what you want is you want to be able to latch the values at at a particular point in that clock cycle not necessarily just transparently passing through the values anytime that that clock signal is on and so to do this we'll look at a variation of the the latch which is the flip-flop so with the D latch anytime it's enabled the input D is going to be output at Q and and so if the D input changes while the the latch is enabled then you'll see a change at the output but often times what's more useful is to think of the instead of having an enable input having a clock input and then only outputting a change at that just at the point where the clock transitions from low to high and so this clock is really more of kind of a heartbeat uh that says at these specific points in time that's when I want the the latch uh to latch in or change its value and so for example at this point here where the latch transitions from low to high that means we want to take this value right here at D and we want that as our output so that's a high output so if we were already low then we would transition to high at that point there and then we want to not do anything so even though the D input changes while the clock is still high we don't care all we care about is when the next clock pulse is which that that next pulse from low to high and then we want to take this value and that happens to be high and so in this case the latch won't switch and so it'll stay high here and then we say we don't care about anything that happens you even though it goes low and this is still high here we don't do anything because all we're doing is we're looking for that next transition from low to high that next clock pulse and that happens here where D is low and so at that point in time we'll switch we'll switch the latch off and then again we don't care what happens here you know goes high again whatever we don't care we're looking for that next clock pulse where it goes from low to high and in that case the uh D input is high and so at that time we will switch the the latch back on um and in this case there's no more transitions so we we just stay high and so you'll notice this is a very different uh output than we got with with this scenario where we're using the enable but it turns out this is actually far more common uh it's far more common to want to only switch at a particular instant in time so the question is how do we build a circuit that does this well one way would be is if we could build a circuit that could take this clock input and turn it into essentially something that would be useful as an enable input for normal D latch uh so to kind of give an example of what what I'm talking about there is you know imagine we could have we could take this clock signal and get a signal out you know put it into some circuit uh and then get a c get a signal out that had these really quick pulses um just at this point where the clock transitions from low to high so if we could build a circuit that could do this then we could use this new uh signal here at the top as an enable for just the Classic uh D latch that we've been looking at so far and as long as this pulse is is really really narrow then effectively we're getting an instantaneous or as close to instantaneous as we can kind of read out of what D is and transitioning just at that point and so if you look at this this this is kind of like your enable uh in a in a regular D latch uh and then if you have that enable in that D you put that into a regular D latch then this is the output you'll get and hopefully hopefully that makes sense uh and so you can see if we could somehow take this clock signal and detect these Rising edges um with a circuit that we'll call an edge detector uh and detect those edges and then and then turn that into a pulse like this uh then we can build what's called a d flip-flop which is a circuit that will take you know that will start with this clock and and only transition at these points where the clock transitions from low to high so now the question is how can we build an edge detector circuit that you know takes this clock signal and outputs this this these pulses well there's a couple ways to do it and one is is this uh sort of interesting looking circuit here and you might be wondering well you know what what does this do we've got uh one input and one output and so you know the idea is that somehow a rising edge here is going to result in a pulse over here but you might be wondering well we've got this inverter going into an and gate we have an input here going through an inverter and you know one side's going through the inverter the other side isn't so if you had you know let's say you had a zero over here well that zero you know if you have a zero coming in it's a zero over here it's going to be a one over here and then you know the and gate the and Gate's going to be a zero it's you know it's only going to be a one if both inputs are ones and you might wonder well how how does how do you get to both inputs being one I mean if if this is a zero then this is going to be a one if this is a one then this is going to be a zero because we're inverting this and so this you think this endgate would never turn on and you you'd almost be right but what happens is if this signal is a zero you know we have this situation here where we have a zero coming in and a one here and so the end Gate's going to be off we're going to have a zero coming out but when this input transitions from a zero to a one this instead of being a zero is going to be a one and then then you would say well then then this would be a zero because we're inverting but the inverter actually takes a small amount of time to switch States so when this input changes from Z to one we've got a one here immediately but the inverter doesn't switch off for you know a few NCS you know very short amount of time but but enough time uh that for a very brief period of time we've got a one and a one coming into this end gate which turns the endgate on um but then of very quickly the inverter switches off this one turns to a zero and now we've got a one and a zero uh and then of course the and gate turns off and so it turns off almost immediately but now we have this pulse and we get this pulse anytime this input transitions from low to high we'll get a little pulse that comes out and that's exactly what we what we wanted here in order to detect this uh Rising Edge on this clock signal so that's one way of building an edge detector and I would actually encourage you to try building this yourself um there's a simpler way though that I'm that I'm going to do because you know this this is going to require an endgate and and uh you know an inverter uh potentially multiple inverters you might find if if you try to build this you need to stack up three or five of these inverters in a row just to get enough of a delay so that you get a big enough pulse uh but yeah you can give it a try uh but but a much easier way to do it that doesn't require adding more chips here is to use a resistor and a capacitor and so we can use a little circuit like this where we go into a capacitor and then you know through through that capacitor and then we have a resistor here uh that that just goes to that goes to ground and so you're wondering well what what does this do well in this case if you've got this this signal that comes in that transitions from low to high like this when it's at zero we've got you know Zer volts across this capacitor the capacitor is discharged you know because the ground here is going to be at zero so you know you've got zero volts over here so that's not not very exciting but then when it turns on the capacitor uh is going to start to charge and as it charges there's current flowing into it and of course if you've got current flowing through here you're going to have a higher voltage here across this resistor and so as soon as as soon as this turns on this is going to jump up to 5 volts you know assuming this is a 5 volt transition here but very quickly that capacitor is going to charge and it's going to charge through this resistor uh and as the capacitor charges less and less current is going to flow into it until the capacitor becomes fully charged and when the capacitor is fully charged then no current's going to going to flow through here and we're going to be back down at zero and so what happens is this turns on very quickly and then it slowly or maybe not so slowly depending on on how fast this is but it discharges or excuse me it charges the capacitor charges and so the the voltage over here drops until you know once the capacitor is fully charged you can have 5 volts on this side zero volts on this side no current flows and so you can see this is a pretty simple circuit to take you know this Rising Edge and turn it into a quick pulse you know because then this can stay high and this will just this will just be low but you get this nice quick pulse right at that Rising Edge which is which is what we want the question is how how quick is this pulse and you know I'm not going to go into deriving all the math but uh you you can calculate the the width of this pulse um by just multiplying the value of the capacitor and the resistor if you multiply the value of the capacitor resistor it'll tell you essentially where you know the point or how much time it'll take for this capacitor to get about 2/3 of the way charged which will give you a pretty good sense of of how um of how short this Gap is so let's build this I've got a resistor and a capacitor here this is a uh a 0.1 microfarad capacitor and then this is a 1K uh resistor and so if we want to figure out this this time constant to figure out how how big this this pulse is we can just multiply these together but of course we first we've got to get them into standard you know farads and and ohms so 0.1 microfarads is going to be 0.1 * 10 to the uh minus 6 and then one 1 K of course is just 10 the 3 and so if we take 0.1 * 10- 6 multiply that by 10 to the 3 we get 0.1 time 10 the minus 3 which is going to be equal to 0.1 milliseconds because if you're multiplying farads times kilms in this sort of circuit you end up with seconds uh so 0.1 milliseconds is how long this this Gap will be so for our purposes we can say that you know okay 0.1 milliseconds is you know pretty pretty much instantaneous which is what we're going for here we're we're looking for you know when this clock transitions we just sort of take an instantaneous read of this D input so as long as in our circuit this D isn't trans
Original Description
-=[ ❤️ Support ]=-
→ per Video: https://www.patreon.com/join/liveoverflow
→ per Month: https://www.youtube.com/channel/UClcE-kVhqyiHCcjYwcpfj9w/join
-=[ 📄 Info. ]=-
Main Channel: https://youtube.com/LiveOverflowCTF
Twitch: https://twitch.tv/LiveOverflow
-=[ 🔴 Stuff I use ]=-
→ Microphone:* https://amzn.to/2LW6ldx
→ Graphics tablet:* https://amzn.to/2C8djYj
→ Camera#1 for streaming:* https://amzn.to/2SJ66VM
→ Lens for streaming:* https://amzn.to/2CdG31I
→ Connect Camera#1 to PC:* https://amzn.to/2VDRhWj
→ Camera#2 for electronics:* https://amzn.to/2LWxehv
→ Lens for macro shots:* https://amzn.to/2C5tXrw
→ Keyboard:* https://amzn.to/2LZgCFD
→ Headphones:* https://amzn.to/2M2KhxW
-=[ 🐕 Social ]=-
→ Twitter: https://twitter.com/LiveOverflow/
→ Website: https://liveoverflow.com/
→ Subreddit: https://www.reddit.com/r/LiveOverflow/
→ Facebook: https://www.facebook.com/LiveOverflow/
-=[ 📄 P.S. ]=-
All links with "*" are affiliate links.
LiveOverflow / Security Flag GmbH is part of the Amazon Affiliate Partner Programm.
#liveoverflow
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from LiveUnderflow · LiveUnderflow · 11 of 42
1
2
3
4
5
6
7
8
9
10
▶
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
BUILDING AN 8-BIT COMPUTER FROM SCRATCH #2 (Full Stream)
LiveUnderflow
LiveOverflow's Makeup Tutorial #1
LiveUnderflow
MakeUp Tutorial for Streaming and YouTube
LiveUnderflow
MurmusCTF, SSD CTF Challenge, Google CTF writeups - PwnNews 27/06/19
LiveUnderflow
Google CTF 2019 Chat - Looking at Writeups
LiveUnderflow
Discussing Hacking Videos - Community Guidelines YouTube
LiveUnderflow
Hacking Skills Perspective
LiveUnderflow
Chatting about Cryptography and Exploit Regulations
LiveUnderflow
BUILDING AN 8-BIT COMPUTER FROM SCRATCH #1 (Full Stream)
LiveUnderflow
BUILDING AN 8-BIT COMPUTER FROM SCRATCH #3 (Full Stream)
LiveUnderflow
BUILDING AN 8-BIT COMPUTER FROM SCRATCH #4 (Full Stream)
LiveUnderflow
Studying Cybersecurity in USA vs. Germany | ReHacked
LiveUnderflow
Examining JavaScript Inter-Process Communication in Firefox | Watch Together & Q&A
LiveUnderflow
Reading SECRET U.S. Air Force HACKING Document!!
LiveUnderflow
Why Don't Use alert(1) for XSS? | Watch Together + Q&A
LiveUnderflow
Escaping from JavaScript Sandbox (AngularJS)
LiveUnderflow
Why proofing impact for every XSS is "dumb" - Bug Bounty Reports
LiveUnderflow
Password Cracking Explained | ReHacked
LiveUnderflow
HTTP Desync Attack Explained With Paper
LiveUnderflow
Better than Stack Overflow for Development
LiveUnderflow
Thumbnail A/B Test Experiment for CTR
LiveUnderflow
How To Exploit a Heap Overflow
LiveUnderflow
Log4Shell | Bug Bounty Public Service Announcement #shorts
LiveUnderflow
New Details on Commercial Spyware Vendor Variston - Revisiting Firefox Sandbox Escape
LiveUnderflow
Can AI Hack Websites with XSS? #ChatGPT
LiveUnderflow
ping Vulnerability Patch Analysis (with #ChatGPT) - CVE-2022-23093
LiveUnderflow
Using CodeQL to Investigate GraphQL Resolvers
LiveUnderflow
Security Issue Found in US Gov CISA Tool?
LiveUnderflow
Using joern to Find GraphQL Authorization Issue
LiveUnderflow
Analytics from 7 Years on YouTube...
LiveUnderflow
3D Printer Researching Igus Bearings - Prusa i3 MK3S+ (part 3)
LiveOverflow
Attacking VSCode Extension from Browser? - Live Security Research
LiveOverflow
I Don't Trust Websites! - The Everything API with ChatGPT
LiveOverflow
Do Hackers Need To Know Algorithms and Data Structures?
LiveOverflow
"Remove the video as soon as possible"
LiveOverflow
Arm®-based Video
LiveOverflow
How to make good HACKING videos
LiveOverflow
LEEROY fällt auf HACKER rein?
LiveOverflow
Hacking for an Intelligence Agency
LiveOverflow
Tier List of My Worst Tweets
LiveOverflow
Step by Step Phishing Setup Tutorials are Unethical!
LiveOverflow
Hacker Reacts to 23andme Data Leak
LiveOverflow
More on: Systems Design Basics
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
eCPPTv3 Review
Medium · Cybersecurity
Next-Gen Endpoint Protection Software: Securing Remote Employees Against Modern Cyber Threats
Medium · Cybersecurity
Understanding NAT (Network Address Translation): How Multiple Devices Share a Single Public IP…
Medium · Cybersecurity
Why the EC-Council 312-41 Practice Test Is Essential for Certification Success
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI