# Memory:
* Memory is an integral part of the embedded system.
    * Certain Embedded processors/controllers contain built in program memory and data
    memory and this memory is known as on-chip memory
    * Certain Embedded processors/controllers do not contain sufficient memory inside the
    chip and requires external memory called off-chip memory or external memory.
# Program Storage Memory :
   * Also called code storage memory.
   * Stores the program instructions.
   * It retains it contents even if after the power to it is turned off.
   * It is generally known as Non Volatile storage memory.
                                      Fig: Different types of Program Memory
Fig: Internal View of 8x4 ROM
# Masked ROM (MROM):
   * One-time programmable memory.
   * Uses hardwired technology for storing data.
   * The device is factory programmed by masking and metallization process.
   * The primary advantage of MROM is low cost for high volume production.
   * The limitation with MROM based firmware storage is the inability to modify the
   device firmware against firmware upgrades.
# Programmable ROM (PROM)/ (OTP):
   * It is not pre-programmed by the manufacturer.
   * The end user is responsible for Programming these devices.
       -   user provides file of desired contents of ROM
       -   file input to machine called ROM programmer
       -   each programmable connection is a fuse
       -   ROM programmer blows fuses where connections should not exist
   * Very low write ability
   * Very high storage permanence
# Erasable Programmable ROM (EPROM):
# Electrically Erasable Programmable Read Only Memory (EEPROM):
   *
# FLASH Memory:
   *
   # Principle of data storage in Flash Memory:
* A flash cell stores the data by removing or putting electrons on
  its floating gate.
* When electrons are present on the floating gate, no current
 flows through the transistor. This denotes a ‘0’.
* When electrons are removed from the floating gate, the
 transistor starts conducting, indicating a ‘1’.
* Applying of voltages between the control gate and source or drain
 will decide the presence and absence of electrons in floating gate.
* There are two types of flash memory: the NOR flash developed by
 Intel and NAND flash, which originated from Toshiba technology.
* The names, NOR-flash and NAND-flash, came from the structure
 used for the interconnections between memory cells
                                                                       Fig: A Flash Memory Cell
* In NOR-flash, cells are connected in parallel to the bit lines facilitating the reading/writing/erasing of each
   cell individually.
* This parallel connection is similar to the parallel connection of transistors in a CMOS NOR array, and hence
  the name ‘NOR flash’.
* In contrast, cells in a NAND flash are connected in series.
* This difference is the reason for differences in the way of usage and the application domain of the two types of cells.
* NOR flash is relatively higher speed (than NAND), and here random access is possible such that data can be read
  or written in quantities as small as a byte.
* NAND flash, on the other hand, does sequential access and can read or write only as blocks.
* NOR flash is used in applications where data needs to be randomly accessed, so it is used to store BIOS in PCs and
  operating systems in mobile phones.
* NAND flash finds use in applications where data is sequentially stored and retrieved, that is, for data storage in
 digital cameras, mobile phones, MP3 players, USB memory sticks, etc.
              NAND Flash                                                         NOR Flash
    # Read-Write Memory / Random Access Memory (RAM):
*
# Read-Write Memory Classification:
   * RAM is the data memory or working memory of the controller/processor.
   * RAM is a direct access memory, meaning we can access the desired memory location
   directly without the need for traversing through the entire memory locations to reach the
   desired memory position
                                  Fig: Classification of Read-Write Memory
# Static RAM (SRAM):
 * Memory cell uses flip-flop to store bit. And holds data as long as power supplied.
 * The content is hold in terms of voltage and therefore it is static, which does not change over time.
 * In typical implementation, an SRAM cell (bit) is realized using
  6 transistors ( 6 MOSFETs).
 * Four of the transistors are used for building the latch (flip-flop)
  part of the memory cell and 2 for controlling the access.
 * Static RAM is the fastest form of RAM available.
                  Fig: SRAM cell storing one bit
# Dynamic RAM (DRAM):
  * Memory cell uses MOS transistor and capacitor to store bit.
  * It is more compact than SRAM. Therefore, DRAM have high density and low cost compared to
  SRAM.
  * The disadvantage is that since the information is stored as charge it gets leaked off with time
  and to prevent this they need to be refreshed periodically.
  * Special circuits called DRAM controllers are used for the refreshing operation. The refresh
  operation is done periodically in milliseconds interval.
  * Slower to access than SRAM.
      Fig: A DRAM cell
*
    Fig: Basic DRAM Architecture
Fig: Internal Diagram of DRAM Chip
# Non Volatile RAM (NVRAM):
   * Holds data after external power removed.
   * Battery-backed RAM
      - SRAM with own permanently connected battery.
      - writes as fast as reads.
      - no limit on number of writes unlike nonvolatile ROM-based memory
   * SRAM with EEPROM or flash
      - stores complete RAM contents on EEPROM or flash before power turned off.
# Memory Shadowing:
  * Generally the execution of a program or a confi guration from a Read Only Memory (ROM) is very slow
   (120 to 200 ns) compared to the execution from a random access memory (40 to 70 ns).
  * Shadowing of memory is a technique adopted to solve the execution speed problem in processor-based
   systems.
  * In computer systems, there will be a configuration holding ROM called BIOS.
  * BIOS stores the hardware configuration information like the address assigned for various serial ports , etc.
  * In memory shadowing, a RAM is included behind the logical layer of BIOS at its same address as a shadow to
   the BIOS.
  * The first step that happens during the boot up is copying the BIOS to the shadowed RAM.
  * Then write protecting the RAM and then disabling the BIOS reading.
  * It is performed for achieving the high system performance.
# Memory Selection for Embedded System:
   * Selection of suitable memory is very much essential step in high performance applications,
    because the challenges and limitations of the system performance are often
    decided upon the type of memory architecture.
   * Systems memory requirement depend primarily on the nature of the application that is
   planned to run on the system.
   * Memory performance and capacity requirement for low cost systems are small, whereas
   memory throughput can be the most critical requirement in a complex, high performance
   system.
   * Following are the factors that are to be considered while selecting the memory devices:
        -   Speed
        -   Data storage size and capacity
        -   Bus width
        -   Power Consumption
        -   Cost
   * Embedded system requirements:
       - Program memory for holding control algorithm or embedded OS and the applications
         designed to run on top of OS.
       - Data memory for holding variables and temporary data during task execution.
       - Memory for holding non-volatile data which are modifiable by the application.