How Computer Memory Works – Computerphile

So we saw how the Mac used 30 pin SIMS like this to store its memory And we’ll look later at what sort of information the computer stores in these things But for now, I just want to look at how this actually stores information. Now as I’m sure all of you are aware, it stores it in terms of binary digits or bits But actually what we are really interested in [is] just storing a single bit and we can put them together to form lots of memory. So to understand how the memory works, we need to look at some of the basic digital logic circuits we can build using logic gates. Now over on Numberphile, Matt Parker introduced these using dominoes to create various things We’re going to look at them in terms of the electronic chips So you can buy your basic logic circuits in integrated circuits like this. This one’s four OR gates. So [incomprehensible], you put them together in an electronic circuit to build memory Now this is a bit odd because normally these are just used to process or combine various inputs but if we connect them in a specific way, we can actually get them to store information at least until the power is turned off. So what we’ve got here are two very basic electronic circuits. We’ve got an AND gate here, and an OR gate in this chip, here. These chips come with four AND gates or four OR gates together And if we remember from the Numberphile video, an AND gate is on when both of its inputs are on. If either input if off, then the output is off. So in this case, I wired it up to a simple L.E.D., so that we can see the output of one of the AND gates. And I’ve wired both of the inputs to the positive voltage rail because we use positive five volts to represent TRUE or one in binary and we use ground, or zero volts, to represent false or zero in binary. Now. That’s generally what we use with what was called TTL logic. These days you use different voltage levels and so on, but the principle is the same; you have one voltage which represents FALSE, or zero, and another voltage which is generally higher that represents one, or TRUE. So if I take… Hang on. If I just move these over so you can see what I’m doing. So both of these are currently connected to logic 1, or five volts. If I disconnect one and connect it to logic zero, you can see that immediately that light goes off, because the AND gate has now got one input zero, one input at one, one and zero is zero by the laws of boolean algebra. So we can combine these in different ways, And [incomprehensible] back in one, both one, it’s on. Put them both to zero, then they’re both off. Over here, I’ve got an OR gate. And if you remember back from the Numberphile video, an OR gate is on when either of its inputs are on, or both of them are on. So I’m gonna to rewire the circuit to do that. So often you’ll get books like this which will give you details of different things. The quad input positive OR gates has inputs on pins one and two and the output on pin three. The AND gate, the 7402, has the inputs on pins two and three, and the [output] on pin one. So, connect the output to pin three. And we can now start to connect the inputs. Now in both cases… Woops! I just shorted the uh… Oo. Ha Ha. *laughing” I just shorted the uh… [BRADY]: A little bit hot? [GUY]: Yeah. Just shorted the power supply which is why it’s making noise. So we connect both of these to… The cable’s all melted! …pin zero. And if we now unplug that and plug it into there, Have I just broken everything? [BRADY]: You fried the chip! [GUY]: I hope this gets edited out Yeah. So that’s right. Um. I’ve either fried everything on here… [BRADY]: Are you now turning it off and on again? [GUY]: I am indeed turning it off and on again, here, in the hope that I haven’t just shorted everything out. Uum. [BRADY]: Shall we pause there? [GUY]: Yeah. I think we might need to pause it. Ha ha ha ha. Smoke’s cleared, and we’ve just had a slight problem with power supply but we’re back and running now. There’s a little hamster running around in a wheel to power everything at the moment. So we’ve rewired this so that the output of the OR gate is now connected to the L.E.D. and these are both tied to logic zero through these resistors here. If I now connect any of these to logic one, the input comes on. So that’s input two connected to logic one. Input one, the input comes on. And of course because it’s an OR gate, if I connect the second input at the same time, then they’re both on. We also get other versions of these chips. and these are called NAND gates or NOR gates. And they work in exactly the same way. They two inputs and they AND them together but immediately following that, build into the chip, is what’s called a NOT gate, which inverts the output. So it’s the opposite of an AND gate. Its output is off when both of its inputs are on. So I’m-gonna-open this up. There we are. So-I’m-gonna take the AND chip out. There we are! And pop this chip in. It can be a pain because you have to bend all of the legs to fit in. There we go. So that’s now in place So-I-gotta rewire it now to use a NAND gate that I’ve popped in there. So I connect the output to pin three of this circuit. and the L.E.D. of course comes on, because both inputs one and two are wired to zero. Normally an AND gate would be off because both of its inputs are zero But this is the opposite of that so both of its inputs are zero, it’s now on. So if we connect input two to five volts, it stays on because zero and one is zero. There inverse of that is one. But if we connect input one as well to five volts, then the L.E.D. goes off. Because one and one is one, the opposite of that is zero, so the L.E.D. is now off. But as soon as we disconnect one of the pins, it comes back on. And one of the fascinating things about NAND gates is that you could build a whole computer just using the circuits on this chip. You’d need lots of them. You’d need more than four. But what we are going to do today is use, not a NAND gate to start with, but a NOR gate, which is an OR, then NOTed. to actually build some memory. So over here, here is one I prepared earlier, we have quad input NOR gate. So-this-is four NOR gates So-what-I’m-gonna do is wire two NOR gates into a circuit so that it’ll actually store the information that we put in it. I’m gonna use this one on the left here. And this one over here. Let me just check the wiring diagram We have pins one is the output of the NOR gate. Two and three are the inputs. And on the other side, pin thirteen is the output in pin eleven and twelve. So I’m gonna connect the output of this NOR gate on the right hand side to the input of the one on the left hand side [BRADY]: Shall we call them A and B or..? [GUY]: Yeah. So we connected the output of NOR gate B to the input of NOR gate A And-now-I’m-gonna connect the output of NOR gate A back to the input of NOR gate B. It’s a very tight fit so… There we go. So we’ve got these two things crossed over, but the output of one is connected to the input of the other. And just to make sure the circuit works, I’m just gonna put some resistors to tie the other input to zero volts to our logic zero. This means that I can make them logic one or logic zero just by touching the leg of the resistor with a wire connected to five volts later in the demonstration So the other thing I’m gonna do is I’ve connected the output of NOR gate A to this wire here. And I’m just gonna put a L.E.D. across that wire to ground like so. And I’m gonna to the same on the other side. So I’ll connect that up like so. There. And well see that this L.E.D. has now come on. So I now get a fly wire, plug this into five volts like that. And if I touch this one, this L.E.D. comes on, and it stays on. If I touch that one, that L.E.D. goes off and this one comes on, and stays on. This circuit is remembering its state. And we can do that by just driving a signal into the chip. And it’ll stay like that until I turn the power off. We need to look at how this circuit works. What-I’m-gonna do is draw it out. But before we do that, it would be useful to refresh out memory of how a NOR gate works. Ah. So that’s a NOR gate and it has two inputs which we’ll label as a and b and it has an output which we’ll label as q. So we can build a truth table for this. So normally with an OR gate, zero OR zero would be zero. But we’re inverting it because it’s a NOR gate. So the output is one. Zero or one is one, but it’s inverted so the output is zero. One or zero is one, but it’s inverted so the output’s zero. One or one is one, inverted, so the answer is zero. So that’s the truth table for our NOR gate. Now let’s have a look at the circuit that we used over there. So we had our first NOR gate and we also had our second NOR gate, like that. And we’ve got the inputs to these like so. And we took the output from here and connected it to the input of that one. And we took the output from here and connected it here. We’ve now got two inputs left that we’re not using and I gotta label them as R because that is what we use to reset it. and we’ve got S which is what we used to set it, or to store a bit. We’ve also got two outputs. And I’m gonna label the first one q and the other one we’re gonna call this NOT q. And the way we do that is is we draw a line over the top to say that this is NOT q. Now the thing we have to remember about these circuits is that they don’t switch the output instantaneously when the inputs switches. There is a slight very short delay. And depending in what kind of chip you get… But there is always a slight delay. So-what-I’m-gonna do is I’m gonna draw out our truth table for this So we’ve got input R, and we’ve got input S, we’ve got output q, and output q NOT q. But these are also inputs to this. So I’m actually going to put in q prime and NOT q prime. To start with, this is at zero, this is at zero. We don’t know what these values are, so we’ll leave them blank. What’s the next value of q going to be? So it’s going to be zero, OR’d with the current value of NOT q, NOT’d, so that’s gonna be represented as q NOT q, NOT’d. NOT q, NOT’d is of course q because the two NOTs cancel out. So the value of q prime is whatever the old value of q was effectively. Same happens for NOT q prime. That’s s, which is zero. OR’d with the old value of q, NOT’d so we get NOT q. So as long as the two inputs are zero, you get the same values propagating through the circuit. But what happens if we set s to be one. We’ll leave r at zero. So our new value of q is gonna be the old value of NOT q OR’d with zero So it’s gonna be NOT NOT q again. So it’s gonna be q. Our new value of NOT q is gonna be s, which is one, OR’d with whatever the value of q was, NOT’d. Now if you OR anything with one, if you think about the truth table, the answer is always one. So NOT q is going to be zero because it’s NOT of one. So we’re gonna get a zero in there. So we can feed those back in again We’ve still got zero and one as the input here We now know that the output of q bar, or NOT q, is zero. So what’s the new value of q gonna be? Well, it’s the output of NOT q, which is zero OR’d with zero NOT’d which is one The output of q prime is going to be one and the output of q bar prime… Well that’s still one OR’d with whatever the output of q was before. So we’ll call that q, that’s always going to be one, NOT’d, so that’s gonna be zero. And if we run those values through again… So we’ve got zero, one, one zero. Then we get the same values out: one, zero. But the interesting thing is, when this becomes zero, and that becomes zero again, q is still at one, NOT q is still at zero If we run the circuit through here, the new value of q is the old value of NOT q OR’d with zero that’s zero, NOT’d, that’s one. And NOT q prime is S, which is zero, with the old value of q, which was one, and that’s one, NOT’d, that’s zero. So it stays the same, and you get the same input coming through. So it actually continues. And we could do the same thing with the reset, and you’d find if you work it through, that it resets it and all of the values go to zero. So that very simple circuit will actually store the state if it is set and if it is reset. And you can actually build up a complete memory circuit because you can put some very simple digital logic in front of that to generate the right s or r signal based on the value of a bit and whether you want to store it or not. [LEFTVIDEO]: …and everybody was gonna click on that one. Well it turned out that the video behind that was a person talking about the fight [RIGHTVIDEO]: Only that will fall over, that wont move. Here we go! Ready?

100 Replies to “How Computer Memory Works – Computerphile

  1. my sd card corrupted and all the videos delete so it is possible the video is on memory of computer ? even I don't save I just only play in computer.

  2. I already knew that this is how latches work. It's part of the curriculum for me, but seeing it for real at 8:35 was really cool for me. It's not like I didn't believe it before I saw it but this makes it "more" real. This video didn't exist back when I learned this stuff.

  3. Give me all of your Atari computers please. :p lol dang you have so many different kinds of the Atari computer models… I just want to be there!

  4. thank you so much Mr. Steve,
    and this is one of the best demonstration i have ever seen on youtube :)!!!!!!!!!!!!!!!!!!!!!!
    just perfect !!!!!

  5. sorry to say it but whatever device you're using to read this comment is most likely using capacitors as RAM. welcome to the real world

  6. CMOS logic is naturally inverting, so don't you mean to say that a NAND gate and NOR gate are implemented directly, whilst the AND gate and the OR gate have an inverter at the end?

  7. This could have been done so much clearer and btw. you explain how static memory works and the ram chip you show at the start use dynamic memory which is working with refreshing charge or no charge on capacitors rather than logical circuits.

  8. Could you do a video that explains how that binary information gets translated to pixel coordination? I know it is constantly updating pixels on a screen, so surely the time delay you mentioned is actually taken advantage of to loop power cycles to the pixel component.. or is it something else? Very well explained! Thank you greatly.

  9. It´s explained quite simply by proof. It´s quite simple really, I was having some trouble understanding how a cpu could store a number and I could really think of one way but had no idea how that would work. This video demonstrates this. As said in video: Memory function unit works with 2 parameters: R and S where S is the value true and the value itself at the same time. When a cpu is done storing the value it breaks off the connection from the memory unit but the memory unit preserves the value. This happens because if you notice, the value is stuck in an infinite loop being constantly evaluated by S = 0 and R = 0. Which means it will never change.

  10. This is a nice video to explain how logic gates work. Didn't clearly explain
    how data is stored on devices like Hard Disks or Optical Disks.

  11. Because of you, I made a computer! Check out the video on my page. I made it control servers, leds, sounds and more! I just had to say thank you.

  12. Who needs a integraded circuit? I made it with 4 transistors, a protobord, and 7 resistors. But it was realy hard. Why I didn't used a integraded circuit?!

  13. 13:40 "and all the values go to zero" um NO they don't. all the values do the OPPOSITE, the circuit is symmetrical.

  14. They should have been teaching us this stuff when I was in school in the 80s. We didn’t even learn dos. We were totally ripped off. It really bothers me to this day how our school board was so incredibly ignorant and yet stoic in that.

  15. That's an awesome video but i'm curious about one thing; in the inverse of the AND gate, when both inputs are "0" or "off" the result comes back as "1" or "on". how is this possible on a physical level? doesn't 0 mean no electricity? so how come providing no electricity to the gate gives electricity on its own? am I missing something?

  16. I wrote two Tests about this in College Never understood what was going on. A whole year. Watched this Video and its so Freaking easy I am ashamed of failing the test

  17. I severely dislike that explanation.
    While logically, a NAND gate is taking an AND gate and then putting a NOT gate on the output, electrically it typically isn't. Electrically it is very easy to make a NAND gate directly, and for CMOS, PMOS or NMOS, NAND gates are made directly and an AND gate is actually a NOT gate fed by a NAND gate; likewise the NOR gate is done directly and an OR gate is a NOT gate fed by a NOR gate.

  18. I just figure out why minecraft players call this an 'rs nor latch' I had no idea the name was based on actual terminology

  19. They should have mentioned the S-R flip-flop's inherent flaw, which is: if both R and S are 1, on the output Q and /Q will be equal to each other, which is obviously not how boolean algebra should work.
    Of course there is an easy way around this, just don't let R and S be equal to 1 simultaneously. And the J-K flip-flop fixes this issue, but that requires a clock signal to work.
    Just thought this should be mentioned when talking about S-R filp-flops..

  20. Ok @computerphile. I cannot find the answer to my query…maybe you could help? I got your vid by asking "how can you put information in a computer chip?". I understand the whole 1 on, 0 off deal, that's not my question though. How in the world does those chips, made out of metal and stuff you could tell me I hope, hold numbers? How does a machine become capable of being able to put binary code into it in the first place? How did they figure that out too? What is so special about those chip, silicone right, that makes them able to put a language created by man, I hope or who if not, to have the ability to turn inputs off or on? I find it rather difficult to ask the correct question here. Lol. For I wanna know how it all began. How did they find out how to make the chips, how did they figure out that they could also turn those chips on or off? You getting where I coming from here? I hope so. If not I can put more detail I suppose. Just lemme know

  21. Wish they put this kinds of videos into Television instead of regular empty content show they put on TV's nowadays which teaches you nothing. I understand it's entertainment business but everyone has their own definition of entertainment and I was entertained by this.

Leave a Reply

Your email address will not be published. Required fields are marked *