Embedded Systems Memory - Volatile vs Non-Volatile, DRAM vs SRAM, ROM vs PROM vs EPROM vs EEPROM vs Flash, etcStarted by 1 year ago●7 replies●latest reply 1 year ago●1542 views
This new #FAQ is meant to help readers demystify different types of memory used within Embedded Systems and maybe gain a decent understanding of when and why to use certain kind of memories, the pros and cons, etc.
Your contribution to making this a great place for people to learn about the different types of memory for Embedded Systems could earn you some money as $150 will be divided between the authors of the most appreciated posts, based on the number of thumbs-ups awarded by the community.
And in case you forgot, images are supported by this forum platform so please feel free to add images that would support your text.
As always, thanks so much for your participation!
During early days of microcontrollers we had only RAM and ROM, RAM: random access memory, that is volatile while ROM: read only memory, that is non volatile, and the method to create ROM was either OTP, that is one time programmable or UVEPROM: Ultra violet erasable programmable read only memory, that is we can erase using ultraviolet light and we can re program the ROM. The UVEPROM comes with a optically transparent top, and we had a gadget called eraser, where we can place the UVEPROMS and expose them for 5 minutes to erase, (all memory locations were set to 1's) and then another gadget to program those erased UVEPROMS.
The next was EEPROM, electrically erasable programmable read only memory, where the program voltage was different and using voltage was different, and in our circuits we had to switch to different voltage to erase and write the program, and come back to use the memory as ROM. The EEPROM has an advantage that you can write single byte. Internally it will go through an erase cycle and then write cycle. Nowadays you get EEPROM which can work at single voltage for both programming and reading.
For embedded products we had a device called PROM, programmable read only memory, (also called as OTP ROM, one time programmable read only memory) which can be programmed once and then use it in the system. This had programming facility either can be used in circuit, or can be got as pre programmed from factory and just assemble in the product.
The next was flash, a technology which revolutionized the embedded products, where you can use the same voltage for erasing, programming and reading. In flash memories the erase size is larger than programming size, and you should erase before writing. Erase would take more time than to program, and programming size is also higher, (even though you can program a single byte/word, it is better to program in specified size.
The embedded products demand gave rise to two kinds of flashes: NOR FLASH and NAND FLASH. NOR flash is common with ROM, EEPROM etc.., where you can integrate it with controller and it acts as memory on system bus and we can have XIP programs (execute in place) that can be programmed and used. Nowadays NOR flash is available with burst capability to match with SDRAMs and DDRAMs
NAND FLASH is another technology where the density is more, but this does not integrate as NOR flash to system bus, it can have block read, block write and block erase, and can simulate a disk drive. This has given rise to Compact flash, MMC cards, SD cards, USB pen drives, SSHD drives. Here each block can be read as reading blocks in disk drives, and for writing it has to be erased and written, and once again erase block size is higher than (usually 16 - 32 times) write block size. Also the NAND flash has some more area wherein you can place information such as CRC (cyclic redundancy code), ECC (error correction code), through which you can keep the integrity of data.
Regarding RAM, it comes in basically two flavours, SRAM: Static RAM, where density is low but can be integrated to system so that data can be accessed in single read/ write cycle. The time to read will be same as time to write, and you can place code / data / stack / heap on to this.
The SRAM posed limitation to he size and hence gave way to evolve DRAM Dynamic RAM. In Dram the density was high, but to achieve this the circuit could retain the data for only a finite amount of time (hence the term dynamic). It has to be periodically refreshed. Earlier days Z80 controller had a special interrupt driven code with pop's which use to periodically refresh the memory. SRAM also come with a very low power version where you can make it with battery back up and does not loose data during power cycles and virtually can act as ROM.
The DRAM technology evolved in a different way, SDRAM, Synchronous DRAM, which was an great evolution where memory reads and writes can be done in bursts to enhance the throughput, and they matched the cache lines of CPU to have burst reads and writes to optimize the performance. The speed of this was enhanced to DDR, double data rate DRAM, DDR2, twice the double data rate, DDR3, 4 times DDR, etc.. and this lead to make CPU coupled to memory (and also display) through high speed circuit (called as North Bridge). There are also display specific DDRs which integrates with both CPU and display in a special way to enhance the performance.
It will be incomplete if we do not mention about Cache memory. Cache memory is that which interfaces with CPU and performs at the same speed towards CPU side and do the burst transfers towards the main memory. There are two types of caches I-cache, instruction cache where program counter of CPU refers, and D-cache data cache where the data / stack / heap refers. Also there are several levels of caches, and the first or even second level cache will be integrated in the silicon itself.
The memory is still evolving and racing with CPU in its speed /density. Also it is evolving in storage sector.
Talking about caches it should not be forgotten that those memories are fast not only because they are operated at the tremendously high core frequency but also because they are not addressed normally. Caches are using associative memory, i.e. memory which is addressed via content: Part of the address is stored in the cache line and the cache returns the info if there is a line with that address (and also the content of that line) within a single cycle. That's why caches are so small: It's expensive to have that type of memory on your die since it consumes quite a lot of die area.
Howdy, I came up through developing Z80 w/OTP PROM. Expensive, and made jumping to Freescale w/flash worth the learning curve. Ok, here's my take:
Dynamic RAM: cheap temporary powered up storage, still the best bit/$.
Static RAM: More expensive powered up storage. Was originally battery backed for non-volatile storage. An advantage now negated by flash.
Some will bring up cosmic ray sensitivity based on cell size, I'll leave that to the boffins who design this stuff.
ROM: the "original, code in stone" tech: send hex file (s16 or...) to mfg. They build the mask to set this code directly in chip production. Very Expensive, Very Costly to edit (Thou SHALL HAVE GOLD CODE before submission)
EPROM: old tech required UV-B to erase (a week of summer sunlight works too), also slow and a major PITA to deal with. Only legacy stuff now (thank your favorite deity).
EEPROM: the predecessor of flash: works Very Much same, but erase / write characteristics somewhat->very different (pends gen of flash).
Flash: latest & best yet: burn it, use it, erase & burn again ... Wonderful. Recent uCs can burn parms onto local flash, Very Handy.
PS: For the poster of space project: use flash for as long as possible Then have swre/hdwe that copies flash into PROM. But, I'll offer that a RAID build of flash would give the radiation hardness yet allow code mods. You could build in checkpoint as well as end to end verification/rebuilds. Some math/stat genius can figure out how many copies, checkpoints, verify periodicity, etc to have xx% confidence in code integrity. Not saying DO, just an idea... <<<)))
Some comments on CustomSarge's post.
When doing your custom die ROM has a big size advantage over RAM. Less area consumed for the same memory size means less die size means less $$$. ROM also normally has a lower current consumption, yet another advantage. Of course this applies only for mass market products where you do your own dies.
Working with ROM might cause additional FW efforts, though. Since ROM contents cannot be changed and you likely do not have that gold code quality when the ROM content must be delivered to the fab you should design some patching mechanism (e.g. use a list of function pointers in RAM for function calls originating inside ROM, allowing you to modify the jump target with later builds). Also don't underestimate debug overhead since you will end up with 2 images: 1 image for the ROM and another for the RAM part of your firmware.
Flash is "latest & best" maybe in many places where volatility is a no-go. However, due to the limited number of erase/write cycles you cannot use it as a replacement for RAM (i.e. for storing stack/heap/global variables).The list of memory technologies is not complete. There have been quite a few approaches to do non-volatile memory allowing infinite write cycles and access times comparable to RAM, however, they never made it to the masses. Think of MRAM, FRAM, phase change RAM, ...
tangential to the base memory technology, but:
Something I often run across when called in to "fix" an existing product is a lack of care in the way parameters are stored in flash. This can lead to gibberish params restored, often bricking the device.
- always cover the params area with at least a simple checksum or hash.
- always validate params on restore.
- If you can, have two param areas (observing the above rules) and only zorch the 'old' area after you've verified the new area.
Great subject and looking to follow up with the responses. One important point with using a PROM is the requirement to commit to a design early in your project flow. Currently working a space project and one board uses a PROM as part of the boot process. This is a great choice for space due to radiation tolerance, however committing to the PROM design is required earlier since they are incorporated onto the PCB. Having a radiation hardened solution that is re-programmable would alleviate schedule pressure and allow for more design flexibility as the requirements mature.
I would like to throw something in about selecting the right memory for a design, because the topic was named as “when and why to use certain kind of memories, the pros and cons, etc.”
We are a distributor specializing in the supply of memory-components, carrying over 20 different manufacturers. We do nothing but DRAM, SRAM and Flash business since over 27 years now. Our customer base is mainly in the embedded/industrial markets and we serve them from 12 offices worldwide.
The majority of customers is trying to find the memory for their applications on their own, simply because they do not expect that a distributor could be of any help for them. Well, for the most part this is true, because the majority of distributors are broadliners, having all kinds of electronic components, but of each product-type they carry just one or two manufacturers. A distributor carrying many different products can hardly have a special knowledge about memory. And with only one or two manufacturers on his linecard, the broadline-distributor can impossibly say if there are multiple second sources for the required product.
As a consequence, the board-designers decide to use the same components as they see on reference-design-boards, or they look up the websites of the big manufacturers like Samsung or Micron to find memories which match their demands.
Some time later, these customers often run into EOL situations or shortages and get stuck. And even if there is no “real problem”, these customers will never really know if there would be better solutions at lower prices, with less-frequent version-changes and no risk of being single-sourced.
One day these customers might eventually find our company, Memphis Electronic. We will then open up all the possible alternative memories that exist, show them the different prices, availabilities, longevities, name the advantages or known troubles of certain manufacturers and eventually even suggest a redesign to optimize the cost and availability.
We see a trend in the last years showing that especially the big manufacturers are often letting their smaller customers down. Suddenly leadtimes explode are “undefined”, parts might get discontinued without replacement, certain variations of part numbers are taken off the production line, or the manufacturers reserve the right to adapt the price upon delivery.
Interesting enough, there are still so many customers accepting this behavior, although there are numerous other manufacturers that are maybe less “nameful”, who have fast deliveries, much less revision changes or EOLs and guaranteed fixed pricing.
What I am trying to say is that the memory-market seems to be changing from the supplier-side. The big manufacturers have moved their focus to supply mainly super-large-volume customers making smartphones, tablets, IOT-devices or PC/laptop/servers. In parallel, the high-mix/low-volume embedded/industrial customers are running into more and more troubles as they still have not realized that they would be better off to change to smaller memory-suppliers which fit much better to their demands.
Also the new memory-technologies are making things difficult nowadays. For example let’s name DDR4 and LPDDR4 memory. These two memory technologies are being produced only by the 3 largest manufacturers in very huge quantity especially for the mobile and computing markets. However, Embedded/Industrial customers try to follow the same trend and use the same memory technologies. But they notice short supplies. Why is that?
Well, if you were a memory-manufacturer and had customers buying a billion “consumer grade” DDR4 or LPDDR4 off you, always the same without any special wishes, with very regular forecast and demand, would you then really be interested to also serve industrial customers with their high-mix/low volume demands without guaranteed stable®ular purchase, wishes for highest quality, lots of service-questions, special requirements like for full industrial temperature ranges, always "urgent" deliveries, etc? Sure not! It is so much easier to concentrate on serving a handful of high-volume customers.
Now let's look at the smaller manufacturers of DRAM and Flash components. It is difficult for them to keep up with the pace of the technology-trends, simply because modern memory-manufacturing-technologies no longer cost millions of dollars to produce, but billions! Smaller manufacturers can not afford such development-expenses. If customers need DRAMs with 8Gb or higher density, Multi-Chip-Packaged DRAM+Flash combos, or high-capacity Flash components, they will not find these at smaller memory manufacturers.
But what shall the smaller customers do when they need memory? Well, maybe the solution is to try to make new designs based on mature technologies that are mass produced by many manufacturers instead of trying to look for the newest parts.
And if these mature products are accepted to be used in the design, then look around for smaller manufacturers, because these will for sure have a lot better supply!
Especially the term "longevity" becomes reality with smaller manufacturers, for the simple reason that they can not afford to shrink the chip-designs to new processes as quickly as the big manufacturers do.
While the large memory-manufacturers tend to EOL all devices that they can not sell in large quantity. Another strategy, used by one of the big DRAM-makers, is to keep the price for the legacy devices extremely high and then delay shipments until enough orders have been collected to do one bigger production run. Most customers do not even notice that the prices from this manufacturer are ridiculously high as they trust that a big memory manufacturer would always be the best supplier ;-)
My company, Memphis Electronic helps customers to “open the box of Pandora” of the variety of different memory components and manufacturers available on the market. Our goal is to pave the way to hazzle-free long-term-availability and supply. If you feel that my long message fits to your experience, get in touch with us!