[From the last episode: We saw how branch speculationDone by a processor, it means that the processor has to guess ahead of time what the result of a test will be so that it can load those instructions into the pipeline. If it’s wrong, it will have to empty the pipeline and restart with the correct instructions. can both save time and hurt long pipelinesA way of speeding up a repeated task by breaking it up into stages and having different resources do each stage. It takes longer for the first task to be completed (that’s the latency); the others come out in quick succession after the first one..]
Before we talk more about processorsA computer chip that does computing work for a computer. It may do general work (like in your home computer) or it may do specialized work (like some of the processors in your smartphone)., we need to take a look at memory. Pretty much no computing happens without some kind of memory. The thing is, there are different kinds of memory, and they’re good for different things. Spoiler alert: no memory is perfect, although the search is still on for a memory that’s good at everything. But that’s a topic for another day.
Who Needs Memory? Wait, What Were We Talking About Again??
Why do we need memory anyway? Well, for two main things: for storing the program that a processor will need to run and for storing any data needed for that computing and results of the computing. But even that isn’t specific enough to nail what we need from memory.
One big question is, do we need to keep whatever’s in memory for a long time? In particular, if we powerThe rate of energy consumption. For electricity, it’s measured in watts (W). down a computer, should the data still be there later when we turn it back on? Data that disappears when the power shuts off is called volatile; data that sticks around is called non-volatile or persistent.
The program that a processor needs to run must be stored somewhere persistent, since the processor needs to access it when the power turns on. Imagine if your laptop applications or mobile-phone apps disappeared every time you powered down! You’d have to re-download and re-install them every time you turned the systemThis is a very generic term for any collection of components that, all together, can do something. Systems can be built from subsystems. Examples are your cell phone; your computer; the radio in your car; anything that seems like a "whole." back on!
On the other hand, maybe there is data that the processor doesn’t need to store permanently. If the processor calculates something it’s going to need again in a few seconds, but not after that, then the processor can keep the data in volatile memory. Another example is when you, say, are working on a document in a word-processing program. You have to save occasionally, or else, if the power shuts off unexpectedly, you’ll lose a ton of work. That’s because, while you work, your laptop stores your document in volatile memory. When you save the document, it goes to non-volatile memory.
Different Kinds of Memory
So let’s talk about specific types of memory, and we’ll stick with the major ones. One note on naming, however. From way back when, there were two broad classes of memory. There was read-only memory (ROM), which you could read but not overwrite. Then there was random-access memory (RAM); you could read and write from any random place in the memory easily. That may sound obvious, but think of the old reel tapes that we (well, not I) used to store data on. It’s hard to go just anywhere over and over, since you have to wind the tape into the right position. It’s doable, but cumbersome. That’s an old concept, but you’ll see it in the upcoming names.
SRAM
Static Random-Access Memory. This is a volatile memory that’s really fast, but burns a lot of energy. If you want the processor to be able to access something quickly, then you put it in SRAMStands for "static random access memory." This is also temporary memory in a computer. It's very fast compared to other kinds of memory, but it's also very expensive and burns a lot of energy, so you don't have nearly so much.. Instructions are often loaded into SRAM so that the processor doesn’t have to wait around when it’s ready to execute them. Short-term data can also go here.
The challenge with SRAM is that it takes a lot of space on a chipAn electronic device made on a piece of silicon. These days, it could also involve a mechanical chip, but, to the outside world, everything looks electronic. The chip is usually in some kind of package; that package might contain multiple chips. "Integrated circuit," and "IC" mean the same thing, but refer only to electronic chips, not mechanical chips. (that is, it’s expensive) and it uses a lot of energy. It’s called “static” because, when you put the data there, it will simply stay there for as long as the power is on.
DRAM
Dynamic Random-Access Memory. This is also volatile memory, but the memory cells are much smaller – and therefore cheaper – than SRAM. So this is where bigger chunks of data or a program will go. Problem is, it’s slower than SRAM, although it uses less energy than SRAM. If you need to get to something in DRAMStands for "dynamic random access memory." This is temporary working memory in a computer. When the goes off, the memory contents are lost. It's not super fast, but it's very cheap, so there's lots of it. over and over, you might want to temporarily put it in SRAM so that you can get to it faster (we’ll talk more about this next week).
It’s called “dynamic” because the data can slip away even when the power is on. So the system has to “refresh” the data over and over to keep it in place (unlike static memory).
Flash memory
This is a very common kind of non-volatile memory, but there are two varieties. One is called NOR flash for reasons we won’t get into here. It’s pretty easy to read, although it’s pretty slow. It’s more complicated to write to than SRAM and DRAM. You could keep a small program in NOR flash and, theoretically, have the processor grab the instructions right out of the flash, where they’re permanently stored. That would be pretty slow, however, so usually the instructions are copied out of the flash and stored temporarily in SRAM where they can be accessed more quickly as needed.
The other type of flash is called NAND flash. The good news is that it can store much more data much more cheaply than NOR flash can. But it’s much more complicated to write to and read from. So it’s not usually used for something like instructions, where you have to be able to retrieve them a few at a time from different places. Because you have to read a big chunk of data all at once, it’s better for storing big data files. You’ve undoubtedly used it before: that’s what thumb drives are made of. If you’ve heard of solid-state drives (SSDs), those are also built from NAND flash.
Note that, even though we call this non-volatile memory, the data can, in fact, slowly drain away. But that happens over years, so, for practical purposes, it’s ok. But if you want to archive something for historical purposes, it’s probably not suitable as a store-it-and-leave-it medium.
Hard drives
I mention these just because, for those of you using laptops, it’s an obvious type of memory. It’s non-volatile, and it can store a lot of data for a very long time (longer than flash). The problem is, it’s built on disks that spin and are read by a read head – which is kind of like the needle on an old-school turntable. Because it’s mechanical, things can break more easily. Solid-state drives are starting to replace them in many computers, but there is still the issue that SSDs lose data faster than a hard driveA type of persistent (non-volatile) memory built from rotating platters and “read heads” that sense the data on the platters. will – but your laptop will probably die before the data goes. We’re not going to talk about hard drives anymore, since they’re not typically a part of an IoTThe Internet of Things. A broad term covering many different applications where "things" are interconnected through the internet. setup.
Leave a Reply