Introduction
I’ve been trying to sort out all those computer memories in some meaningful order in my head for some time and it turned out to be not an easy job. Partly because of my head and partly because of all the various memory types out there: volatile, non-volatile, read-only, RAM, DRAM, SDRAM, permanent, Flash…does the list ever end? What does it even mean? Flash memory is very popular nowadays – why do I take it for granted on my 32 GB USB stick but count every KB when doing an embedded projects? Why does my 4 GB USB stick have only 3.7 GB of memory? Too many questions, so I better hit it and do my own research.
Microcontroller vs processor, again
What has been the most confusing for myself is distinction of memory types for small embedded AVR projects and memory types for my home PC. Surprisingly, they all come down to be the same thing! It’s just that PC has bigger memory appetite, and we measure memories in GB or TB when dealing with it, whilst we usually need a few of kilobytes when working with microcontrollers. The difference between microcontrollers and CPUs of home computer is – in regards to memory – where the memory sits. With microcontrollers, the memory is embedded within the same chip as the processing unit, while the PC CPU requires memory units brought from the outside world (that’s the reason why MCU based devices start working imediately while your PC or Raspberry Pi takes some time to boot). So we have, for instance ATmega328 with 32 KB of Flash memory, 1 KB of EEPROM and 2 KB of RAM. On the other hand Intel Core i7-6700T has 8 MB of cache memory and … that’s it! Everything else we use as memory – RAM, HDD, USB sticks – all of those gigabytes you need for gaming and pirating come from the outside.
Nice. But wait, did you just say something like Flash, cache, EEPROM, RAM? What the hack is all of that? Lots of names and terms come from the times before IC technologies, when memories were made of huge reels, vacuum tubes and relays and would usually take a size of a smaller diplodocus. I will not go into description of those technologies but will try to clarify the names we’re stuck with ever since. All the memories I’ll be writing about are semiconductor based devices, either diode matrices or transistor arrays.
How to store the data?
I have somehow intuitively divided memory types based on question: what happens when the power goes down? Answer is surprisingly simple: the memory either loses its content or it doesn’t! It turns out there is a real term for these two types: the first being volatile and the second being non-volatile. Very imaginatively. First thing that bothers me here is – if there is a chance to make memory not to forget its data why do we ever bother making memories that do forget it? Well think about it for a while – how would you store your data if the electricity is off? Guess you would use some..uhm..big capacitors? But they would discharge very soon. Magnets? They’re big and chunky, and noone knows how they work :). No seriously, how? Write it with an ink? Carve it in a stone?
It turns out we don’t have many options after all and none of them is permanent. We use either magnetism – where the data is stored as a tiny micromagnetic pattern in our hard drives (or even audio cassettes, anyone remember audio cassettes?), or compact discs – where data is literally carved into the disk coating by laser and optically read-out, or solid-state technology that’s been around for last 20 years only and has ability to store an electrical charge for extended periods of time without a connection to a power supply. All these types have a couple of things in common – they’re bulk and slow. Magnetic hard drives and CDs even need a motor reader to deliver their tasks. And all of them are temperature dependent – rise a heat a bit and magnetic drive is demagnetized, optical coating evaporated and solid drive leaking.
You can see, non-volatile memory is not something you’d want in a high-speed device. Volatile types, on the other hand, are very fast – they don’t need permanent memory storage. A couple of capacitors and transistors are enough. But, once you plug the power supply off, everything in there is lost in abyss.
It is usually said that computers need two types of memory; one to hold the instructions that it needs to execute (a program), and another to hold the data that are being used in the calculations. Program memory is something you don’t want to lose when the power goes down, so it is made as non-volatile type. Data memory can be both – there are some things you don’t care to lose like millions of variables processor stores temporarily and some things you want to keep for long – your documents, photos, games…
Here are your options.
Memory types and their weird names
Non-volatile memory types
Let’s start with non-volatile types. The most commonly used term that comes around when talking about computer memories is ROM or read-only memory. Yes, Mr. Holmes, this type of memory can only be read, not written. Technology of the time when it was first invented required that memory content is pre-programmed in a memory factory and then shipped to an engineer who used it. This feature had one good side – the ROMs are non-volatile, so their data is not erased when the power goes down. It didn’t take while till somebody said: “this is lame, I want to program my own memory here and now” so he invented a programmable ROM, or a PROM, that you could write your data on – once. This was possible thanks to a new floating-gate MOSFET technology that replaced diode matrix of the earlier ROMs. It wasn’t much fun either so people soon invented an erasable PROM or EPROM, which could have been erased and re-programmed again. These chips were funny since day had a small glass window to expose a silicon die to UV light in order to erase memory content when needed and were referred to as UV-EPROMs. Not much later, someone said again “this sunbathing memories are also lame, let’s make memories electrically erasable” and so it came an EEPROM. This new branch of ROMs brought an end

to the savage practice of erasing of the whole data by introducing single byte by byte erasure. Suddenly, you could use your fancy new chip for many cycles of reading or writing. No need to say that soon all computer memories were using the EEPROM types. Various topologies and architectures have resulted in different speeds, prices and chip performances and one that outshone them all was a Flash EEPROM. Initially developed by Toshiba in 80’s, Flash EEPROMS have been established as the fastest, cheapest and easiest to use and have been, and still are, used in all computer application: starting from LED blinking microcontroller programs to memory cards (MMC, SD), USB sticks, solid-state drives (SSD) and all those terabytes of vacation photos you keep on Facebook data centers. Downside of flash is the number of erase cycles you can perform. With every erase cycle, a floating gate FETs are corroded and after some time degraded. Some really inexpensive flash chips have a rated life of fewer than 50 erase/write cycles, you can find these in PC motherboards where the BIOS is updated almost never. More expensive flash chips can withstand 1 million erase/write cycles, these would be used in camera memory cards, and USB sticks. The flash memory that is built into a microcontroller chip has an erase/write endurance somewhere in the middle, more like 10 thousand cycles.
Volatile types
Another often heard type of memory is RAM or random access memory. This basically means that data in the memory can be accessed at any location randomly anytime. All kinds of memory devices we use today are RAMs. Why do we insist on calling it “RAM” all the time then? It’s historical. In pre-transistor era, the data was mechanically stored on the tape reels, and the access to the data was sequential – one piece of data after another. This has changed forever after the advent of RAM integrated circuits on the scene in 70’s.
When we talk about RAM, we usually want to say “volatile memory that is very fast”. There are two the most widespread types of these memories, static and dynamic. The difference is in their basic building blocks or memory cells – with dynamic RAM or DRAM we have simple capacitor and transistor (remember when we mentioned above capacitor as a storage element), while with static RAM or SRAM we have 6 transistors configured as a flip-flop bistable. Both of these are very simple circuits that everyone here studies in the 1st year of electronics courses. It’s just that in one chip there are monstrously lot of them. Why are they called static or dynamic? DRAM has capacitor in it. And what capacitor does? It discharges. So you need to re-charge periodically. In other words, you need to dynamically remind the memory on its contents. SRAM on the other hand uses flip-flop utility to keep its data stable forever. Or until the current drops down. SRAM is the fastest type of memory we know of.
A DRAM module only needs a transistor and a capacitor for every bit of data where SRAM needs 6 transistors. Because the number of transistors in a memory module determine its capacity, a DRAM module can have almost 6 times more capacity with a similar transistor count to an SRAM module. This ultimately boils down to price, which is what most buyers are really concerned with. Because of its lower price, DRAM has become the mainstream in computer main memory despite being slower and more power hungry compared to SRAM. SRAM memory is still used in a lot of devices where speed is more crucial than capacity like CPU cache memory of processors where speed is very essential, and the low power consumption translates to less heat that needs to be dissipated.
A bit more on Flash and DRAM. They are very important.
We can say they’re the most used kinds of non-volatile and volatile types and they deserve to be looked a bit deeper.
While the fundamental DRAM cell and array has maintained the same basic structure (and performance) for many years, there have been many different interfaces for communicating with DRAM chips. DRAM can be divided into asynchronous and synchronous DRAM (SDRAM). Like always synchronous means there is some clock signal that leads the communication. Double data rate SDRAM (DDR SDRAM) was a later development of SDRAM, used in PC memory beginning in 2000. “Double data rate” is fancy way of saying that the data is sent on both rising and falling clock edges. Subsequent versions, named DDR2, DDR3, and DDR4, increased this factor to 4× and 8× and reduced the power consumption to 1.2V.
The two main categories of Flash memory are named after the NAND and NOR logic gates which correspond to the internal structure of the memory cells. Why do we have two? As always it’s a speed vs size trade-off. NOR is generally faster and bigger. A goal of NAND flash development was to reduce the chip area required to implement a given capacity of flash memory, and thereby to reduce cost per bit and increase maximum chip capacity so that flash memory could compete with magnetic storage devices like hard disks. Operation of each is nicely explained here. Flash memory space is organized in blocks of data. One limitation of flash memory is that, although it can be read or programmed a byte or a word at a time in a random access fashion, it can be erased only a block at a time. Why is that so? Well, the fabrication of the flash chips results in a specific memory space division that consists of blocks and pages. On this blog you’ll find more details about inner architecture of Flash.
The false memory size
Did it ever happen to you that you buy a memory device rated at couple of gigabytes but when you get home and plug it in you see significantly less memory space? Like, for example, 4 GB memory card that I bought actually had 3.7 GB. Almost 10% of it was missing! If you are angry on a lying producer, you should be, but not for the reason you think you should be.
There are two standards in memory size unit notation, decimal in binary. In decimal, one gigabyte is 1000 megabytes while in binary, this equals to 1024 megabytes. Some will even go further and call this unit Gibibyte. The problem is that manufacturers use these notations arbitrarily and do not inform naive buyers. So, when they sell you 4 GB memory cards, they actually sell you 4 000 000 000 bytes, which corresponds to 4 GB in decimal notation. But in reality, it is GB in binary notation that our computers use.
I got motivated to do this research and write this post thanks to the video of TEDed, and great article at embedded.fm.
2 thoughts on “Remember the memories”