Memory Devices and How They Work

Soham Chatterjee
11 min readAug 17, 2018

--

Memory devices have become so ubiquitous that very few devices can function without them. Despite this, very few of us actually understand how they work and I think we take advantage of just how easy it is to drag and drop a file into a device and have it seamlessly stored in a matter of seconds.

Decrease in the cost of Memory over the years [16].

Behind this simplicity though, to store even a single bit, changes have to occur in nano meter precision, and in millisecond (and even nanosecond) periods, which shows the amount of technological advances that these seemingly ordinary and commonplace things went through in the last few decades.

In this article, I will explain a few memory devices and how they save and retrieve memory.

Note: This article is a bit off-topic from what I usually blog about. The reason for this article is because I came across memory devices while working on another more interesting topic: Dark Silicon and Dark Memory. If you like these kinds of articles or if you think there is any way I can improve them, do let me know!

Some Basics First

Since this article will be looking at memory from a hardware perspective, there are a few things that you should know before moving on:

Firstly, memory, of any type, is stored in the forms of 0s and 1s. It does not matter if you are storing your favorite music video or a PDF file of your resume, it is always broken down into 0s and 1s (bits) in the memory. A 0 and a 1 can be represented in many different ways and different memory devices use different techniques to store them. They can be represented by voltages, magnetic fields or even capacitor charges. Since we tend to store a lot of bits, the smaller the area needed to store that bit, the more memory we can fit in a given space.

Secondly, in my opinion, there are two kinds of memory: Memory which we need to access quickly like the RAM, cache and registers and memory which we use over a long period of time like flash drives, hard disks and SSDs. Because of the way we access the memory, there is a difference in the way we store them.

Memory that needs to accessed quickly are generally not required over a long period of time. In that case we sacrifice power for faster access time. This is why most of these memory need constant power and need to refreshed periodically (they lose their stored state easily) to store memory. They are also built to be able to handle many changes to their state. On the other hand, long term memory often do not need continuous power to retain their state, however, their read and write times are much slower.

And finally, the farther away the memory is located from the device trying to access it, the longer it will take to access it. This becomes pretty evident when dealing with registers and cache and RAM.

A few other benchmarks for memory access times [17].

Since the registers are present in the CPU itself, they can be accessed the fastest. The L1 cache is the next closest thing to the CPU and it takes a slightly longer time to access it. The next closest thing is the L2 cache which can take 4 times as long to access as compared to the L1 cache and 48 times (!!!) as long as cache. And accessing something from the DRAM? Well, compared to a register, it can be 720 times slower (which is actually 65 nanoseconds!) [1]. The scale at which these things run is insane and I really commend the people who did the research and implementations that lead to such results.

Ok, so now that we know some of the basics, let’s dive in and see what these things are made of to help them achieve such results.

CACHE

There are two ways in which we have implemented cache and I’ll talk a bit about both of them. Remember, that the cache has to be fast and should be able to handle a large number of read/write operations.

SRAM

The Static Random Access Memory is a type of cache that is implemented using 6 transistors. SRAMs are extremely fast and since they are static, the memory does not need to be refreshed unlike SDRAMs. However, they do need continuous power to maintain their memory state. But being a static memory, their power requirements are quite less and definitely lesser than SDRAMs. SRAMs are also very expensive as compared to SDRAMs and hence only a small portion of the cache (usually registers, L1 and L2) will be made with SRAMs (differs in each manufacturer) [2].

SRAMs are a type of flip-flop and use 4 of their 6 transistors as an inverter to store a bit of memory. The other two transistors control access to the memory. There are SRAMs that are implemented with more transistors (8T, 10T) and with lesser (4T). 8T will take more space to store a bit than a 6T SRAM but will utilize less power [3]. Where they are used depends on what you want to optimize. For example, L1 cache is more optimized for speed and will be different from L2 which is more optimized for size [2].

Construction of a 6T SRAM cell. P1, P2, N1 and N2 form an inverter and N2 and N4 act as access transistors. [18] has a really nice explanation of how memory is written and read from a cell like this.

The SRAM has three operations: Write (used to store memory), Read (used to retrieve memory) and Hold (used to save memory). How they do it is a bit complex and I won’t get into the details in this article (maybe I will write another one for it), but the figures should help you get a sense of how they function ([18]). Furthermore, if you wish to learn how to build an SRAM memory of your own, then you can follow this great article.

SDRAM/DRAM

SDRAM is the acronym for Synchronous Dynamic Random Access Memory. The major difference between an SDRAM and a DRAM is that an SDRAM has a clock that is synchronized to the CPU clock. SDRAMs can also pipeline instructions which makes them faster and more efficient than simple DRAMs [4]. This is why DRAMs have mostly become obsolete and have been replaced with SDRAMs.

SDRAM implementation [19]

SDRAMs are implemented using a transistor and a capacitor. The state of the capacitor (charged/uncharged) is what is used to store a bit. This however has two implications. Firstly, since the charge of the capacitor can get depleted quickly, it has to be recharged over time. So not only is an SDRAM volatile (needs power to maintain its memory), but it is also Dynamic (charge needs to be periodically refreshed).

Secondly, every READ operation on a bit of memory (using a sense amplifier) causes the charge on the capacitor (if it is present) to be depleted. This means that the data must be written back after every read operation [5]. This process consumes both power and time hence making the SDRAM much slower and power hungry than the SRAM.

SDRAMs have undergone many iterations over the years and newer versions are called DDRx SDRAM, where the DDR stands for Double Data Rate. Newer DDR versions are generally faster and use less power [6].

FLASH DRIVES AND SSDs

Pen/Thumb/Flash drives, whatever you call them, and SSDs are probably the memory devices that we interact with the most physically. They are non-volatile, meaning that they don’t need power to maintain their memory and while they are slower than the other memory devices I mentioned before, they are much cheaper and hence used to store larger amounts of memory.

Flash memory is of two types: NOR flash and NAND flash. NOR flash has faster read speed and slower WRITE and ERASE speed as compared to NAND flash. This is why it is mostly used for storing programs in devices (since programs are read more often than written).

On the other hand, NAND memory has faster WRITE and ERASE speed than READ speed and hence used for general storage purposes [8]. Furthermore, NOR requires more space to store a bit while NAND is more compact, making NAND memory cheaper per bit. This is why NAND flash is more suited for making flash drives with. To know more about the difference between the implementation of those two, you can take a look at [9].

Flash memory, like SRAMs, use transistors to store bits. However, unlike the transistors in SRAMs which lose the charge when power is removed, flash memory can retain it. It does this by using something called a floating gate terminal.

Structure of a Floating Gate Transistor. The Floating Gate is surrounded by a Metal Oxide Layer that prevents charges from escaping when power is removed [9].

Unlike in a normal transistor where there is only one gate, a floating gate transistor has a secondary gate that ‘floats’ or is insulated from the control gate.

When we want to store a bit, we apply a voltage to the control gate. The electrons pass through the insulator layer and gets trapped in the floating gate. These charges remain lodged in the floating gate even after power is removed. In fact, the charge on the floating gate can last for years [10]!

The process of writing or erasing data can cause the floating gate to ‘wear off’ and reduce its ability to store memory over many read/write cycles. Think of it as writing on a piece of paper, erasing it and then writing on top of it again. After a while, it becomes impossible to write anything on it again.

Flash drives do have controllers that make sure that memory gets distributed among a lot of transistors to prolong the life of the gate [11]. Moreover, like the paper example from before, erasing a transistor does not remove the charges completely and some of the charges in the floating gate can still persist (just like erasing a piece of paper can still leave some traces). This can be used for good (to retrieve lost data), but it can also be used for bad (like reading private/deleted documents).

SLC has only a single voltage refernce allowing it to store only 1 bit [21].

Before moving on, I also wanted to mention that SSDs and SD cards (micro and mini too) also use the same NAND flash memory technology to store information. The reason they can store so much information in such a small space (which is not possible [20]) is because in most modern flash memory, a multi-level cell (MLC) or even a triple-level cell (TLC and TLC+) design is used.

MLC has more reference points allowing it to store more bits in the same space [21].

This means that unlike what I mentioned previously (SLC), two bits (MLC) or more (TLC < 3 bits>; TLC+ < 4 bits>) bits of information can be stored in a single cell (transistor). This allows more information to be packed into the same area, making it cheaper to manufacture. However, at the same time, there is an increase in power consumption and error rate (although it can be reduced using clever software techniques). MLC and TLC memory is much slower as compared to SLC and is less robust (shorter lifespans).

Even though many companies hesitate to mention what kind of storage level they use [12], it shouldn’t be surprising to know that TLC is what is usually used for regular products and eMLC is used for products that need to be more robust and resilient (very few products actually use SLC) [13].

HARD DISKS

Despite advances in Solid State Memory technologies, Hard Disk Drives (HDD) are still the largest (in terms of memory) and are the cheapest storage devices available. Unlike all the previous memory devices we saw, which have no moving parts, HDDs use a spinning magnetic disc to store information.

Hard Disk Tracks and Sectors [23].

An HDD is made up of two main components: A magnetic disc and an arm. The magnetic disc contains tracks which are further divided into sectors. The sectors are further divided into domains. Each domain can be either magnetized or demagnetized to represent a bit [14].

Surface of a HDD under a microscope [22].

To save data, domains are magnetized using a magnetized pin on the end of the arm head. To read data, the arm head moves over the disk and gets either attracted or deflected from it. This motion is turned into bits.

I think that the wonderful thing about this technology is just how precise the motor controlling the arm needs to be. The arm head often moves at speeds of up to 15,000 RPM and may be present at distance as small as a few nanometers above the disc [15]. Voice coils, which can be easily controlled and are not affected by temperature changes, are used to achieve such precision.

However, this also means that even small dust particles can cause the arm head to move out of place resulting in a disk crash. Moreover, disk capacity is often increased, not by adding more discs but by packing more tracks into the same area. This may increase the likelihood of a disk crash as the arm head will need to move much closer to the disk surface.

IN CONCLUSION,

This was just meant to be an article that tells you about how different kinds of memory devices are implemented. I know that I have not mentioned a lot of devices, like the CD, floppy disc and registers [7] which paved the way for the devices we have now. Moreover, I have just touched up on the basics of how memory is stored, because there are so many tiny details and systems in these devices that explaining all of them will probably require me to write a book. I have mentioned some links in the reference section that you can check out if you want to know more details about them.

If you liked this article please follow me and give me a clap…or two…or 40. If you didn’t then I would love to hear your feedback!

You can follow me on twitter (@csoham358) also read some of my other articles here

REFERENCES

[1] https://mechanical-sympathy.blogspot.com/2013/02/cpu-cache-flushing-fallacy.html

[2] https://superuser.com/questions/724504/processors-cache-l1-l2-and-l3-are-all-made-of-sram

[3] https://en.wikipedia.org/wiki/Static_random-access_memory#Design

[4] https://www.electronics-notes.com/articles/electronic_components/semiconductor-ic-memory/sdram-synchronous-dram-what-is.php

[5]How to use SDRAMs in FPGAs — https://alchitry.com/blogs/tutorials/sdram-verilog

[6] https://www.electronics-notes.com/articles/electronic_components/semiconductor-ic-memory/sdram-synchronous-dram-what-is.php

[7] https://electronics.stackexchange.com/questions/275832/how-do-registers-work-in-a-cpu

[8] NAND and NOR flash performance comparisons — https://www.edn.com/design/systems-design/4321127/What-is-the-difference-between-NAND-and-NOR-Flash-

[9] How NAND and NOR memory works — http://www.iue.tuwien.ac.at/phd/windbacher/node14.html

[10] https://howflashdriveworks.wordpress.com/how-does-flash-drive-work/

[11] https://www.quora.com/How-does-a-flash-drive-pen-drive-store-data

[12] http://forums.sandisk.com/t5/All-SanDisk-USB-Flash-Drives/How-to-know-which-SanDisk-flash-drives-use-MLC-NAND-and-which/td-p/353259

[13] https://www.mydigitaldiscount.com/everything-you-need-to-know-about-slc-mlc-and-tlc-nand-flash.html

[14] http://www.adrc.com/ckr/hddworks.html

[15] https://www.bleepingcomputer.com/tutorials/how-hard-drives-work/

[16] Another great discussion of the evolution of memory devices with many graphs showing the decrease in the prices of memory for a lot of devices — https://hblok.net/blog/posts/tag/ssd/

[17] An amazing article by Peter Norvig — http://norvig.com/21-days.html#answers

[18] Great Explanation of how Reading and Writing to a 6T SRAM works — https://allthingsvlsi.wordpress.com/2013/04/19/6t-sram-operation/

[19] Difference between DRAM and SRAM — http://qr.ae/TUN73k

[20] How so much memory is fit in a small SD card — https://electronics.stackexchange.com/questions/14055/how-can-so-many-memory-cells-fit-on-microsd-card

[21] White paper analysing MLC and SLC flash memory — https://www.touchdynamic.com/pdf/SLC_vs_MLC.pdf

[22] https://www.texaspowerfulsmart.com/atomic-force/nfmm-characterization-of-magnetic-domains.html

[23] https://www.datarecovery.net/articles/hard-drive-sector-damage.aspx

--

--