Some understanding of memory hardware: Difference between revisions

From Helpful
Jump to navigation Jump to search
(Created page with "{{computer hardware}} [https://people.freebsd.org/~lstewart/articles/cpumemory.pdf "What Every Programmer Should Know About Memory"] is a good overview of memory architectures, RAM types, reasons bandwidth and access speeds vary. ==RAM types== '''DRAM''' - Dynamic RAM : lower component count per cell than most (transistor+capacitor mainly), so high-density and cheaper : yet capacitor leakage means this has to be refreshed regularly, meaning a DRAM controller, more...")
 
 
(16 intermediate revisions by the same user not shown)
Line 6: Line 6:


==RAM types==
==RAM types==
{{stub}}


'''DRAM''' - Dynamic RAM  
'''DRAM''' - Dynamic RAM  
: lower component count per cell than most (transistor+capacitor mainly), so high-density and cheaper
: lower component count per cell than most (transistor+capacitor mainly), so high-density and cheaper per storage size
: yet capacitor leakage means this has to be refreshed regularly, meaning a DRAM controller, more complexity and higher latency than some
: yet capacitor leakage means it forgets its state, so this has to be refreshed regularly,  
: (...which can be alleviated and is less of an issue when you have multiple chips)
: also meaning you need a DRAM controller, more complexity (not something you'd DIY), and higher latency than some
: (...some latency is less of an issue when you have multiple chips)
: this or a variant is typical as main RAM, due to low cost per bit
: this or a variant is typical as main RAM, due to low cost per bit


Line 17: Line 20:
: ...that of coordinating the DRAM via an external clock signal (previous DRAM was asynchronous, manipulating state as soon as lines changed)  
: ...that of coordinating the DRAM via an external clock signal (previous DRAM was asynchronous, manipulating state as soon as lines changed)  
: This allows the interface to that RAM to be a predictable state machine, which allows easier buffering, and easier interleaving of internal banks
: This allows the interface to that RAM to be a predictable state machine, which allows easier buffering, and easier interleaving of internal banks
: ...and thereby higher data rates (though not necessarily lower latency)
: which makes higher data rates a bunch simpler (though not necessarily lower latency)
: SDR/DDR:
: SDR/DDR:
:: DDR doubled busrate by widening the (minimum) units they read/write (double that of SDR), which they can do from single DRAM bank{{verify}}
:: DDR doubled busrate by widening the (minimum) units they read/write (double that of SDR), which they can do from single DRAM bank{{verify}}
:: similarly, DDR2 is 4x larger units than SDR and DDR3 is 8x larger units than SDR
:: similarly, DDR2 is 4x larger units than SDR and DDR3 is 8x larger units than SDR
:: DDR4 uses the same width as DDR3, instead doubling the busrate by interleaving from banks
:: DDR4 uses the same width as DDR3, instead doubling the bus rate by interleaving from banks
:: unrelated to latency, it's just that the bus frequency also increased over time.
:: unrelated to latency, it's just that the bus frequency also increased over time.


 
<!--
'''Graphics RAM''' refers to varied specialized
'''Graphics RAM''' is less of a type and more of a design specialization
: Earlier versions would e.g. allow reads and writes (almost) in parallel, making for lower-latency framebuffers
: Earlier versions would e.g. allow reads and writes (almost) in parallel, making for lower-latency framebuffers
: "GDDR" is a somwhat specialized form of DDR SDRAM
: "GDDR" is a somewhat specialized form of DDR SDRAM
 
-->




Line 36: Line 39:
: Retains state as long as power is applied to the chip, no need for refresh, also making it a little lower-latency
: Retains state as long as power is applied to the chip, no need for refresh, also making it a little lower-latency
: no external controller, so simpler to use
: no external controller, so simpler to use
: the higher component count per cell makes it more expensive per storage size
: e.g used in caches, due to speed, and acceptable cost for lower amounts
: e.g used in caches, due to speed, and acceptable cost for lower amounts




'''PSRAM''' - PseudoStatic RAM
'''PSRAM''' - PseudoStatic RAM
: A tradeoff somewhere between SRAM and DRAM
: A design tradeoff, somewhere between SRAM and DRAM
: in that it's DRAM with built-in refresh, so functionally it's as standalone as SRAM and slower but you can have a bunch more of it for the same price - e.g. SRAM tends to
:: its like DRAM with built-in refresh, so functionally it's as "don't think about it" as SRAM
: (yes, DRAM can have built-in refresh, but that's often points a ''sleep'' mode that retains state without requiring an active DRAM controller)
::: (yes, DRAM technically can have built-in refresh, but that's often points a ''sleep'' mode that retains state without requiring an active DRAM controller, not something for active use)
:: it's slower than DRAM, and cheaper than SRAM
: SRAM makes sense for internal RAM, PSRAM makes sense for extended RAM in situations DRAM is not necessary






<!--
'''Non-volatile RAM'''
'''Non-volatile RAM'''


The concept of Random Access Memory (RAM) '''only''' tells you that you can access any part of it with similar ease (contasted with e.g. tape storage, where more distance meant more time, so more storage meant more time).
While the concept of Random Access Memory (RAM) '''only''' tells you that you can access any part of it with comparable ease (contasted with e.g. tape storage, where more distance meant more time, so more storage meant more time)...


Yet we tend to think about RAM as volatile, as entirely temporary scratchpad, only useful as an intermediate between storage and use.
...we tend to think about RAM as volatile, only useful as an intermediate scratchpad between storage and use, and will lose its contents as soon as it is unpowered. Probably because the commonly chosen designs have that property.
This is perhaps because the simplest designs (and thereby cheapest per byte) have that property.
For example, DRAM loses its charge and has to be constantly and actively refreshed, DRAM and SRAM and many others lose their state once you remove power.
(There are also exceptions and inbetweeens, like DRAM that doesn't need its own controller and can be told to refresh itself in a low-power mode, acting a whole lot like SRAM).




Yet there are various designs that are both easily accessible ''and'' keep their state.
Yet there are various designs that are both easily accessible ''and'' keep their state.


It's actually a gliding scale of various properties.
And there is a gliding scale of ''various'' properties in that area as well.
We may well call it NVM (non-volatile memory), when grouping a lot of them and don't yet care about further properties - like how often we may read or write or how difficult that is. Say, some variants of EEPROM aren't the easiest to deal with, and consider that Flash, now very common and quite convenient, is a development from EEPROM.


When we talk about NVRAM rather than NVM when we are often pointing at more specific designs,
often where we can fairly easily use it and it happens to stick around,
like in FRAM, MRAM, and PRAM, or nvSRAM or even BBSRAM.


We may well call it NVM (non-volatile memory) when we haven't yet gotten to some more specific properties,
like how often we may read or write, or how difficult that is.


FRAM - Ferroelectric RAM, which resembles DRAM but uses a ferroelectric material,
Say, some variants of EEPROM aren't the easiest to deal with.
: easier to access than Flash
We like Flash more, even though it's basically a development from EEPROM.
: seems to have a read limit rather than a write limit?, but that limit is also something like 1E14 and you are ''unlikely'' to use it so intensely to reach that any time soon.  
But both wear out.
: so it's great for things like constant logging, which would be terrible for Flash
https://electronics.stackexchange.com/questions/58297/whats-the-catch-with-fram


NVRAM on the other hand tends to be easier, more reisable, like FRAM, MRAM, and PRAM, or nvSRAM or even BBSRAM.




nvSRAM - SRAM and EEPROM stuck on the same chip.
 
'''nvSRAM''' - SRAM and EEPROM stuck on the same chip.
: seems intended as a practical improvement on BBSRAM
: and/or a "access common stuff quickly, occasionally write a chunk to EEPROM" style of data logging, black boxes, that sort of thing
: https://en.wikipedia.org/wiki/NvSRAM
: https://en.wikipedia.org/wiki/NvSRAM




BBSRAM - Battery Backed SRAM  
'''BBSRAM''' - Battery Backed SRAM  
: basically just SRAM ''alongside'' a lithium battery
: basically just SRAM ''alongside'' a lithium battery, so that it'll live a good while
: feels like cheating, but usefully so.
: is sort of cheating, but usefully so.
 
 
 
'''FRAM''' - Ferroelectric RAM
: functions more like flash, also limited in amount of use (but with many more cycles)
: read process is destructive (like e.g DRAM), so you need a write-after-read to keep data around
: so it's great for things like round-robin logging (which would be pretty bad for Flash)
: https://electronics.stackexchange.com/questions/58297/whats-the-catch-with-fram
 
 
'''PRAM'''
: https://en.wikipedia.org/wiki/Phase-change_memory


-->






===Memory stick types===
===DRAM stick types===
{{stub}}
{{stub}}




'''ECC RAM'''
'''ECC RAM''' ('Error correction code')
: can detect many (and correct some) hardware errors in RAM  
: can detect many (and correct some) hardware errors in RAM  
: The rate of of bit-flips is low, but will happen. If your computations or data are very important to you, you want ECC.
: The rate of of bit-flips is low, but will happen. If your computations or data are very important to you, you want ECC rather than the regular, non-ECC type.
: See also:
: See also:
:: http://en.wikipedia.org/wiki/ECC_memory
:: http://en.wikipedia.org/wiki/ECC_memory
Line 128: Line 140:




 
<!--


On pin count
On pin count
Line 137: Line 149:
: ECC RAM has the same pin count
: ECC RAM has the same pin count


-->


In any case, the type of memory must be supported by the memory controller
In any case, the type of memory must be supported by the memory controller
Line 146: Line 159:
Historically, RAM controllers were a thing on the motherboard near the CPU, while there are now various cases where the controller is on the CPU.
Historically, RAM controllers were a thing on the motherboard near the CPU, while there are now various cases where the controller is on the CPU.


==More on DRAM versus SRAM==
==More on...==
 
===DRAM versus SRAM===
{{stub}}
{{stub}}
<!--
<!--
'''Dynamic RAM (DRAM)''' cells are a transistor and capacitor, much simpler than various other types of RAM.
'''Dynamic RAM (DRAM)''' cells are a transistor and capacitor, much simpler than various other types of RAM.
Line 355: Line 369:
-->
-->


==On ECC==
===ECC===
<!--
<!--


Line 403: Line 417:
-->
-->


==Buffered/registered RAM==
===Buffered/registered RAM===
<!--
<!--
This is mainly a detail of motherboard (and CPU) design.
This is mainly a detail of motherboard (and CPU) design.
Line 429: Line 443:
: often implies UV-EEPROM, erased with UV shone through a quartz window.
: often implies UV-EEPROM, erased with UV shone through a quartz window.


EEPROM's extra E means Electrically Eresable
EEPROM's extra E means Electrically Erasable
: meaning it's now a command.
: meaning it's now a command.
: early EEPROM read, wrote, and erased {{verify}} a single byte at a time. Modern EEPROM can work in alrger chunks.
: early EEPROM read, wrote, and erased {{verify}} a single byte at a time. Modern EEPROM can work in larger chunks.
: you only get a limited amount of erases (much like Flash. Flash is arguably just an evolution of EEPROM)
: you only get a limited amount of erases (much like Flash. Flash is arguably just an evolution of EEPROM)


Line 457: Line 471:
The name came from marketing, helping to distinguish it as its own thing with its own properties.
The name came from marketing, helping to distinguish it as its own thing with its own properties.


Like EEPROM, Flash is non-volatile, erases somewhat slowly, and has a limited number of erase cycles.


Like EEPROM, Flash is non-volatile,  has a limited number of erase cycles, and isn't the ''fastest'' to erase --


One difference is making it erasable in chunks (smaller than erase-fully variants, larger than erase-bytes variants),
...yet arguably, "Flash memory" just means EEPROM that has block-level (or device-level) erase,
making them faster to bulk-erase (so easier and faster to write) than the erase-bytes kind,
a tradeoff that helps speed, cost, and use for random-storage needs.
a tradeoff that helps speed, cost, and use for random-storage needs.




Simpler memory cards, and simpler USB sticks, have one flash chip and a simple controller, which is the cheapest setup and why they don't tend to break 10MB/s,
Simpler memory cards, and simpler USB sticks, have one flash chip and a simple controller,
which is the cheapest setup and why they don't tend to break 10MB/s,
and don't have enough wear leveling to last very long.  
and don't have enough wear leveling to last very long.  


SSDs go faster
SSDs are ''made of flash'', but  
partly because they parallelize to more chips (RAID-like layout), and
* are what you might call managed flash.
partly because of an extra layer of management that (in most practical use) hides Flash's relatively slow erase speed (by doing it at other times, not when it's needed, a plan that usually works but may not under heavy load).


-->
* go faster partly because they interleave/parallelize to multiple chips ([[RAID]]-like layout),
: this also actually hides Flash's relatively slow erase speed (by doing it at other times, not when it's needed, a plan that usually works but may not under heavy load) and certain edge cases


<!--


There are two types of Flash, NOR and NAND, named for the cells resembling (and working like) classical logic gates.
There are two types of Flash, NOR and NAND, named for the cells resembling (and working like) classical logic gates.
Line 479: Line 494:
Very roughly,  
Very roughly,  
NOR is faster but more expensive so has a few specialist uses,
NOR is faster but more expensive so has a few specialist uses,
NAND is denser, slower, and takes less power, is typically more useful and cheaper for bulk storage.  
NAND is denser, slower, and takes less power, is typically more useful and cheaper for bulk storage.




Line 528: Line 543:
-->
-->


==PRAM==
==Flash, eMMC, UFS==
<!--
 
as mentioned, Flash is essentially a development upon EEPROM


<!--
 
https://en.wikipedia.org/wiki/Phase-change_memory
'managed flash' is one name you could give
to putting a controller in front that does some amount of extra work.
How complex that is varies, though.
 
 
Worth mentioning is eMMC, basically a flash chip meant for internal use, that happens to be built on MMC. It was in common use for internal storage in phones and tables until it was displaced by UFS.
 
 
 
"Are SD cards, USB flash drives managed flash?"
 
 
 
(eUSB is Embedded, USB-connected flash. It's not un
 
 
 
*Capacity Dependent
 
 
 
 
In principle, eMMC and UFS are both managed (NAND) Flash,
eMMC communication was scaled up from its origins.
 
UFS communication is more modern, modeled off SCSI,
 
 
For microcontrollers, both eMMC and UFS are nontrivial to interface
if there isn't an existing interface, and you may prefer (micro)SD for now
(most of which still support SPI, which was dropped from eMMC, despite shared origins),
or use a platform that ''already'' interfaces with on-board whatever-it-is (probably eMMC, e.g. beagleboard).
 
 
https://community.silabs.com/s/article/emmc-and-why-it-is-not-a-suitable-microcontroller-storage-option?language=en_US
 
 
https://en.wikipedia.org/wiki/Universal_Flash_Storage
 
UFS is mostly known in its embedded form (eUFS)
: there are also UFS memory cards, but they are not (yet?) common


-->
-->

Latest revision as of 23:37, 30 March 2024

The lower-level parts of computers

General: Computer power consumption · Computer noises

Memory: Some understanding of memory hardware · CPU cache · Flash memory · Virtual memory · Memory mapped IO and files · RAM disk · Memory limits on 32-bit and 64-bit machines

Related: Network wiring notes - Power over Ethernet · 19" rack sizes

Unsorted: GPU, GPGPU, OpenCL, CUDA notes · Computer booting



"What Every Programmer Should Know About Memory" is a good overview of memory architectures, RAM types, reasons bandwidth and access speeds vary.


RAM types

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.


DRAM - Dynamic RAM

lower component count per cell than most (transistor+capacitor mainly), so high-density and cheaper per storage size
yet capacitor leakage means it forgets its state, so this has to be refreshed regularly,
also meaning you need a DRAM controller, more complexity (not something you'd DIY), and higher latency than some
(...some latency is less of an issue when you have multiple chips)
this or a variant is typical as main RAM, due to low cost per bit


SDRAM - Synchronous DRAM - is mostly a practical design consideration

...that of coordinating the DRAM via an external clock signal (previous DRAM was asynchronous, manipulating state as soon as lines changed)
This allows the interface to that RAM to be a predictable state machine, which allows easier buffering, and easier interleaving of internal banks
which makes higher data rates a bunch simpler (though not necessarily lower latency)
SDR/DDR:
DDR doubled busrate by widening the (minimum) units they read/write (double that of SDR), which they can do from single DRAM bank(verify)
similarly, DDR2 is 4x larger units than SDR and DDR3 is 8x larger units than SDR
DDR4 uses the same width as DDR3, instead doubling the bus rate by interleaving from banks
unrelated to latency, it's just that the bus frequency also increased over time.



SRAM - Static RAM

Has a higher component count per cell (6 transistors) than e.g. DRAM
Retains state as long as power is applied to the chip, no need for refresh, also making it a little lower-latency
no external controller, so simpler to use
the higher component count per cell makes it more expensive per storage size
e.g used in caches, due to speed, and acceptable cost for lower amounts


PSRAM - PseudoStatic RAM

A design tradeoff, somewhere between SRAM and DRAM
its like DRAM with built-in refresh, so functionally it's as "don't think about it" as SRAM
(yes, DRAM technically can have built-in refresh, but that's often points a sleep mode that retains state without requiring an active DRAM controller, not something for active use)
it's slower than DRAM, and cheaper than SRAM
SRAM makes sense for internal RAM, PSRAM makes sense for extended RAM in situations DRAM is not necessary


Non-volatile RAM

While the concept of Random Access Memory (RAM) only tells you that you can access any part of it with comparable ease (contasted with e.g. tape storage, where more distance meant more time, so more storage meant more time)...

...we tend to think about RAM as volatile, only useful as an intermediate scratchpad between storage and use, and will lose its contents as soon as it is unpowered. Probably because the commonly chosen designs have that property.


Yet there are various designs that are both easily accessible and keep their state.

And there is a gliding scale of various properties in that area as well.


We may well call it NVM (non-volatile memory) when we haven't yet gotten to some more specific properties, like how often we may read or write, or how difficult that is.

Say, some variants of EEPROM aren't the easiest to deal with. We like Flash more, even though it's basically a development from EEPROM. But both wear out.

NVRAM on the other hand tends to be easier, more reisable, like FRAM, MRAM, and PRAM, or nvSRAM or even BBSRAM.


nvSRAM - SRAM and EEPROM stuck on the same chip.

seems intended as a practical improvement on BBSRAM
and/or a "access common stuff quickly, occasionally write a chunk to EEPROM" style of data logging, black boxes, that sort of thing
https://en.wikipedia.org/wiki/NvSRAM


BBSRAM - Battery Backed SRAM

basically just SRAM alongside a lithium battery, so that it'll live a good while
is sort of cheating, but usefully so.


FRAM - Ferroelectric RAM

functions more like flash, also limited in amount of use (but with many more cycles)
read process is destructive (like e.g DRAM), so you need a write-after-read to keep data around
so it's great for things like round-robin logging (which would be pretty bad for Flash)
https://electronics.stackexchange.com/questions/58297/whats-the-catch-with-fram


PRAM

https://en.wikipedia.org/wiki/Phase-change_memory



DRAM stick types

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.


ECC RAM ('Error correction code')

can detect many (and correct some) hardware errors in RAM
The rate of of bit-flips is low, but will happen. If your computations or data are very important to you, you want ECC rather than the regular, non-ECC type.
See also:
http://en.wikipedia.org/wiki/ECC_memory
DRAM Errors in the Wild: A Large-Scale Field Study


Registered RAM (sometimes buffered RAM) basically places a buffer on the DRAM modules (register as in hardware register)

offloads some electrical load from the main controller onto these buffers, making it easier to have designs more stably connect more individual memory sticks/chips.
...at a small latency hit
typical in servers, because they can accept more sticks
Must be supported by the memory controller, which means it is a motherboard design choice to go for registered RAM or not
pricier (more electronics, fewer units sold)
because of this correlation with server use, most registered RAM is specifically registered ECC RAM
yet there is also unregistered ECC, and registered non-ECC, which can be good options on specific designs of simpler servers and beefy workstations.
sometimes called RDIMM -- in the same context UDIMM is used to refer to unbuffered
https://en.wikipedia.org/wiki/Registered_memory

FB-DIMM, Fully Buffered DIMM

same intent as registered RAM - more stable sticks on one controller
the buffer is now between stick and controller [1] rather than on the stick
physically different pinout/notching


SO-DIMM (Small Outline DIMM)

Physically more compact. Used in laptops, some networking hardware, some Mini-ITX


EPP and XMP (Enhanced Performance Profile, Extreme Memory Profiles)

basically, one-click overclocking for RAM, by storing overclocked timing profiles
so you can configure faster timings (and Vdimm and such) according to the modules, rather than your trial and error
normally, memory timing is configured according to a table in the SPD, which are JEDEC-approved ratings and typically conservative.
EPP and XMP basically means running them as fast as they could go (and typically higher voltage)


In any case, the type of memory must be supported by the memory controller

DDR2/3/4 - physically won't fit
Note that while some controllers (e.g. those in CPUs) support two generations, a motherboard will typically have just one type of memory socket
registered or not
ECC or not

Historically, RAM controllers were a thing on the motherboard near the CPU, while there are now various cases where the controller is on the CPU.

More on...

DRAM versus SRAM

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

ECC

Buffered/registered RAM

EPROM, EEPROM, and variants

PROM is Programmable ROM

can be written exactly once

EPROM is Erasable Programmable ROM.

often implies UV-EEPROM, erased with UV shone through a quartz window.

EEPROM's extra E means Electrically Erasable

meaning it's now a command.
early EEPROM read, wrote, and erased (verify) a single byte at a time. Modern EEPROM can work in larger chunks.
you only get a limited amount of erases (much like Flash. Flash is arguably just an evolution of EEPROM)


Flash memory (intro)

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

Flash, eMMC, UFS